From nobody Sun Feb 8 04:12:46 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFFBD13635E for ; Mon, 12 May 2025 12:34:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053274; cv=none; b=ShYQ/uQn+hJRLe0yM3VAGOT6YJMx8QYcxf13azZskdk9I44n/iLVzpqqYsVxzRmW19IIBa8bfUJkCBBJ7RWi88hVN1ksHSL6oFGuI2lA3N7qsBFVGS87m1aY1eUqkA54X1jPZQ3oGsHXk+FS+LCPE+BkfbPBmO17FLVBAytHzag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053274; c=relaxed/simple; bh=8iSz8jBeX1KZuRVVHaPIDDcwWFktOFemhE20zzNrMbs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TWGTqlqD8fHKqPKJe/DV5nWo0gtHD1Ou5H9FySC3UrdzjMo7dreMT2EomfFR7TgZ0P0EjkB0R8qhM9DQHfx7ORXTsq6UVRDkIv+BdodSBZ6AmAcauaXk6BGX/1Q1XB+sC3migXPlYJZo4eg/cIgKtd6quzbrmGmOHP3xSqhv0FU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XEEC2sbL; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XEEC2sbL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747053271; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hrbmXyUL7HXGUWgagRU2heQ2lgkOZ/iJWMnvv1t5buw=; b=XEEC2sbLTsqZnMRnts1BYsjAWLELeqpMBsreyOmvs4qLCz2ED2x5+nES01ayGSOJweCLlu XpJ2woI+bMy0ZmouDloX5PMN9+03IQAcX6Hw2F+wSu0cZSVs5tk+nsszOP8zcr7zkQcDGo pY81ONAro/B3J0xvautKdwD5CyFx/p8= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-248-jYn_B_E9PfyAK8EFm1NE9A-1; Mon, 12 May 2025 08:34:30 -0400 X-MC-Unique: jYn_B_E9PfyAK8EFm1NE9A-1 X-Mimecast-MFC-AGG-ID: jYn_B_E9PfyAK8EFm1NE9A_1747053269 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-442dc6f0138so9402875e9.0 for ; Mon, 12 May 2025 05:34:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747053269; x=1747658069; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hrbmXyUL7HXGUWgagRU2heQ2lgkOZ/iJWMnvv1t5buw=; b=m1coeqlW+aGodffYAmw2lNChJZiFJXpqa0GH8s4geghWq7FRnja2eT5oO2idZqdBMN tYZJz1PpZ3crbsaJNMx1f/n5nG+oIhKJxBlejZByoQQHnwY407YVQSNtQR3du2BTsThz wx8hxcGlCNlzmdGeqHmac43xLU0u5lQiw5X6H7EjyOdf4aTWl9mUovmPr8BJxsfdQC1P qSZrrmU+l0xXISsGmoE9oMfM8JVybVCJiszHdJuGQJ5wxFNfByRjZ8WZhU49cRNynvq/ IjxYsMHGrZaUqJihBtKMyOEsN/MtRPxDWmXXDKc2AzBFEun70ozPCVC5SnSRCHbdoMet RCrw== X-Gm-Message-State: AOJu0YxhuypUrr5Na8enb8Dk2O9366QwBPX4qkoGej/setkY0c94vFIX pgrktzCx09BrITWuOI+CezT6CciW9pQlsgibfUGcBeua7AvRLP1XJBv90njdqWjY7K1plUMVBrz tlNZisfLPoe7ToSPLxBVxwiJ15x3SZPt0Z1CrpGSIs7YLkHHbrqs/ayiiKbzDHos5F202nTdGoE 7h1nWsI/ww/QAQHrMLOfNesfHrzwdvSs6RWJVA9BNayjfu X-Gm-Gg: ASbGnctPtlYJlHDqeD2cBMPUdqxRVTRbiXiuMuvR7Z71eChtpC3d9aRXyF/A7+20kEE DrKep/Mu2QNb65KisHpDA8N//Ew+W3SQW4JsNOU//3JPFZBI552llIOXviGt4uZFy5+c5GWM8kj nWkQF2VaqZNAi8zH0Z0chCgxLkHyPcuXckNmEKx5gMiUC4ANU4e5GVjl/yXG83h/fqpY2OgrUx9 /GW667z4LB6YB4UvPKe4SBerYEcZmZtLP+J9oLgWiqxifkUeyGLEJ9WRtaxoNcI/rzRDp5ddTr/ UhzAauA/8hvTFmO4kY3/AJYK0fckN2Fau8Y9vdQoJOQ5S/2EOjQrnp752OVrn1bVDbxPpqgf X-Received: by 2002:a05:600c:444c:b0:43d:5ec:b2f4 with SMTP id 5b1f17b1804b1-442d6d3dcc8mr126250245e9.10.1747053269349; Mon, 12 May 2025 05:34:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7YFyagUZ9y+fevUV3BzP4ffMO+2lnku0MMlhrkvHNYDdbfZ5KLiwSKLyxUHWcSulKlrGmcw== X-Received: by 2002:a05:600c:444c:b0:43d:5ec:b2f4 with SMTP id 5b1f17b1804b1-442d6d3dcc8mr126249585e9.10.1747053268821; Mon, 12 May 2025 05:34:28 -0700 (PDT) Received: from localhost (p200300d82f4a5800f1ae8e20d7f451b0.dip0.t-ipconnect.de. [2003:d8:2f4a:5800:f1ae:8e20:d7f4:51b0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-442d687adc0sm123327975e9.35.2025.05.12.05.34.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 May 2025 05:34:28 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-trace-kernel@vger.kernel.org, David Hildenbrand , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , Peter Xu , Ingo Molnar Subject: [PATCH v2 01/11] x86/mm/pat: factor out setting cachemode into pgprot_set_cachemode() Date: Mon, 12 May 2025 14:34:14 +0200 Message-ID: <20250512123424.637989-2-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512123424.637989-1-david@redhat.com> References: <20250512123424.637989-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's factor it out to make the code easier to grasp. Drop one comment where it is now rather obvious what is happening. Use it also in pgprot_writecombine()/pgprot_writethrough() where clearing the old cachemode might not be required, but given that we are already doing a function call, no need to care about this micro-optimization. Reviewed-by: Lorenzo Stoakes Acked-by: Ingo Molnar # x86 bits Signed-off-by: David Hildenbrand Reviewed-by: Liam R. Howlett --- arch/x86/mm/pat/memtype.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c index 72d8cbc611583..edec5859651d6 100644 --- a/arch/x86/mm/pat/memtype.c +++ b/arch/x86/mm/pat/memtype.c @@ -800,6 +800,12 @@ static inline int range_is_allowed(unsigned long pfn, = unsigned long size) } #endif /* CONFIG_STRICT_DEVMEM */ =20 +static inline void pgprot_set_cachemode(pgprot_t *prot, enum page_cache_mo= de pcm) +{ + *prot =3D __pgprot((pgprot_val(*prot) & ~_PAGE_CACHE_MASK) | + cachemode2protval(pcm)); +} + int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn, unsigned long size, pgprot_t *vma_prot) { @@ -811,8 +817,7 @@ int phys_mem_access_prot_allowed(struct file *file, uns= igned long pfn, if (file->f_flags & O_DSYNC) pcm =3D _PAGE_CACHE_MODE_UC_MINUS; =20 - *vma_prot =3D __pgprot((pgprot_val(*vma_prot) & ~_PAGE_CACHE_MASK) | - cachemode2protval(pcm)); + pgprot_set_cachemode(vma_prot, pcm); return 1; } =20 @@ -880,9 +885,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long s= ize, pgprot_t *vma_prot, (unsigned long long)paddr, (unsigned long long)(paddr + size - 1), cattr_name(pcm)); - *vma_prot =3D __pgprot((pgprot_val(*vma_prot) & - (~_PAGE_CACHE_MASK)) | - cachemode2protval(pcm)); + pgprot_set_cachemode(vma_prot, pcm); } return 0; } @@ -907,9 +910,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long s= ize, pgprot_t *vma_prot, * We allow returning different type than the one requested in * non strict case. */ - *vma_prot =3D __pgprot((pgprot_val(*vma_prot) & - (~_PAGE_CACHE_MASK)) | - cachemode2protval(pcm)); + pgprot_set_cachemode(vma_prot, pcm); } =20 if (memtype_kernel_map_sync(paddr, size, pcm) < 0) { @@ -1060,9 +1061,7 @@ int track_pfn_remap(struct vm_area_struct *vma, pgpro= t_t *prot, return -EINVAL; } =20 - *prot =3D __pgprot((pgprot_val(*prot) & (~_PAGE_CACHE_MASK)) | - cachemode2protval(pcm)); - + pgprot_set_cachemode(prot, pcm); return 0; } =20 @@ -1073,10 +1072,8 @@ void track_pfn_insert(struct vm_area_struct *vma, pg= prot_t *prot, pfn_t pfn) if (!pat_enabled()) return; =20 - /* Set prot based on lookup */ pcm =3D lookup_memtype(pfn_t_to_phys(pfn)); - *prot =3D __pgprot((pgprot_val(*prot) & (~_PAGE_CACHE_MASK)) | - cachemode2protval(pcm)); + pgprot_set_cachemode(prot, pcm); } =20 /* @@ -1115,15 +1112,15 @@ void untrack_pfn_clear(struct vm_area_struct *vma) =20 pgprot_t pgprot_writecombine(pgprot_t prot) { - return __pgprot(pgprot_val(prot) | - cachemode2protval(_PAGE_CACHE_MODE_WC)); + pgprot_set_cachemode(&prot, _PAGE_CACHE_MODE_WC); + return prot; } EXPORT_SYMBOL_GPL(pgprot_writecombine); =20 pgprot_t pgprot_writethrough(pgprot_t prot) { - return __pgprot(pgprot_val(prot) | - cachemode2protval(_PAGE_CACHE_MODE_WT)); + pgprot_set_cachemode(&prot, _PAGE_CACHE_MODE_WT); + return prot; } EXPORT_SYMBOL_GPL(pgprot_writethrough); =20 --=20 2.49.0 From nobody Sun Feb 8 04:12:46 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 823DA29374F for ; Mon, 12 May 2025 12:34:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053277; cv=none; b=nlKK4ekkhE2jRLs6xSkxz80JYo9dfjuKWO0BKEbTLHzzhCkJT3w3s87FErX1BTrjWz4N1wPLXpYIbscW6YLKBQw8DqCaigCw0+G+dUHYGAme71IxP3LKkClEv9r3R1B1COktgWiWsI5iziokMvNEmncEjfUQh/ar1Slw/onJ/6U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053277; c=relaxed/simple; bh=HzndHn4T9ZYXppW40wlrwQTTad9pQBIWeyR83towNBk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d3qNkcJ1tvKzQwTc9Ook/OpSPeBwMta7uQ5rimk/+Lhd1imGW4qmA3CmRPwIVE7e4O6xed00rtTi/T/sIkIbKCXOsn4H9A5ZtUnH7i7Ay9OD3l1C3oXWOictBdrGafLwqycku6NmkZ+DDSLc86Ko9805knehQosQY3r6lMpMlh8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XU7KZpEb; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XU7KZpEb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747053274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6nHoWozKkbl8Jpefo8Zb0yf0bGe9671cYhr6GgVPgWI=; b=XU7KZpEbfEykLhfQI+z1q21uD/1rqOzJNYfYDhkoDqPV4nghRTGwj2IBfAqLW8qSl2Vf8/ S152sUP6wIHGw/MBbdEaq+C8siUUZGfwgUG8O2IP1aek4yUDW0L0w3otA841armyU66O1N R6n7xGtfbj/8Pn0dNFf4xQDS9/tf/bY= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-3or5fRMlOfGBppAAxvc_jA-1; Mon, 12 May 2025 08:34:33 -0400 X-MC-Unique: 3or5fRMlOfGBppAAxvc_jA-1 X-Mimecast-MFC-AGG-ID: 3or5fRMlOfGBppAAxvc_jA_1747053272 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43eed325461so23224995e9.3 for ; Mon, 12 May 2025 05:34:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747053272; x=1747658072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6nHoWozKkbl8Jpefo8Zb0yf0bGe9671cYhr6GgVPgWI=; b=wbuaFazm6RxKXaJQcwjlFaSsf34htmhnOWHFpx659QDUnW5TEWYgiY6O5NkVZtPR8q GsR97nEPvspPK35eLrQL1PbK0jcJ7wr0Tfyi9XJU0Gh2X0gbKO02Wkt8LpfL0Bf2Uwsu gM7KjpMHwCll1EW7qlv99KH7bd1cVpEj8s2KLKJxo4n2F9tSbyGnDzIFT0Yhgiw9HCmh ZddcQ7GzV+BRMEPFnj+nWcMWpcJN7imx6Sg8twJwC9SVj/YYpxtO2mLPOMye5F8r4RFd EiCFSfMHKGvRQFUDh+rapxLTPi/V/t2jKXwU5WME+yYuFHEOxjfYuUj/scL0Tjetyrdw ztHQ== X-Gm-Message-State: AOJu0YwSUPQeIOoV+RGkJs1ciZpnE6jKXtR5H4+A48Z0hxB9ubbXLywm rHJCuw08BLRkzD82URyDEeEfvn3+Xjlxoomd247UoUV4fO88ZNXB2lPxq6x9F9J2qFDWE+P9WUY O98S4Vkw3oETrSqCxTj8CA8Wn8y0k5oIAThKKVlZuyOx23ddMLsi7UgVrpWl+4O8AwkMyBxRI+P Qq7pJiQL/F3AlretRjs3bK4afgF41VZ1A9LFRTd2fnyo/Y X-Gm-Gg: ASbGncvNjx6LhqCZDR3Gfs6GwRyuj1iYVMvmIngb5V13qEOfELB4Nov8MM4wj2EyRhD lEHYzjW2dQz0DAtgpC2i/M0ejyADfOJr5aCHW3HH+UXteaJDityR4XcIzuK6mnw+yQ1gO81UTfE 8X19uELj6+jzz02bl8LAM5qi2dzb82FeLhvw8AFobf0iS1ojO6+8b8XgWT2yTU8xk9VPrh3QYCN 3wakMmJ1RFLCTdayLV+1blrPUU1QTmOyaCcX/BlhlmbTZN5sxQBrA6e59/rZi8tkR+6FUMe9in/ T5cW8kY+p/HSSrH1gZiJpRINe5V6Z8jAinHJZCaG7w5YqKKLBE7t6gVXtul7dm5vBDeZJa5t X-Received: by 2002:a05:600c:3490:b0:441:d4e8:76cd with SMTP id 5b1f17b1804b1-442d6ddec00mr105442565e9.29.1747053272142; Mon, 12 May 2025 05:34:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAkmJW1RYt0shbyVSJYG/Cde8Y5kgDkvTgdUylwEM8H1PlNDd2NNsMG+k4pYVsizSZx0oo/Q== X-Received: by 2002:a05:600c:3490:b0:441:d4e8:76cd with SMTP id 5b1f17b1804b1-442d6ddec00mr105442015e9.29.1747053271651; Mon, 12 May 2025 05:34:31 -0700 (PDT) Received: from localhost (p200300d82f4a5800f1ae8e20d7f451b0.dip0.t-ipconnect.de. [2003:d8:2f4a:5800:f1ae:8e20:d7f4:51b0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-442cd32f331sm168479925e9.13.2025.05.12.05.34.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 May 2025 05:34:31 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-trace-kernel@vger.kernel.org, David Hildenbrand , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , Peter Xu , Ingo Molnar Subject: [PATCH v2 02/11] mm: convert track_pfn_insert() to pfnmap_setup_cachemode*() Date: Mon, 12 May 2025 14:34:15 +0200 Message-ID: <20250512123424.637989-3-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512123424.637989-1-david@redhat.com> References: <20250512123424.637989-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ... by factoring it out from track_pfn_remap() into pfnmap_setup_cachemode() and provide pfnmap_setup_cachemode_pfn() as a replacement for track_pfn_insert(). For PMDs/PUDs, we keep checking a single pfn only. Add some documentation, and also document why it is valid to not check the whole pfn range. We'll reuse pfnmap_setup_cachemode() from core MM next. Acked-by: Ingo Molnar # x86 bits Signed-off-by: David Hildenbrand Reviewed-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- arch/x86/mm/pat/memtype.c | 24 ++++++------------ include/linux/pgtable.h | 52 +++++++++++++++++++++++++++++++++------ mm/huge_memory.c | 5 ++-- mm/memory.c | 4 +-- 4 files changed, 57 insertions(+), 28 deletions(-) diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c index edec5859651d6..fa78facc6f633 100644 --- a/arch/x86/mm/pat/memtype.c +++ b/arch/x86/mm/pat/memtype.c @@ -1031,7 +1031,6 @@ int track_pfn_remap(struct vm_area_struct *vma, pgpro= t_t *prot, unsigned long pfn, unsigned long addr, unsigned long size) { resource_size_t paddr =3D (resource_size_t)pfn << PAGE_SHIFT; - enum page_cache_mode pcm; =20 /* reserve the whole chunk starting from paddr */ if (!vma || (addr =3D=3D vma->vm_start @@ -1044,13 +1043,17 @@ int track_pfn_remap(struct vm_area_struct *vma, pgp= rot_t *prot, return ret; } =20 + return pfnmap_setup_cachemode(pfn, size, prot); +} + +int pfnmap_setup_cachemode(unsigned long pfn, unsigned long size, pgprot_t= *prot) +{ + resource_size_t paddr =3D (resource_size_t)pfn << PAGE_SHIFT; + enum page_cache_mode pcm; + if (!pat_enabled()) return 0; =20 - /* - * For anything smaller than the vma size we set prot based on the - * lookup. - */ pcm =3D lookup_memtype(paddr); =20 /* Check memtype for the remaining pages */ @@ -1065,17 +1068,6 @@ int track_pfn_remap(struct vm_area_struct *vma, pgpr= ot_t *prot, return 0; } =20 -void track_pfn_insert(struct vm_area_struct *vma, pgprot_t *prot, pfn_t pf= n) -{ - enum page_cache_mode pcm; - - if (!pat_enabled()) - return; - - pcm =3D lookup_memtype(pfn_t_to_phys(pfn)); - pgprot_set_cachemode(prot, pcm); -} - /* * untrack_pfn is called while unmapping a pfnmap for a region. * untrack can be called for a specific region indicated by pfn and size or diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index f1e890b604609..be1745839871c 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1496,13 +1496,10 @@ static inline int track_pfn_remap(struct vm_area_st= ruct *vma, pgprot_t *prot, return 0; } =20 -/* - * track_pfn_insert is called when a _new_ single pfn is established - * by vmf_insert_pfn(). - */ -static inline void track_pfn_insert(struct vm_area_struct *vma, pgprot_t *= prot, - pfn_t pfn) +static inline int pfnmap_setup_cachemode(unsigned long pfn, unsigned long = size, + pgprot_t *prot) { + return 0; } =20 /* @@ -1552,8 +1549,32 @@ static inline void untrack_pfn_clear(struct vm_area_= struct *vma) extern int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, unsigned long pfn, unsigned long addr, unsigned long size); -extern void track_pfn_insert(struct vm_area_struct *vma, pgprot_t *prot, - pfn_t pfn); + +/** + * pfnmap_setup_cachemode - setup the cachemode in the pgprot for a pfn ra= nge + * @pfn: the start of the pfn range + * @size: the size of the pfn range in bytes + * @prot: the pgprot to modify + * + * Lookup the cachemode for the pfn range starting at @pfn with the size + * @size and store it in @prot, leaving other data in @prot unchanged. + * + * This allows for a hardware implementation to have fine-grained control = of + * memory cache behavior at page level granularity. Without a hardware + * implementation, this function does nothing. + * + * Currently there is only one implementation for this - x86 Page Attribute + * Table (PAT). See Documentation/arch/x86/pat.rst for more details. + * + * This function can fail if the pfn range spans pfns that require differi= ng + * cachemodes. If the pfn range was previously verified to have a single + * cachemode, it is sufficient to query only a single pfn. The assumption = is + * that this is the case for drivers using the vmf_insert_pfn*() interface. + * + * Returns 0 on success and -EINVAL on error. + */ +int pfnmap_setup_cachemode(unsigned long pfn, unsigned long size, + pgprot_t *prot); extern int track_pfn_copy(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, unsigned long *pfn); extern void untrack_pfn_copy(struct vm_area_struct *dst_vma, @@ -1563,6 +1584,21 @@ extern void untrack_pfn(struct vm_area_struct *vma, = unsigned long pfn, extern void untrack_pfn_clear(struct vm_area_struct *vma); #endif =20 +/** + * pfnmap_setup_cachemode_pfn - setup the cachemode in the pgprot for a pfn + * @pfn: the pfn + * @prot: the pgprot to modify + * + * Lookup the cachemode for @pfn and store it in @prot, leaving other + * data in @prot unchanged. + * + * See pfnmap_setup_cachemode() for details. + */ +static inline void pfnmap_setup_cachemode_pfn(unsigned long pfn, pgprot_t = *prot) +{ + pfnmap_setup_cachemode(pfn, PAGE_SIZE, prot); +} + #ifdef CONFIG_MMU #ifdef __HAVE_COLOR_ZERO_PAGE static inline int is_zero_pfn(unsigned long pfn) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 2780a12b25f01..d3e66136e41a3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1455,7 +1455,8 @@ vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, p= fn_t pfn, bool write) return VM_FAULT_OOM; } =20 - track_pfn_insert(vma, &pgprot, pfn); + pfnmap_setup_cachemode_pfn(pfn_t_to_pfn(pfn), &pgprot); + ptl =3D pmd_lock(vma->vm_mm, vmf->pmd); error =3D insert_pfn_pmd(vma, addr, vmf->pmd, pfn, pgprot, write, pgtable); @@ -1577,7 +1578,7 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_fault *vmf, p= fn_t pfn, bool write) if (addr < vma->vm_start || addr >=3D vma->vm_end) return VM_FAULT_SIGBUS; =20 - track_pfn_insert(vma, &pgprot, pfn); + pfnmap_setup_cachemode_pfn(pfn_t_to_pfn(pfn), &pgprot); =20 ptl =3D pud_lock(vma->vm_mm, vmf->pud); insert_pfn_pud(vma, addr, vmf->pud, pfn, write); diff --git a/mm/memory.c b/mm/memory.c index 99af83434e7c5..064fc55d8eab9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2564,7 +2564,7 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct = *vma, unsigned long addr, if (!pfn_modify_allowed(pfn, pgprot)) return VM_FAULT_SIGBUS; =20 - track_pfn_insert(vma, &pgprot, __pfn_to_pfn_t(pfn, PFN_DEV)); + pfnmap_setup_cachemode_pfn(pfn, &pgprot); =20 return insert_pfn(vma, addr, __pfn_to_pfn_t(pfn, PFN_DEV), pgprot, false); @@ -2627,7 +2627,7 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_st= ruct *vma, if (addr < vma->vm_start || addr >=3D vma->vm_end) return VM_FAULT_SIGBUS; =20 - track_pfn_insert(vma, &pgprot, pfn); + pfnmap_setup_cachemode_pfn(pfn_t_to_pfn(pfn), &pgprot); =20 if (!pfn_modify_allowed(pfn_t_to_pfn(pfn), pgprot)) return VM_FAULT_SIGBUS; --=20 2.49.0 From nobody Sun Feb 8 04:12:46 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D2E4293B6D for ; Mon, 12 May 2025 12:34:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053279; cv=none; b=GguUVY+4E7KuRTwdfS3z6TnW4bQZZmkU7pvE4FQZ3n1WLms+DfZ2ESBim1qkz7BPWfNgjIc8jrnrMfL9QOkAJR7Y/nJxLjIeZ0ZaXsT5IzxOw1XSvFsnYXGufaZoZa345Mq3EVdkO7oBYoQdemO59ZLn6BBBqfa808WdHrew89A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053279; c=relaxed/simple; bh=7m+BzEd74yqLbmLjeWAIwrgcejBZOMr6mqnEZdo2IKg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cCLuZ+QhZ7vwDCDtxXsXXeimhuOsN/fMdcfsHPuww54fiZOOzu15v5dvh1cyOr+ydDneW8wPaq7P70vKSC82InkbB4iEKVa0GchEAWQGhdV0OPY4MPW6qXFux5VMkHE7Ktho7cUArKCm+iBAmTd9aekauV1W69cdMDF+CHW7sZ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iBE1IYoo; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iBE1IYoo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747053276; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vjnnC5BACKQYADpf3O8+rlLTsN5UNkR42iRu+4jj/5k=; b=iBE1IYoonLkZatsAJEUgQRlze52E0N8N/CyPJCVtwoF1Q7IVbJ9E0fN0ObtHpJiWQ2RllF 0x40Qb2l/6Fx6AjcnnzypQ17FmDX9eRhZvFGkNVDYobOD3xZTsAWBqae59H6nv9qyFD04E fNFQJO8PiOl+XkwRk7SHTek5I/BG5ts= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-542-FZNXt8_4PgCUjKIlbrqBJA-1; Mon, 12 May 2025 08:34:35 -0400 X-MC-Unique: FZNXt8_4PgCUjKIlbrqBJA-1 X-Mimecast-MFC-AGG-ID: FZNXt8_4PgCUjKIlbrqBJA_1747053274 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-442dc6f0138so9403475e9.0 for ; Mon, 12 May 2025 05:34:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747053274; x=1747658074; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vjnnC5BACKQYADpf3O8+rlLTsN5UNkR42iRu+4jj/5k=; b=AcLc06UGLNSpY4LhFyo9eb7Qql2shwUkJnafPSDZi5W1kHUOoLNa2DR7fRW6fsrAOV gJSHjrbaXk1eV9hSOgqc03Fs1RwmFbW/FKOGS+kFIDDIA3b3+4F+ze4wh3yUi09MFFoP rWAGFPwO9G8AmSbZLds1bB34hnu0TvmF/3jSCH6ln8XlT5G/y5WUhQQSX2MU5yNzlO/N +3Mcr+IG8SRPU88lJLGuOSyJzBbP2mlfqjbOCQISv4hUieJqdMPjYPGe0ZXwF2bTS2HR Q+YghRiDdOT+NJUA1GrTt/Qcb/b8HkIYnj6VHXXSE5a1UjHNNdpUr93HHRn2/PJdflAG q7Cw== X-Gm-Message-State: AOJu0Yyzhy1SpH3bGa9P0HZchL5Xn6mbu7JltVGRSerm7CMpbMYPQFks iofjOFVMeMm9W1O4HnD+dvtF/AbNjTGW/o5XqUGyx+kAbBgZO/EQP+6+kZol43wESaJ3W4Udh/4 tqmMAIyY18rFGoLV/GEqlARNAu1rXFf0a26UFdNhZBazIJgccDOGGWrYSbqSEELntBV+GWmFADX 60CG9hMFlHe13WzRjcdx2Fx7SJ56BH3O1CeNR66VP+kycA X-Gm-Gg: ASbGncvsoMebfwGDMA4A3G74fujH/Mza5dAdwAQy0n64cVTQFS4eC35wdY8eDN5b+QS FpSaju02bRf0TyJaKg/cT8qYDiim3+R0XcXZ6kuztzyUmtDOX7fApC1kzS4xk+FLCUJd5PgfBhF N468NzoHeXOqoqlEx1rvD8MU02KR+i+wlHTtzN4TLQWsZfdsRzRNEFOcCrsxpKp5jr3kQBiJ3MA yVrT0ARIgMuUxxQoROYYABNkhpsRSgsW/odIsEJaZyoWVA6OUJFJc0mwSQ/nupOfQQ4bEx4wc90 9lDPXD/B7BoZ0MKgHv6mnGS/ujLRjQqT/nRPxk0Zqqhj1pjBYsKkvdPrvHKpO4Ac31bljim7 X-Received: by 2002:a05:600c:5118:b0:43d:cc9:b09d with SMTP id 5b1f17b1804b1-442d6dc539cmr82258675e9.20.1747053274417; Mon, 12 May 2025 05:34:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLHMAxfNnCQj32PB2xBlHRpvgTd61IhRYv44GdPG9fUkbIQCt1pbTkP7UkTO09z7pcUrC5ng== X-Received: by 2002:a05:600c:5118:b0:43d:cc9:b09d with SMTP id 5b1f17b1804b1-442d6dc539cmr82258205e9.20.1747053273921; Mon, 12 May 2025 05:34:33 -0700 (PDT) Received: from localhost (p200300d82f4a5800f1ae8e20d7f451b0.dip0.t-ipconnect.de. [2003:d8:2f4a:5800:f1ae:8e20:d7f4:51b0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-442d67df5ecsm123693385e9.9.2025.05.12.05.34.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 May 2025 05:34:33 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-trace-kernel@vger.kernel.org, David Hildenbrand , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , Peter Xu , Ingo Molnar Subject: [PATCH v2 03/11] mm: introduce pfnmap_track() and pfnmap_untrack() and use them for memremap Date: Mon, 12 May 2025 14:34:16 +0200 Message-ID: <20250512123424.637989-4-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512123424.637989-1-david@redhat.com> References: <20250512123424.637989-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's provide variants of track_pfn_remap() and untrack_pfn() that won't mess with VMAs, and replace the usage in mm/memremap.c. Add some documentation. Reviewed-by: Lorenzo Stoakes Acked-by: Ingo Molnar # x86 bits Signed-off-by: David Hildenbrand Reviewed-by: Liam R. Howlett --- arch/x86/mm/pat/memtype.c | 14 ++++++++++++++ include/linux/pgtable.h | 39 +++++++++++++++++++++++++++++++++++++++ mm/memremap.c | 8 ++++---- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c index fa78facc6f633..1ec8af6cad6bf 100644 --- a/arch/x86/mm/pat/memtype.c +++ b/arch/x86/mm/pat/memtype.c @@ -1068,6 +1068,20 @@ int pfnmap_setup_cachemode(unsigned long pfn, unsign= ed long size, pgprot_t *prot return 0; } =20 +int pfnmap_track(unsigned long pfn, unsigned long size, pgprot_t *prot) +{ + const resource_size_t paddr =3D (resource_size_t)pfn << PAGE_SHIFT; + + return reserve_pfn_range(paddr, size, prot, 0); +} + +void pfnmap_untrack(unsigned long pfn, unsigned long size) +{ + const resource_size_t paddr =3D (resource_size_t)pfn << PAGE_SHIFT; + + free_pfn_range(paddr, size); +} + /* * untrack_pfn is called while unmapping a pfnmap for a region. * untrack can be called for a specific region indicated by pfn and size or diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index be1745839871c..90f72cd358390 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1502,6 +1502,16 @@ static inline int pfnmap_setup_cachemode(unsigned lo= ng pfn, unsigned long size, return 0; } =20 +static inline int pfnmap_track(unsigned long pfn, unsigned long size, + pgprot_t *prot) +{ + return 0; +} + +static inline void pfnmap_untrack(unsigned long pfn, unsigned long size) +{ +} + /* * track_pfn_copy is called when a VM_PFNMAP VMA is about to get the page * tables copied during copy_page_range(). Will store the pfn to be @@ -1575,6 +1585,35 @@ extern int track_pfn_remap(struct vm_area_struct *vm= a, pgprot_t *prot, */ int pfnmap_setup_cachemode(unsigned long pfn, unsigned long size, pgprot_t *prot); + +/** + * pfnmap_track - track a pfn range + * @pfn: the start of the pfn range + * @size: the size of the pfn range in bytes + * @prot: the pgprot to track + * + * Requested the pfn range to be 'tracked' by a hardware implementation and + * setup the cachemode in @prot similar to pfnmap_setup_cachemode(). + * + * This allows for fine-grained control of memory cache behaviour at page + * level granularity. Tracking memory this way is persisted across VMA spl= its + * (VMA merging does not apply for VM_PFNMAP). + * + * Currently, there is only one implementation for this - x86 Page Attribu= te + * Table (PAT). See Documentation/arch/x86/pat.rst for more details. + * + * Returns 0 on success and -EINVAL on error. + */ +int pfnmap_track(unsigned long pfn, unsigned long size, pgprot_t *prot); + +/** + * pfnmap_untrack - untrack a pfn range + * @pfn: the start of the pfn range + * @size: the size of the pfn range in bytes + * + * Untrack a pfn range previously tracked through pfnmap_track(). + */ +void pfnmap_untrack(unsigned long pfn, unsigned long size); extern int track_pfn_copy(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, unsigned long *pfn); extern void untrack_pfn_copy(struct vm_area_struct *dst_vma, diff --git a/mm/memremap.c b/mm/memremap.c index 2aebc1b192da9..c417c843e9b1f 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -130,7 +130,7 @@ static void pageunmap_range(struct dev_pagemap *pgmap, = int range_id) } mem_hotplug_done(); =20 - untrack_pfn(NULL, PHYS_PFN(range->start), range_len(range), true); + pfnmap_untrack(PHYS_PFN(range->start), range_len(range)); pgmap_array_delete(range); } =20 @@ -211,8 +211,8 @@ static int pagemap_range(struct dev_pagemap *pgmap, str= uct mhp_params *params, if (nid < 0) nid =3D numa_mem_id(); =20 - error =3D track_pfn_remap(NULL, ¶ms->pgprot, PHYS_PFN(range->start), = 0, - range_len(range)); + error =3D pfnmap_track(PHYS_PFN(range->start), range_len(range), + ¶ms->pgprot); if (error) goto err_pfn_remap; =20 @@ -277,7 +277,7 @@ static int pagemap_range(struct dev_pagemap *pgmap, str= uct mhp_params *params, if (!is_private) kasan_remove_zero_shadow(__va(range->start), range_len(range)); err_kasan: - untrack_pfn(NULL, PHYS_PFN(range->start), range_len(range), true); + pfnmap_untrack(PHYS_PFN(range->start), range_len(range)); err_pfn_remap: pgmap_array_delete(range); return error; --=20 2.49.0 From nobody Sun Feb 8 04:12:46 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07429294A0C for ; Mon, 12 May 2025 12:34:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053284; cv=none; b=NIbaCsm9WlTzEbdJHlFVJQmGGsjlQOrtQ8FwnGefLVjRYMHHGSdSu1CjPRNn8i5oATw/sSU0JSE5ZQZOA0xTXOqr02IL8zPjQb1RV9LikgJL0cEfEk13rLF7xd5gmw91X2xv2tHmdlcnH6Ti9shKMT5fkcUcy8r+nLvPRULK8E4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053284; c=relaxed/simple; bh=2GaZjzn3CoqrV8e+uJviIdXRB1JEBQSNA1uHS4huF4c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fl8Z0VDF1FUU+TF+0bARI92+gf9R9CVCRBwfl8iBC5g/vGn7B3/tKiBHNf/iXxx7Ovw73HtI8pQqO20bHUn196ccYHEiBwtsBawQN4MNMj5zkXwadr38SY0sOUwKjSW8+mWp46SRtRbhiCXQTYoI7Q/RgYhcDjriMqqk9uIKRQ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SsNn0uul; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SsNn0uul" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747053280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NYDrLvG5XDZK2S7Vzjb3pmEnm43v74kkrfTla5+cPZI=; b=SsNn0uulAPj3HprWE5BGzjkYGXpBbHfHOV0kiIF9kf+knbJZ4GF95sKRntqQX2SpxrpWFL VxqQbKVCtC5Zmz0kbIE5Po+9rIn2SAwOztgF5Q4XJml6dagT0Lbg3m4iWWQLi4M2GO20Jj XLyVd0p5p4QEMPEaQZU//FRMT4IUanY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-371--Rfgbxl6M2qFwQ9SvvNq4Q-1; Mon, 12 May 2025 08:34:39 -0400 X-MC-Unique: -Rfgbxl6M2qFwQ9SvvNq4Q-1 X-Mimecast-MFC-AGG-ID: -Rfgbxl6M2qFwQ9SvvNq4Q_1747053278 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a0bd786a53so1767583f8f.0 for ; Mon, 12 May 2025 05:34:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747053278; x=1747658078; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NYDrLvG5XDZK2S7Vzjb3pmEnm43v74kkrfTla5+cPZI=; b=TcnPtClyJqxqaEcGcDPHQ3XncRqxYVic2mFb9VN6To81+mozqkxIMBxPoQqL87FeD6 Q4HlLAacAdidGUDx+PsIdICC6LkT3dBOzNcl9K7zSdyJa9LOThQbZ6/kX/VTi0MYPWlQ xhSFd0b2pQ9exW2PsrNrVo/xubYvS5NrNB9X3GuqvFRqH+aNt+aKbZp0Lm2mlsP/j522 TUGOGU9+MkBILZiCBbxPTftVvnsCvKWr3e+XFKH7u0f0KdgaAIpPE15t/t1qWMEe7B+8 q/G2uIijfKujCe3R7AWlQjjGlrL9mkYLEtbVdaPZbh/9UsLpCxjXzTsw2zCMD/hwtJEe h5IA== X-Gm-Message-State: AOJu0YwZDaT+HWibAfKATRZ2U/VxAJ71/c+rVY75KDVxaEeLKgsDkyAT KiC4rGQMnpMP+LDVFYihQPjFkR/7czuofOZvlFQ3MBxqZ6UlQPH7LZGhlY769eOL1otdDW8GUj0 kJwR078QGgBORRRlR1HfYDv8gRMHrcMWoVTufOHlMONX/BD/bqavSVODoAfOkyhdDqK2obvTUL8 2OS6KDLnYTmKqQBmBl/VejR2cTrCCJ9LPQR1UJh53tfZOP X-Gm-Gg: ASbGncu/kzwNoeG5JS1x5aA4JoyVltfjHa39Q6441at3WLPRmsMUIU5BQN9icDnYaBD 7VANXjjjb8mR3OdGtPJi70UYq6wdz0tNnfstSOVHvyFht0fOP1/hKicjQ+T/lXeWShVDnM4tqVJ mQNPwdzWih1+SN6PVQj9AnqCSApfI+upsTm5TR30poKZXm4AK9yUIuc1RP9aXjxTHw5hnwoN2/c Hq9pM7XHFFDuLWpxA6WLA9osPqxhpfkUYSxJjc6T5Fdl/Zl8TkLcO4a427Xaz55MnQM2f2Cu7HK Nn9/lcv+dYzzQ4piY+bamnVRi7hO0xwxwhHG9Qn+1Ue93j6ygoDK+PuLvN5lVp5LQABGDvxi X-Received: by 2002:a05:6000:430d:b0:3a0:b9a9:2fd9 with SMTP id ffacd0b85a97d-3a1f64a34c6mr10772134f8f.51.1747053278176; Mon, 12 May 2025 05:34:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhxNuxHtjAVwepTb/c5WYjIAvKZdsEfHNK/tmk5VSXnQqEoBOKdiBfd2UyPw5vI1dksu9fng== X-Received: by 2002:a05:6000:430d:b0:3a0:b9a9:2fd9 with SMTP id ffacd0b85a97d-3a1f64a34c6mr10772084f8f.51.1747053277633; Mon, 12 May 2025 05:34:37 -0700 (PDT) Received: from localhost (p200300d82f4a5800f1ae8e20d7f451b0.dip0.t-ipconnect.de. [2003:d8:2f4a:5800:f1ae:8e20:d7f4:51b0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-442d687ae10sm123566305e9.37.2025.05.12.05.34.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 May 2025 05:34:36 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-trace-kernel@vger.kernel.org, David Hildenbrand , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , Peter Xu , Ingo Molnar Subject: [PATCH v2 04/11] mm: convert VM_PFNMAP tracking to pfnmap_track() + pfnmap_untrack() Date: Mon, 12 May 2025 14:34:17 +0200 Message-ID: <20250512123424.637989-5-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512123424.637989-1-david@redhat.com> References: <20250512123424.637989-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's use our new interface. In remap_pfn_range(), we'll now decide whether we have to track (full VMA covered) or only lookup the cachemode (partial VMA covered). Remember what we have to untrack by linking it from the VMA. When duplicating VMAs (e.g., splitting, mremap, fork), we'll handle it similar to anon VMA names, and use a kref to share the tracking. Once the last VMA un-refs our tracking data, we'll do the untracking, which simplifies things a lot and should sort our various issues we saw recently, for example, when partially unmapping/zapping a tracked VMA. This change implies that we'll keep tracking the original PFN range even after splitting + partially unmapping it: not too bad, because it was not working reliably before. The only thing that kind-of worked before was shrinking such a mapping using mremap(): we managed to adjust the reservation in a hacky way, now we won't adjust the reservation but leave it around until all involved VMAs are gone. If that ever turns out to be an issue, we could hook into VM splitting code and split the tracking; however, that adds complexity that might not be required, so we'll keep it simple for now. Acked-by: Ingo Molnar # x86 bits Signed-off-by: David Hildenbrand Reviewed-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- include/linux/mm_inline.h | 2 + include/linux/mm_types.h | 11 ++++++ mm/memory.c | 82 +++++++++++++++++++++++++++++++-------- mm/mmap.c | 5 --- mm/mremap.c | 4 -- mm/vma_init.c | 50 ++++++++++++++++++++++++ 6 files changed, 129 insertions(+), 25 deletions(-) diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index f9157a0c42a5c..89b518ff097e6 100644 --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h @@ -447,6 +447,8 @@ static inline bool anon_vma_name_eq(struct anon_vma_nam= e *anon_name1, =20 #endif /* CONFIG_ANON_VMA_NAME */ =20 +void pfnmap_track_ctx_release(struct kref *ref); + static inline void init_tlb_flush_pending(struct mm_struct *mm) { atomic_set(&mm->tlb_flush_pending, 0); diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 15808cad2bc1a..3e934dc6057c4 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -763,6 +763,14 @@ struct vma_numab_state { int prev_scan_seq; }; =20 +#ifdef __HAVE_PFNMAP_TRACKING +struct pfnmap_track_ctx { + struct kref kref; + unsigned long pfn; + unsigned long size; /* in bytes */ +}; +#endif + /* * Describes a VMA that is about to be mmap()'ed. Drivers may choose to * manipulate mutable fields which will cause those fields to be updated i= n the @@ -900,6 +908,9 @@ struct vm_area_struct { struct anon_vma_name *anon_name; #endif struct vm_userfaultfd_ctx vm_userfaultfd_ctx; +#ifdef __HAVE_PFNMAP_TRACKING + struct pfnmap_track_ctx *pfnmap_track_ctx; +#endif } __randomize_layout; =20 #ifdef CONFIG_NUMA diff --git a/mm/memory.c b/mm/memory.c index 064fc55d8eab9..4cf4adb0de266 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1371,7 +1371,7 @@ copy_page_range(struct vm_area_struct *dst_vma, struc= t vm_area_struct *src_vma) struct mm_struct *dst_mm =3D dst_vma->vm_mm; struct mm_struct *src_mm =3D src_vma->vm_mm; struct mmu_notifier_range range; - unsigned long next, pfn =3D 0; + unsigned long next; bool is_cow; int ret; =20 @@ -1381,12 +1381,6 @@ copy_page_range(struct vm_area_struct *dst_vma, stru= ct vm_area_struct *src_vma) if (is_vm_hugetlb_page(src_vma)) return copy_hugetlb_page_range(dst_mm, src_mm, dst_vma, src_vma); =20 - if (unlikely(src_vma->vm_flags & VM_PFNMAP)) { - ret =3D track_pfn_copy(dst_vma, src_vma, &pfn); - if (ret) - return ret; - } - /* * We need to invalidate the secondary MMU mappings only when * there could be a permission downgrade on the ptes of the @@ -1428,8 +1422,6 @@ copy_page_range(struct vm_area_struct *dst_vma, struc= t vm_area_struct *src_vma) raw_write_seqcount_end(&src_mm->write_protect_seq); mmu_notifier_invalidate_range_end(&range); } - if (ret && unlikely(src_vma->vm_flags & VM_PFNMAP)) - untrack_pfn_copy(dst_vma, pfn); return ret; } =20 @@ -1924,9 +1916,6 @@ static void unmap_single_vma(struct mmu_gather *tlb, if (vma->vm_file) uprobe_munmap(vma, start, end); =20 - if (unlikely(vma->vm_flags & VM_PFNMAP)) - untrack_pfn(vma, 0, 0, mm_wr_locked); - if (start !=3D end) { if (unlikely(is_vm_hugetlb_page(vma))) { /* @@ -2872,6 +2861,36 @@ int remap_pfn_range_notrack(struct vm_area_struct *v= ma, unsigned long addr, return error; } =20 +#ifdef __HAVE_PFNMAP_TRACKING +static inline struct pfnmap_track_ctx *pfnmap_track_ctx_alloc(unsigned lon= g pfn, + unsigned long size, pgprot_t *prot) +{ + struct pfnmap_track_ctx *ctx; + + if (pfnmap_track(pfn, size, prot)) + return ERR_PTR(-EINVAL); + + ctx =3D kmalloc(sizeof(*ctx), GFP_KERNEL); + if (unlikely(!ctx)) { + pfnmap_untrack(pfn, size); + return ERR_PTR(-ENOMEM); + } + + ctx->pfn =3D pfn; + ctx->size =3D size; + kref_init(&ctx->kref); + return ctx; +} + +void pfnmap_track_ctx_release(struct kref *ref) +{ + struct pfnmap_track_ctx *ctx =3D container_of(ref, struct pfnmap_track_ct= x, kref); + + pfnmap_untrack(ctx->pfn, ctx->size); + kfree(ctx); +} +#endif /* __HAVE_PFNMAP_TRACKING */ + /** * remap_pfn_range - remap kernel memory to userspace * @vma: user vma to map to @@ -2884,20 +2903,51 @@ int remap_pfn_range_notrack(struct vm_area_struct *= vma, unsigned long addr, * * Return: %0 on success, negative error code otherwise. */ +#ifdef __HAVE_PFNMAP_TRACKING int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, unsigned long size, pgprot_t prot) { + struct pfnmap_track_ctx *ctx =3D NULL; int err; =20 - err =3D track_pfn_remap(vma, &prot, pfn, addr, PAGE_ALIGN(size)); - if (err) + size =3D PAGE_ALIGN(size); + + /* + * If we cover the full VMA, we'll perform actual tracking, and + * remember to untrack when the last reference to our tracking + * context from a VMA goes away. We'll keep tracking the whole pfn + * range even during VMA splits and partial unmapping. + * + * If we only cover parts of the VMA, we'll only setup the cachemode + * in the pgprot for the pfn range. + */ + if (addr =3D=3D vma->vm_start && addr + size =3D=3D vma->vm_end) { + if (vma->pfnmap_track_ctx) + return -EINVAL; + ctx =3D pfnmap_track_ctx_alloc(pfn, size, &prot); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + } else if (pfnmap_setup_cachemode(pfn, size, &prot)) { return -EINVAL; + } =20 err =3D remap_pfn_range_notrack(vma, addr, pfn, size, prot); - if (err) - untrack_pfn(vma, pfn, PAGE_ALIGN(size), true); + if (ctx) { + if (err) + kref_put(&ctx->kref, pfnmap_track_ctx_release); + else + vma->pfnmap_track_ctx =3D ctx; + } return err; } + +#else +int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn, unsigned long size, pgprot_t prot) +{ + return remap_pfn_range_notrack(vma, addr, pfn, size, prot); +} +#endif EXPORT_SYMBOL(remap_pfn_range); =20 /** diff --git a/mm/mmap.c b/mm/mmap.c index 50f902c08341a..09c563c951123 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1784,11 +1784,6 @@ __latent_entropy int dup_mmap(struct mm_struct *mm, = struct mm_struct *oldmm) tmp =3D vm_area_dup(mpnt); if (!tmp) goto fail_nomem; - - /* track_pfn_copy() will later take care of copying internal state. */ - if (unlikely(tmp->vm_flags & VM_PFNMAP)) - untrack_pfn_clear(tmp); - retval =3D vma_dup_policy(mpnt, tmp); if (retval) goto fail_nomem_policy; diff --git a/mm/mremap.c b/mm/mremap.c index 7db9da609c84f..6e78e02f74bd3 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -1191,10 +1191,6 @@ static int copy_vma_and_data(struct vma_remap_struct= *vrm, if (is_vm_hugetlb_page(vma)) clear_vma_resv_huge_pages(vma); =20 - /* Tell pfnmap has moved from this vma */ - if (unlikely(vma->vm_flags & VM_PFNMAP)) - untrack_pfn_clear(vma); - *new_vma_ptr =3D new_vma; return err; } diff --git a/mm/vma_init.c b/mm/vma_init.c index 967ca85179864..8e53c7943561e 100644 --- a/mm/vma_init.c +++ b/mm/vma_init.c @@ -71,7 +71,51 @@ static void vm_area_init_from(const struct vm_area_struc= t *src, #ifdef CONFIG_NUMA dest->vm_policy =3D src->vm_policy; #endif +#ifdef __HAVE_PFNMAP_TRACKING + dest->pfnmap_track_ctx =3D NULL; +#endif +} + +#ifdef __HAVE_PFNMAP_TRACKING +static inline int vma_pfnmap_track_ctx_dup(struct vm_area_struct *orig, + struct vm_area_struct *new) +{ + struct pfnmap_track_ctx *ctx =3D orig->pfnmap_track_ctx; + + if (likely(!ctx)) + return 0; + + /* + * We don't expect to ever hit this. If ever required, we would have + * to duplicate the tracking. + */ + if (unlikely(kref_read(&ctx->kref) >=3D REFCOUNT_MAX)) + return -ENOMEM; + kref_get(&ctx->kref); + new->pfnmap_track_ctx =3D ctx; + return 0; +} + +static inline void vma_pfnmap_track_ctx_release(struct vm_area_struct *vma) +{ + struct pfnmap_track_ctx *ctx =3D vma->pfnmap_track_ctx; + + if (likely(!ctx)) + return; + + kref_put(&ctx->kref, pfnmap_track_ctx_release); + vma->pfnmap_track_ctx =3D NULL; +} +#else +static inline int vma_pfnmap_track_ctx_dup(struct vm_area_struct *orig, + struct vm_area_struct *new) +{ + return 0; } +static inline void vma_pfnmap_track_ctx_release(struct vm_area_struct *vma) +{ +} +#endif =20 struct vm_area_struct *vm_area_dup(struct vm_area_struct *orig) { @@ -83,6 +127,11 @@ struct vm_area_struct *vm_area_dup(struct vm_area_struc= t *orig) ASSERT_EXCLUSIVE_WRITER(orig->vm_flags); ASSERT_EXCLUSIVE_WRITER(orig->vm_file); vm_area_init_from(orig, new); + + if (vma_pfnmap_track_ctx_dup(orig, new)) { + kmem_cache_free(vm_area_cachep, new); + return NULL; + } vma_lock_init(new, true); INIT_LIST_HEAD(&new->anon_vma_chain); vma_numab_state_init(new); @@ -97,5 +146,6 @@ void vm_area_free(struct vm_area_struct *vma) vma_assert_detached(vma); vma_numab_state_free(vma); free_anon_vma_name(vma); + vma_pfnmap_track_ctx_release(vma); kmem_cache_free(vm_area_cachep, vma); } --=20 2.49.0 From nobody Sun Feb 8 04:12:46 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB2AB29373C for ; Mon, 12 May 2025 12:34:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053285; cv=none; b=jTweedFqnXJSKAFZwN9B/JO1ZFI9X/7SiGKMBaezP8u0EvnkEUwpkVM+u4CFGz/nGg0sIWSRdiI0vmz7OjAv5Up2UozeV3CribBy4fzd5IYMl/h4zelY2KsxZkHV+QzXHwjFrIxn1bA04EBEmQP6OpjlPrXGD/vCp1J+aX7a/uQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053285; c=relaxed/simple; bh=WQFbdZmur/Ytk9dJK/ooWmRT8pRAb8iNKuSeeh5cjDI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ueQBR+0cyxSrIkluTejatFSzR1VQ54O1fniIRuhe0XjyTTkITKmfRt+Nzs4hyvFzO862XoopkEWvkQdEkCH6CcW7z1HVao3CtP5NBleybfQ8C2GzMvr1kIqMlhIQpM4HLvMCPq2VDTZGkiR6OgvM5uP7iNC1FvVhb6UH03mo/eM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AOwSZneU; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AOwSZneU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747053282; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=13dAic06AYXZ8stgi94MXGa0Osqutl2B39hqd6w6YHE=; b=AOwSZneUTlrJYTmOEC/mgVSjY7tDedd+kzYug4USVQ3C3yaNdbONcIFxNrRr80qxkTCqlU iF0XxbaPwzvtJMHGhQWoIUZXBW4o8R/aD106IfZqQW0061ilFMwvTt1uanAbhcKqiQ16c4 XA1xG366m2WgbN/8q3/Br2Y3Bfl41d0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-355-gZYM3FnHMUqVYgb5upXFrQ-1; Mon, 12 May 2025 08:34:41 -0400 X-MC-Unique: gZYM3FnHMUqVYgb5upXFrQ-1 X-Mimecast-MFC-AGG-ID: gZYM3FnHMUqVYgb5upXFrQ_1747053281 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-442d472cf84so19759675e9.2 for ; Mon, 12 May 2025 05:34:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747053280; x=1747658080; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=13dAic06AYXZ8stgi94MXGa0Osqutl2B39hqd6w6YHE=; b=I9LoIK09gFxdx9KlyyGOdmjdSTjhhSqjrgE+FsTFW4FM/60LM7lql5Nc7B+iPnBF0N lArx4fR/mD3YF7EtBYALhXya+Xh9ba9cnAjbGitenHnfvW70IHLTpezkRIhIuAVNfErX KqJbx3omIyJRvrqHRRUXmsxVKt34ZInRIOwU/O794eIDYGuf9IkttMoNG1BtxWxaamQZ dhhsoCLhFTg3F9BzMSd0ydn/g9EmfJ2CB0HhumdWamh1B12y4TtMSKyjEw6Tq2mS4LKM uMhN26h6XYo663OCPmCOAgBw+M2pxPk7J2vrZFyA0R58siz75c+qlq8yaP9QZ7wtAhIF c1rA== X-Gm-Message-State: AOJu0YyGPFBWhWmwEdASWPbuzyOs6kNvIlNApE5KXeN1U03C1khBfxnM ek7wz24uB8tKIc66so5UHUIJBx6fAhyEuvlapaDpRiHLw7Cq7myfds0SqH17vSLCgdHeIX9HxHq UULm/G2tWZQrqySlVh4h8h5940rRs8T+JQwr479QoKGunRKI8NJXoRyn6uzjEQfDMPFJ5vF25ZR Owt/tfRE+6R37Mw2aHea4Ku4aHtL1gSS+9v0AGX3ZNSt43 X-Gm-Gg: ASbGncvVze0FFkdK5xJCOtfVFh8Yv1GTM5cS7cAhrLmflBiTfgjLHkXm8sNIRzxP6Lo oE8Nh13xnWzlk0yv2VG1FY8mrry7vX7tH5MeFMtqA04PUBCRdiu0sAQaPlFenxtWvuXY/eLgjzg QUwobp5CG4gIWNq58sjd54jomeEJqUKQldURYrSnSVmnheM7hOVsZXU2SaBXYaidbdihpc1E8MG jBINYT3LZ2ml0c8+ZrDlyXmJDJ1TgQymirGALrWexS5lg9UB1P17vnN/0AFr1S854dA/yFq/bcT Mmbc0zJByoVu/x8FRXkJUFoho3smO4z5ZQpJG9Rf27q3IbDNEFt0wfBvOCjy6r5q82wcdAx+ X-Received: by 2002:a05:600c:8707:b0:43d:8ea:8d7a with SMTP id 5b1f17b1804b1-442d6ddd6eemr75543385e9.28.1747053280537; Mon, 12 May 2025 05:34:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYcR0QvFdl5lqSrPfju6l0qj9023QUSGb7KmYchmWeB3prbPPuHFd5J5L+A7FGYZKCJT6pZQ== X-Received: by 2002:a05:600c:8707:b0:43d:8ea:8d7a with SMTP id 5b1f17b1804b1-442d6ddd6eemr75542655e9.28.1747053279973; Mon, 12 May 2025 05:34:39 -0700 (PDT) Received: from localhost (p200300d82f4a5800f1ae8e20d7f451b0.dip0.t-ipconnect.de. [2003:d8:2f4a:5800:f1ae:8e20:d7f4:51b0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a1f58ec0e4sm12199823f8f.40.2025.05.12.05.34.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 May 2025 05:34:39 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-trace-kernel@vger.kernel.org, David Hildenbrand , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , Peter Xu , Ingo Molnar Subject: [PATCH v2 05/11] x86/mm/pat: remove old pfnmap tracking interface Date: Mon, 12 May 2025 14:34:18 +0200 Message-ID: <20250512123424.637989-6-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512123424.637989-1-david@redhat.com> References: <20250512123424.637989-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We can now get rid of the old interface along with get_pat_info() and follow_phys(). Reviewed-by: Lorenzo Stoakes Acked-by: Ingo Molnar # x86 bits Signed-off-by: David Hildenbrand Reviewed-by: Liam R. Howlett --- arch/x86/mm/pat/memtype.c | 147 -------------------------------------- include/linux/pgtable.h | 66 ----------------- 2 files changed, 213 deletions(-) diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c index 1ec8af6cad6bf..c88d1cbdc1de1 100644 --- a/arch/x86/mm/pat/memtype.c +++ b/arch/x86/mm/pat/memtype.c @@ -933,119 +933,6 @@ static void free_pfn_range(u64 paddr, unsigned long s= ize) memtype_free(paddr, paddr + size); } =20 -static int follow_phys(struct vm_area_struct *vma, unsigned long *prot, - resource_size_t *phys) -{ - struct follow_pfnmap_args args =3D { .vma =3D vma, .address =3D vma->vm_s= tart }; - - if (follow_pfnmap_start(&args)) - return -EINVAL; - - /* Never return PFNs of anon folios in COW mappings. */ - if (!args.special) { - follow_pfnmap_end(&args); - return -EINVAL; - } - - *prot =3D pgprot_val(args.pgprot); - *phys =3D (resource_size_t)args.pfn << PAGE_SHIFT; - follow_pfnmap_end(&args); - return 0; -} - -static int get_pat_info(struct vm_area_struct *vma, resource_size_t *paddr, - pgprot_t *pgprot) -{ - unsigned long prot; - - VM_WARN_ON_ONCE(!(vma->vm_flags & VM_PAT)); - - /* - * We need the starting PFN and cachemode used for track_pfn_remap() - * that covered the whole VMA. For most mappings, we can obtain that - * information from the page tables. For COW mappings, we might now - * suddenly have anon folios mapped and follow_phys() will fail. - * - * Fallback to using vma->vm_pgoff, see remap_pfn_range_notrack(), to - * detect the PFN. If we need the cachemode as well, we're out of luck - * for now and have to fail fork(). - */ - if (!follow_phys(vma, &prot, paddr)) { - if (pgprot) - *pgprot =3D __pgprot(prot); - return 0; - } - if (is_cow_mapping(vma->vm_flags)) { - if (pgprot) - return -EINVAL; - *paddr =3D (resource_size_t)vma->vm_pgoff << PAGE_SHIFT; - return 0; - } - WARN_ON_ONCE(1); - return -EINVAL; -} - -int track_pfn_copy(struct vm_area_struct *dst_vma, - struct vm_area_struct *src_vma, unsigned long *pfn) -{ - const unsigned long vma_size =3D src_vma->vm_end - src_vma->vm_start; - resource_size_t paddr; - pgprot_t pgprot; - int rc; - - if (!(src_vma->vm_flags & VM_PAT)) - return 0; - - /* - * Duplicate the PAT information for the dst VMA based on the src - * VMA. - */ - if (get_pat_info(src_vma, &paddr, &pgprot)) - return -EINVAL; - rc =3D reserve_pfn_range(paddr, vma_size, &pgprot, 1); - if (rc) - return rc; - - /* Reservation for the destination VMA succeeded. */ - vm_flags_set(dst_vma, VM_PAT); - *pfn =3D PHYS_PFN(paddr); - return 0; -} - -void untrack_pfn_copy(struct vm_area_struct *dst_vma, unsigned long pfn) -{ - untrack_pfn(dst_vma, pfn, dst_vma->vm_end - dst_vma->vm_start, true); - /* - * Reservation was freed, any copied page tables will get cleaned - * up later, but without getting PAT involved again. - */ -} - -/* - * prot is passed in as a parameter for the new mapping. If the vma has - * a linear pfn mapping for the entire range, or no vma is provided, - * reserve the entire pfn + size range with single reserve_pfn_range - * call. - */ -int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, - unsigned long pfn, unsigned long addr, unsigned long size) -{ - resource_size_t paddr =3D (resource_size_t)pfn << PAGE_SHIFT; - - /* reserve the whole chunk starting from paddr */ - if (!vma || (addr =3D=3D vma->vm_start - && size =3D=3D (vma->vm_end - vma->vm_start))) { - int ret; - - ret =3D reserve_pfn_range(paddr, size, prot, 0); - if (ret =3D=3D 0 && vma) - vm_flags_set(vma, VM_PAT); - return ret; - } - - return pfnmap_setup_cachemode(pfn, size, prot); -} - int pfnmap_setup_cachemode(unsigned long pfn, unsigned long size, pgprot_t= *prot) { resource_size_t paddr =3D (resource_size_t)pfn << PAGE_SHIFT; @@ -1082,40 +969,6 @@ void pfnmap_untrack(unsigned long pfn, unsigned long = size) free_pfn_range(paddr, size); } =20 -/* - * untrack_pfn is called while unmapping a pfnmap for a region. - * untrack can be called for a specific region indicated by pfn and size or - * can be for the entire vma (in which case pfn, size are zero). - */ -void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, - unsigned long size, bool mm_wr_locked) -{ - resource_size_t paddr; - - if (vma && !(vma->vm_flags & VM_PAT)) - return; - - /* free the chunk starting from pfn or the whole chunk */ - paddr =3D (resource_size_t)pfn << PAGE_SHIFT; - if (!paddr && !size) { - if (get_pat_info(vma, &paddr, NULL)) - return; - size =3D vma->vm_end - vma->vm_start; - } - free_pfn_range(paddr, size); - if (vma) { - if (mm_wr_locked) - vm_flags_clear(vma, VM_PAT); - else - __vm_flags_mod(vma, 0, VM_PAT); - } -} - -void untrack_pfn_clear(struct vm_area_struct *vma) -{ - vm_flags_clear(vma, VM_PAT); -} - pgprot_t pgprot_writecombine(pgprot_t prot) { pgprot_set_cachemode(&prot, _PAGE_CACHE_MODE_WC); diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 90f72cd358390..0b6e1f781d86d 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1485,17 +1485,6 @@ static inline pmd_t pmd_swp_clear_soft_dirty(pmd_t p= md) * vmf_insert_pfn. */ =20 -/* - * track_pfn_remap is called when a _new_ pfn mapping is being established - * by remap_pfn_range() for physical range indicated by pfn and size. - */ -static inline int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *pr= ot, - unsigned long pfn, unsigned long addr, - unsigned long size) -{ - return 0; -} - static inline int pfnmap_setup_cachemode(unsigned long pfn, unsigned long = size, pgprot_t *prot) { @@ -1511,55 +1500,7 @@ static inline int pfnmap_track(unsigned long pfn, un= signed long size, static inline void pfnmap_untrack(unsigned long pfn, unsigned long size) { } - -/* - * track_pfn_copy is called when a VM_PFNMAP VMA is about to get the page - * tables copied during copy_page_range(). Will store the pfn to be - * passed to untrack_pfn_copy() only if there is something to be untracked. - * Callers should initialize the pfn to 0. - */ -static inline int track_pfn_copy(struct vm_area_struct *dst_vma, - struct vm_area_struct *src_vma, unsigned long *pfn) -{ - return 0; -} - -/* - * untrack_pfn_copy is called when a VM_PFNMAP VMA failed to copy during - * copy_page_range(), but after track_pfn_copy() was already called. Can - * be called even if track_pfn_copy() did not actually track anything: - * handled internally. - */ -static inline void untrack_pfn_copy(struct vm_area_struct *dst_vma, - unsigned long pfn) -{ -} - -/* - * untrack_pfn is called while unmapping a pfnmap for a region. - * untrack can be called for a specific region indicated by pfn and size or - * can be for the entire vma (in which case pfn, size are zero). - */ -static inline void untrack_pfn(struct vm_area_struct *vma, - unsigned long pfn, unsigned long size, - bool mm_wr_locked) -{ -} - -/* - * untrack_pfn_clear is called in the following cases on a VM_PFNMAP VMA: - * - * 1) During mremap() on the src VMA after the page tables were moved. - * 2) During fork() on the dst VMA, immediately after duplicating the src = VMA. - */ -static inline void untrack_pfn_clear(struct vm_area_struct *vma) -{ -} #else -extern int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, - unsigned long pfn, unsigned long addr, - unsigned long size); - /** * pfnmap_setup_cachemode - setup the cachemode in the pgprot for a pfn ra= nge * @pfn: the start of the pfn range @@ -1614,13 +1555,6 @@ int pfnmap_track(unsigned long pfn, unsigned long si= ze, pgprot_t *prot); * Untrack a pfn range previously tracked through pfnmap_track(). */ void pfnmap_untrack(unsigned long pfn, unsigned long size); -extern int track_pfn_copy(struct vm_area_struct *dst_vma, - struct vm_area_struct *src_vma, unsigned long *pfn); -extern void untrack_pfn_copy(struct vm_area_struct *dst_vma, - unsigned long pfn); -extern void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, - unsigned long size, bool mm_wr_locked); -extern void untrack_pfn_clear(struct vm_area_struct *vma); #endif =20 /** --=20 2.49.0 From nobody Sun Feb 8 04:12:46 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2B8329374B for ; Mon, 12 May 2025 12:34:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053288; cv=none; b=IWDXYOKTUg8U+TwzPDwXCmfvARFh9t3vCsXqCn0Na/xOvPGMTmwwKtWkj5EVnJc3DTiAL/GLEyf3W/zxUgk6sRQ0TIYIUeL1V00OkCpeXZBc+TpwhNdeknKpnUAbYrKUxRoZJtvyo7Rhz8fveKrD1GPoPFdJGIcNJTM/g49qmfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053288; c=relaxed/simple; bh=MUI/AxEhqRJImsU/nUpWQjiOz2C1jw4sB7/CH9k9y0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k4RXxg8ZQn3dQQkSfaGykSs7G7IFLSEY3sO64xKwjG+ral1QU8axgDfTNODs8io2W9TDI6vDxNyHCofKiOeH+VQSi43HycpKdluqFqDjKnADjGAwYswW36Rdfg7PmSJ1cMk+NAqKF2PrzL0ImBvA0LfZou3+9sTZOuWeNfrzOi4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CHGpSvaJ; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CHGpSvaJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747053284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P/UT1PJepYZyksnYsraxL/8N12b3Ge+B9agKxkMscSY=; b=CHGpSvaJTMKHpXiAhnP6n4LZ6AQ6fImDmcQ79k7mbzAhcD+tCIS/cORRaHfKqyMdpxFXLd fGuOYaf9KJCAlkB+YhXA1zr4pLYXEvCYQyxHNhi1BY8U7n4AWmszwQ1dLWJwfWNNur1w0E 72Ad1GL0Cn4LaJ9NAiw35bA9fSqzpIQ= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-lA322ZqgO3i6m8I30WK45A-1; Mon, 12 May 2025 08:34:43 -0400 X-MC-Unique: lA322ZqgO3i6m8I30WK45A-1 X-Mimecast-MFC-AGG-ID: lA322ZqgO3i6m8I30WK45A_1747053282 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-442cd12d151so28660225e9.1 for ; Mon, 12 May 2025 05:34:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747053282; x=1747658082; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P/UT1PJepYZyksnYsraxL/8N12b3Ge+B9agKxkMscSY=; b=idjsZTha5xIrPXGmyW/xLDy8m6WLRkVzXbm8or6bDao/jroYWzPSTqJBmUdIpXf409 sVp0oCV4fqkxBTWUnbOVbMjlnrRWjFZsCGjw+k8RD83F5im9MQAvqXAH7MYn9twNzVFF vTVfAOEoB9fwpZQQyYRr0/lLOZ9ZxhwmnI4tTG0hbwVbUoyC4iSiNz1feu4oGwf6ElPp EZZLl9loJRbi+6ctgIAar1HMpbJ75Lx0uMQAW4/ohgiSg9Gn2xPk8buMkeBR+/S0r20u etsGM6o8eYFFQ3oAB/aJgorabnSHonm79jV/DhTy+XxHU97JX/HdOp/6iXM33vLFD3Un PVsg== X-Gm-Message-State: AOJu0YzAwAokddTN/P0vAIuphlHxggXu16eU6KSGvTJ8F7N+W+CdhJXG 84JLQvBmCecG2EWnmnI+HUZ/Jmq7E/mwCB0DeZP4+IiaIJ4D2u4ROZ7/mQiU8c2LViSWkmKnHNj rP5rkUhNRlIly6t02flYlc1lKXXOZN7SP2BnmEsCeOLKrPUT0hsvZ9vOLFRf4XkHH2TFRCLbEs8 I7Zi0ubxD79jt8WHCClcK39KsQbQbgiNgCDmvNCIg8hqLR X-Gm-Gg: ASbGncv9bUzKzqacKJVsyCVRNrV4L2aG8Da+2yjDtFxTkBsK5Q3mdyA2mjtRKmaplb6 aOTXz7uKREiQnsfKVcoDLiigjxB943ntrJLrpObK1iZAIHI4X043Nq0YrhJQASjy+NpU9F2y0Dx kmn1CF6MCiRo9VnawlVLzTRwbQuXzkA8KXTae5ZjJekM8wwrR1GzcUxG+h3tfrlH7Jnj6QYop+I IchVs5Wa96cxqgrC5b1mS4xxezoIyaco0I9X0BfzBhf2krcvegCPm1doaxtOmzaFF7cnFf/Smpv gEy5/4drwyAnIzw05oWUj9YQj2cPLoLNnZVeA3/UnLIbbwDW7lqJ/+bj9T4YG2ccraookA/K X-Received: by 2002:a05:600c:5297:b0:439:9b2a:1b2f with SMTP id 5b1f17b1804b1-442d6d0a9dfmr115315605e9.3.1747053282449; Mon, 12 May 2025 05:34:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFywN6624bTf4LyaE2Qvs6JUb4DihepKIjEJxodQ9QeZ2Wkqkhy5X7PHmdPSSD8j6qE1uzKzw== X-Received: by 2002:a05:600c:5297:b0:439:9b2a:1b2f with SMTP id 5b1f17b1804b1-442d6d0a9dfmr115314985e9.3.1747053281990; Mon, 12 May 2025 05:34:41 -0700 (PDT) Received: from localhost (p200300d82f4a5800f1ae8e20d7f451b0.dip0.t-ipconnect.de. [2003:d8:2f4a:5800:f1ae:8e20:d7f4:51b0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-442d773f794sm82894295e9.0.2025.05.12.05.34.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 May 2025 05:34:41 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-trace-kernel@vger.kernel.org, David Hildenbrand , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , Peter Xu , Ingo Molnar Subject: [PATCH v2 06/11] mm: remove VM_PAT Date: Mon, 12 May 2025 14:34:19 +0200 Message-ID: <20250512123424.637989-7-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512123424.637989-1-david@redhat.com> References: <20250512123424.637989-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It's unused, so let's remove it. Reviewed-by: Lorenzo Stoakes Acked-by: Ingo Molnar # x86 bits Signed-off-by: David Hildenbrand Reviewed-by: Liam R. Howlett --- include/linux/mm.h | 4 +--- include/trace/events/mmflags.h | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 38e16c984b9a6..c4efa9b17655e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -357,9 +357,7 @@ extern unsigned int kobjsize(const void *objp); # define VM_SHADOW_STACK VM_NONE #endif =20 -#if defined(CONFIG_X86) -# define VM_PAT VM_ARCH_1 /* PAT reserves whole VMA at once (x86) */ -#elif defined(CONFIG_PPC64) +#if defined(CONFIG_PPC64) # define VM_SAO VM_ARCH_1 /* Strong Access Ordering (powerpc) */ #elif defined(CONFIG_PARISC) # define VM_GROWSUP VM_ARCH_1 diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h index 15aae955a10bf..aa441f593e9a6 100644 --- a/include/trace/events/mmflags.h +++ b/include/trace/events/mmflags.h @@ -172,9 +172,7 @@ IF_HAVE_PG_ARCH_3(arch_3) __def_pageflag_names \ ) : "none" =20 -#if defined(CONFIG_X86) -#define __VM_ARCH_SPECIFIC_1 {VM_PAT, "pat" } -#elif defined(CONFIG_PPC64) +#if defined(CONFIG_PPC64) #define __VM_ARCH_SPECIFIC_1 {VM_SAO, "sao" } #elif defined(CONFIG_PARISC) #define __VM_ARCH_SPECIFIC_1 {VM_GROWSUP, "growsup" } --=20 2.49.0 From nobody Sun Feb 8 04:12:46 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D61E2951BB for ; Mon, 12 May 2025 12:34:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053290; cv=none; b=YlxY/qs1LnGssJcBH2iit+T2hWf3JrYzzQ3sZQt3ffNM4VXmu9UImgU9wAD4CY3XPw8iMq/V6HEA8tyiKpcJCt4nCayO6U2CKBcTH166e45WCTPaVX0yF/2XVK3e0W5t0sKEZM16Dox7mLh+yb5DETV46RYmWMbw+mLODX5P4q8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053290; c=relaxed/simple; bh=plUyq9xd8ySzP2AAXo2oJ8d2YD2N8nsTkRb0LYdC5Ec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DAYl/kb1pjBGp+yeCusTUeyob3hTwNIeReQJFhVlj/OKDRP92woO6w6OJteOYIwi7vWY7JqpIasm8OvAWrfF0xT4VX2FpyrQwT1B/xUlUCew3HdXBdmhXGNEa97NZcwNRaky58wiwRdHwqWJwG7XRpSGGRHHMGmEomwxVuNNesw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=a9fPBcb0; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="a9fPBcb0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747053287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=damHjxLzdKBqIDkI5LPVSGeFU6dth6KBhucvp/6hc2Y=; b=a9fPBcb0IvUn9oNcxLPb1a6/ncFV0eCorxjukqhG8dd+roY+0HbwHh8dLbrzcWa8O9r2GN fYJjk7Ih5cp1s0S9rsTO+D/QnGCZiIxHhsdZVSyr1VW/4XMvKpZaj2jb6xdK3xocPDWY+l e3tVrNpLcO/KDETnyiOPH6+eDdVMuLg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-132-6ISKYOnSMjSylFQ5u9saQw-1; Mon, 12 May 2025 08:34:46 -0400 X-MC-Unique: 6ISKYOnSMjSylFQ5u9saQw-1 X-Mimecast-MFC-AGG-ID: 6ISKYOnSMjSylFQ5u9saQw_1747053285 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a2046b5e75so363975f8f.1 for ; Mon, 12 May 2025 05:34:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747053285; x=1747658085; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=damHjxLzdKBqIDkI5LPVSGeFU6dth6KBhucvp/6hc2Y=; b=N1U6jo8cukQQrqD100sUysMB20NOD8zFfOSkruNeaIsQEpbUBii7XN2eerPMyF81oH dacV74iaY5554W6r5dE7+UapAYpPJguQRxy7Qx9W4lyqJ0rYTm2y1sGywGYDLEFcHULy yzaSOf+9JeixEZ8h5TZqrfeF+v0OZ/E1n1CZllm+piwIyGnFa7n+XzQwjoKTPtWmfy/j 3lzMywTCEQ5A4MKF+z9za8qdBZZY3veRCHQmesonf/CvGbbrej6MhhFM5RYC1UTTlk6+ Im0i3g6x0NZnKGzTbiJXnbecI4p/82Y7PoZEua8l13KRTulViEp96UO+A5cSxRVafJ9q s6jQ== X-Gm-Message-State: AOJu0YwEK0RA2hK+lms7/VqLW8a9s/SpR6mxHmNx0VsIzVm3pR5Hlf7M CDh9fhtWhVDa/zMa+QnCsONH+1U3+r0Rj8zfIwUoeh5nvnyOQMDlqenF3OeVbLbsVjlDLuoUD7B 5wAHvZ8YonFzEEfYsntDiodHb/c4LEmI2SB6tn3goPTmnmIKq37zOEqnkNQSvkdybFgR1kUQkc1 /JnoxwfaYEQZVeO6GfNTKSDp8lLXfBVvvAPVPJDIT0GYaE X-Gm-Gg: ASbGncufx8AvX7mim8JkFO2jQSF0rl7wwz7CJZGG0fM5RLEekFAYIus0sl+GGA2by1b myoKr9akvw/BAE3W5FRg04OE2uMHUrE17mtFwaZAnOZpSWV1hp6B8xVV8o/dUlZ4/tGhteYqdpT keV8+hY4uCHIDT1UVT4j+763lDzCVc2iJEWwTLlPfnYGq/JKeIo7Lv/JUHRtSOYUg3IVEPcTAB8 SgrZhiib+rKQDrE3WDL3NIptkBMkSGnz7kE2Nwy0FhxDCHuh9fvXr7fgguLB7gicKkSA3LlRV3y nLjhiO9WKgMRI+YDHL+L6aBx2cZdvUmzORzk2U6T+jblPBQqmD2ZjqxfdN2OHvIqUWRxx0vB X-Received: by 2002:a05:6000:2011:b0:3a0:b455:a1fd with SMTP id ffacd0b85a97d-3a1f643d7f2mr9690561f8f.32.1747053285234; Mon, 12 May 2025 05:34:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnmU3EtVrQ/jxHU8AUaqqw41jpYBGCmzwmgCEh+gCBZD+u2TEH9U2eBlpYNMTeAuFBo11Jgg== X-Received: by 2002:a05:6000:2011:b0:3a0:b455:a1fd with SMTP id ffacd0b85a97d-3a1f643d7f2mr9690506f8f.32.1747053284744; Mon, 12 May 2025 05:34:44 -0700 (PDT) Received: from localhost (p200300d82f4a5800f1ae8e20d7f451b0.dip0.t-ipconnect.de. [2003:d8:2f4a:5800:f1ae:8e20:d7f4:51b0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-442cd32f238sm164887305e9.11.2025.05.12.05.34.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 May 2025 05:34:44 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-trace-kernel@vger.kernel.org, David Hildenbrand , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , Peter Xu , Ingo Molnar Subject: [PATCH v2 07/11] x86/mm/pat: remove strict_prot parameter from reserve_pfn_range() Date: Mon, 12 May 2025 14:34:20 +0200 Message-ID: <20250512123424.637989-8-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512123424.637989-1-david@redhat.com> References: <20250512123424.637989-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Always set to 0, so let's remove it. Reviewed-by: Lorenzo Stoakes Acked-by: Ingo Molnar # x86 bits Signed-off-by: David Hildenbrand Reviewed-by: Liam R. Howlett --- arch/x86/mm/pat/memtype.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c index c88d1cbdc1de1..ccc55c00b4c8b 100644 --- a/arch/x86/mm/pat/memtype.c +++ b/arch/x86/mm/pat/memtype.c @@ -858,8 +858,7 @@ int memtype_kernel_map_sync(u64 base, unsigned long siz= e, * Reserved non RAM regions only and after successful memtype_reserve, * this func also keeps identity mapping (if any) in sync with this new pr= ot. */ -static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_= prot, - int strict_prot) +static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_= prot) { int is_ram =3D 0; int ret; @@ -895,8 +894,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long s= ize, pgprot_t *vma_prot, return ret; =20 if (pcm !=3D want_pcm) { - if (strict_prot || - !is_new_memtype_allowed(paddr, size, want_pcm, pcm)) { + if (!is_new_memtype_allowed(paddr, size, want_pcm, pcm)) { memtype_free(paddr, paddr + size); pr_err("x86/PAT: %s:%d map pfn expected mapping type %s for [mem %#010L= x-%#010Lx], got %s\n", current->comm, current->pid, @@ -906,10 +904,6 @@ static int reserve_pfn_range(u64 paddr, unsigned long = size, pgprot_t *vma_prot, cattr_name(pcm)); return -EINVAL; } - /* - * We allow returning different type than the one requested in - * non strict case. - */ pgprot_set_cachemode(vma_prot, pcm); } =20 @@ -959,7 +953,7 @@ int pfnmap_track(unsigned long pfn, unsigned long size,= pgprot_t *prot) { const resource_size_t paddr =3D (resource_size_t)pfn << PAGE_SHIFT; =20 - return reserve_pfn_range(paddr, size, prot, 0); + return reserve_pfn_range(paddr, size, prot); } =20 void pfnmap_untrack(unsigned long pfn, unsigned long size) --=20 2.49.0 From nobody Sun Feb 8 04:12:46 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B374129375D for ; Mon, 12 May 2025 12:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053292; cv=none; b=fq3fvX9PJ0hhms5P/CLWibPBoDe3Lf///lGa779aVFJDjK/hml/PKISyALQPxocysPlezv9bFk0INsz4TgSJXJztD+MnYMvxAApbYRmPezwpam/N3js1mXglCzhk+BeJ9gCJ3fuauigD34M6X+PdhFTLuq6ojHyXNiKZRLD9Y5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053292; c=relaxed/simple; bh=3khWjqFjWFC9CiGQiESB8aVTX3LwH0n7i9MwUmwd6T4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RtkUom86xObgEYKp7wsO4jk/7LkGmRgVMqXCOopMdV8dlESJYdaMUvx6imI1EzXSJdDHg4ro1GuO2yPVbAxD/AQO/7wTWT/86AsBpWpCGrmhMmyxCYHecWtbNT6di+3CBwKEojtklLNyMKHh0AS288PJfvmUzzvKHn79gk2AJJ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=cn5as17M; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cn5as17M" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747053289; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WLXTuxdzeoCOS7HE06BqHxnwP6g0cDhZW8Z+d4gkxmw=; b=cn5as17MHOw8zgBvIYF8YjBDCnkRTLxP7LyLXLAooY8YUsRBmaD3Tqahj+lGQRPwsqacwo Z5ahnDYJuUel1FsB+sY54PAOXgPyRSj0UX15jaob+tpUar8o+OSkJ/D11tjw4xDqDArwsv woVJMz/61U3azVNd4mM9T7JNO1gWE7s= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-497-rfto4gSoOJWK8Z8CJ1komA-1; Mon, 12 May 2025 08:34:48 -0400 X-MC-Unique: rfto4gSoOJWK8Z8CJ1komA-1 X-Mimecast-MFC-AGG-ID: rfto4gSoOJWK8Z8CJ1komA_1747053287 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3a0b7120290so1943039f8f.2 for ; Mon, 12 May 2025 05:34:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747053287; x=1747658087; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WLXTuxdzeoCOS7HE06BqHxnwP6g0cDhZW8Z+d4gkxmw=; b=sSAl4bS5fHAti3SIALb/dsNUWb/Tr7T4jp8QLv/1fFBlA6kw+26JXj5eLnuu2MD7DT czt2hZvEZkSY+DBRAmry4/QRfNJMf2hX01NKJy5PVAiUqwZdlilESnAApTlhKPeC88iI 3S2dWjR2+5Oa01ffYas6bSOpguoVM6JdgxzWoA+qLfbIIec0vNZeF1e8jWBdbgYb1qaT NEo39G7X9087A/8c4yEUlVXsqymYJWgl4FyvC6YVyBskQEgq9zvJc9uJzOGKpTs6vqJa H+jjaHwoZ829M5fLxTyhmJqfTysF7Hjs9UGPgSxY2xrOVt+eUXZIIvH5gYeBGypGCv6G Qmuw== X-Gm-Message-State: AOJu0YwokRrUbJyoUq2fMW+Hcnw9P5etOvz6aqzj1RnJigV7HZNxBOWL z0HhhVfTll3mPR21cmR/WgW62+8l8JBfi6QBbO+UcEsvY8EI4MF+yC8/Ab9cXMHwUz7zKQ/pfu2 1BXHQ2khO5wGIZ9ujQGCZoegkjNz08AgKL19vsWJ623TUWozmxjnvjPyTRmprdS+XNUQr4YwhEk TitDL8ECY5g47XJY97//7YznGdaYRHCVdCzVuLYzubSwF2 X-Gm-Gg: ASbGncsxCRfQJ8fWg91W1AI2VjP1ZeihgDkPC9+3t8rjIG/NNDDyq/96VDzfYrS+zhg jNkr3oyPJfiGeIxLAmcJlqdx3PxW1c3WBFh4d3CZ9oQMl61n3Cm5Agj/z+ndJa49ih+0PKxbqJn /R1/UKGRGXth65NGMgA9shfHjpRhb4vuW17ORtBq9qI6i6Cjf7Pinhs8MxYcQRBxkSuB4ssOHO2 gr1ggQdG8E5kwJ4Y9qCD+rcOJOvlYQmB/BJ+l2XIhPRbgJAheqcvLADUg6W8hLpP5befL3DDOf4 PxMBnIeic3Fo4CKAmln4y/5fx2ZOdd+AftmUw/pIvvZ6tg2oerPhfjhcP05f5gNcdU6HVhMI X-Received: by 2002:a5d:5f56:0:b0:39e:dce8:1c07 with SMTP id ffacd0b85a97d-3a1f64a43a5mr11025606f8f.46.1747053287290; Mon, 12 May 2025 05:34:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXC2JTlHqMNEkDQGwHpsMemWHOSr9CrtHgYnjEcClwN7Gy0FNgR8cW6E5jpqWqORj+so6DMQ== X-Received: by 2002:a5d:5f56:0:b0:39e:dce8:1c07 with SMTP id ffacd0b85a97d-3a1f64a43a5mr11025549f8f.46.1747053286815; Mon, 12 May 2025 05:34:46 -0700 (PDT) Received: from localhost (p200300d82f4a5800f1ae8e20d7f451b0.dip0.t-ipconnect.de. [2003:d8:2f4a:5800:f1ae:8e20:d7f4:51b0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a1f58ebd43sm12647639f8f.37.2025.05.12.05.34.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 May 2025 05:34:46 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-trace-kernel@vger.kernel.org, David Hildenbrand , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , Peter Xu , Ingo Molnar Subject: [PATCH v2 08/11] x86/mm/pat: remove MEMTYPE_*_MATCH Date: Mon, 12 May 2025 14:34:21 +0200 Message-ID: <20250512123424.637989-9-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512123424.637989-1-david@redhat.com> References: <20250512123424.637989-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The "memramp() shrinking" scenario no longer applies, so let's remove that now-unnecessary handling. Reviewed-by: Lorenzo Stoakes Acked-by: Ingo Molnar # x86 bits Signed-off-by: David Hildenbrand Reviewed-by: Liam R. Howlett --- arch/x86/mm/pat/memtype_interval.c | 44 ++++-------------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/arch/x86/mm/pat/memtype_interval.c b/arch/x86/mm/pat/memtype_i= nterval.c index 645613d59942a..9d03f0dbc4715 100644 --- a/arch/x86/mm/pat/memtype_interval.c +++ b/arch/x86/mm/pat/memtype_interval.c @@ -49,26 +49,15 @@ INTERVAL_TREE_DEFINE(struct memtype, rb, u64, subtree_m= ax_end, =20 static struct rb_root_cached memtype_rbroot =3D RB_ROOT_CACHED; =20 -enum { - MEMTYPE_EXACT_MATCH =3D 0, - MEMTYPE_END_MATCH =3D 1 -}; - -static struct memtype *memtype_match(u64 start, u64 end, int match_type) +static struct memtype *memtype_match(u64 start, u64 end) { struct memtype *entry_match; =20 entry_match =3D interval_iter_first(&memtype_rbroot, start, end-1); =20 while (entry_match !=3D NULL && entry_match->start < end) { - if ((match_type =3D=3D MEMTYPE_EXACT_MATCH) && - (entry_match->start =3D=3D start) && (entry_match->end =3D=3D end)) - return entry_match; - - if ((match_type =3D=3D MEMTYPE_END_MATCH) && - (entry_match->start < start) && (entry_match->end =3D=3D end)) + if (entry_match->start =3D=3D start && entry_match->end =3D=3D end) return entry_match; - entry_match =3D interval_iter_next(entry_match, start, end-1); } =20 @@ -132,32 +121,11 @@ struct memtype *memtype_erase(u64 start, u64 end) { struct memtype *entry_old; =20 - /* - * Since the memtype_rbroot tree allows overlapping ranges, - * memtype_erase() checks with EXACT_MATCH first, i.e. free - * a whole node for the munmap case. If no such entry is found, - * it then checks with END_MATCH, i.e. shrink the size of a node - * from the end for the mremap case. - */ - entry_old =3D memtype_match(start, end, MEMTYPE_EXACT_MATCH); - if (!entry_old) { - entry_old =3D memtype_match(start, end, MEMTYPE_END_MATCH); - if (!entry_old) - return ERR_PTR(-EINVAL); - } - - if (entry_old->start =3D=3D start) { - /* munmap: erase this node */ - interval_remove(entry_old, &memtype_rbroot); - } else { - /* mremap: update the end value of this node */ - interval_remove(entry_old, &memtype_rbroot); - entry_old->end =3D start; - interval_insert(entry_old, &memtype_rbroot); - - return NULL; - } + entry_old =3D memtype_match(start, end); + if (!entry_old) + return ERR_PTR(-EINVAL); =20 + interval_remove(entry_old, &memtype_rbroot); return entry_old; } =20 --=20 2.49.0 From nobody Sun Feb 8 04:12:46 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83949295516 for ; Mon, 12 May 2025 12:34:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053294; cv=none; b=sqDvVZsa2Ps6jFJQ0x8KpfnbQyhxdhPtEzwI8IB9Z9F0E1rAf+rvm/ZLSAeX6jnylxMpdDnDnmR7AnvyvOCdSk6zTaRz1YKiL9ZvB4FsugaYlAvYcLAuVELm4dWst8WnV2gZJTJsRcEWYvGA8qK98LGqvVbmdLL9tYSyVCf5YII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053294; c=relaxed/simple; bh=SqVDOXGgAvnPE5z9oU92cnmrU7MjwVFUodqWnzatDc4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=haDW2eAVcgWxFWzi3I/j0F90Jo5Nhrmig8p0bH8j3JPWDBV5OyodG4eX1rVAIA5nFb96eNplWEkig6syhvfTQm5j9wpeEmjzUSDNkA4Y/tOb/yq0tKfV0jXDc8OVlGcGJUizXBPpIxSZpR2FAEd27kSpnak8gmjvWsIvw9VUwpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iEgmaNbG; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iEgmaNbG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747053291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2DrqxmiOL3McpG/dCHwH1I+FCiwsh4PlvLiMszfDdMo=; b=iEgmaNbGFWJv+otvgftTHyfOD7E+KawQVRHZS3sfJoMDdpA2KznMudhsPWuQepe/VuYXJh HcmVRJ9Amm2NwzlWeVvPqF5nyfAqUtTML7gJYJ7NukzR0aioEHkbfjE2fj83YxD6wu1Fug U/DQBwCSbDWvs1Eu7k+haAwPekhyhnE= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-383-jXMK4JryOBaA13AfFJttDQ-1; Mon, 12 May 2025 08:34:50 -0400 X-MC-Unique: jXMK4JryOBaA13AfFJttDQ-1 X-Mimecast-MFC-AGG-ID: jXMK4JryOBaA13AfFJttDQ_1747053289 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a1f9ddf04bso1546902f8f.3 for ; Mon, 12 May 2025 05:34:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747053289; x=1747658089; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2DrqxmiOL3McpG/dCHwH1I+FCiwsh4PlvLiMszfDdMo=; b=es/cJ8RQDjEwnS4f4WKLIR2cumFZqi+1dbKoR4e8lT+W0XyDbSFi3quGtX/hyhR9Ef USK2UCWGYHSZDoKDv1TBciXsPjPgLS0qzJctjj4DB00r45r09sQr5DutRJUM4NRaQPwI xbN5SUso7Jpmnkh/rG9MZLzJKuiIqdJDFC7aZ45Kp+ol+QhbaltnIkw9y27I0sHq+6qn GG4uYubXK0GEiJIl0DM+Vr7pyIS+2HDAU1cTy2EGVxYIhfGKQFyB3a6wIufN1m4Pi+uE nHzzDg84IgppAwcgnDvc1jOOcDoJ8rpT1O4O+e76sRGf1XW1KpA4AtYiw0ot5gkm8m/Q czfg== X-Gm-Message-State: AOJu0Yxt6jmJaDfnkwQnBetI/FLJvnimipD7qwTiDzmyGAKlCV1L915e YcW1mn705IKiEaf/FrrSWzOBiqYHFQOJmFpYVRdnJhz6OW+fm3AWylO3qZkiqcCx3ocpSTE0XI+ YIEyW/u/G0vbzdHcRUxodgUFHve1iPAcnBwWpQNBO0tMcleEhal9TBQwUqSv+4jV4R82K5cbMxC qzgg/18fwMj5aE5vebpXudl7uOpg9G7+xlidv1v3hgflVu X-Gm-Gg: ASbGncuGFXxxVIE9biyaa+0F/NP0ELxKLNNYImfijMTi2o9/+K0vlBM5FBhnUPqh/ub fEhqvYXNYIWpD/pFFWYcIXO9H9Qq7V3PhIg0o5Ut85rvMIvSoDeNgbcK0zQzP3dR1e11cuL9JZ1 ubxNwaiCYXavRl0Ix8dZ3BVvn+7Ke2PKf0QMAm2d7RjXC/IaRGZPb6eKpnNlXlm6nQyXzn72yRE 91eH810eOvqJNnrMntSsjOMk2pj6nuObYg7XyWc28kLt6+K4CXuYrezHHxQ7Jem9biFfMu/3K8l Gta0sNytfd0/pQcIMK1U7geDXgcO6KLTvbrckFS4Yvczq5dThiU0r/J14oyyyAEQKr8bvdn4 X-Received: by 2002:a05:6000:186e:b0:3a0:830d:ec58 with SMTP id ffacd0b85a97d-3a1f6446e78mr9882932f8f.28.1747053289347; Mon, 12 May 2025 05:34:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0s3h7inHrYSooQ8NhTVln7D4g+9j4TOqzMH9jwIQneuWGNhcfmrI3NwJv0snFOVP2u3wuBw== X-Received: by 2002:a05:6000:186e:b0:3a0:830d:ec58 with SMTP id ffacd0b85a97d-3a1f6446e78mr9882884f8f.28.1747053288844; Mon, 12 May 2025 05:34:48 -0700 (PDT) Received: from localhost (p200300d82f4a5800f1ae8e20d7f451b0.dip0.t-ipconnect.de. [2003:d8:2f4a:5800:f1ae:8e20:d7f4:51b0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a1f5a4c583sm12120673f8f.84.2025.05.12.05.34.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 May 2025 05:34:48 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-trace-kernel@vger.kernel.org, David Hildenbrand , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , Peter Xu Subject: [PATCH v2 09/11] x86/mm/pat: inline memtype_match() into memtype_erase() Date: Mon, 12 May 2025 14:34:22 +0200 Message-ID: <20250512123424.637989-10-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512123424.637989-1-david@redhat.com> References: <20250512123424.637989-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's just have it in a single function. The resulting function is certainly small enough and readable. Signed-off-by: David Hildenbrand Reviewed-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- arch/x86/mm/pat/memtype_interval.c | 33 +++++++++--------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/arch/x86/mm/pat/memtype_interval.c b/arch/x86/mm/pat/memtype_i= nterval.c index 9d03f0dbc4715..e5844ed1311ed 100644 --- a/arch/x86/mm/pat/memtype_interval.c +++ b/arch/x86/mm/pat/memtype_interval.c @@ -49,21 +49,6 @@ INTERVAL_TREE_DEFINE(struct memtype, rb, u64, subtree_ma= x_end, =20 static struct rb_root_cached memtype_rbroot =3D RB_ROOT_CACHED; =20 -static struct memtype *memtype_match(u64 start, u64 end) -{ - struct memtype *entry_match; - - entry_match =3D interval_iter_first(&memtype_rbroot, start, end-1); - - while (entry_match !=3D NULL && entry_match->start < end) { - if (entry_match->start =3D=3D start && entry_match->end =3D=3D end) - return entry_match; - entry_match =3D interval_iter_next(entry_match, start, end-1); - } - - return NULL; /* Returns NULL if there is no match */ -} - static int memtype_check_conflict(u64 start, u64 end, enum page_cache_mode reqtype, enum page_cache_mode *newtype) @@ -119,14 +104,16 @@ int memtype_check_insert(struct memtype *entry_new, e= num page_cache_mode *ret_ty =20 struct memtype *memtype_erase(u64 start, u64 end) { - struct memtype *entry_old; - - entry_old =3D memtype_match(start, end); - if (!entry_old) - return ERR_PTR(-EINVAL); - - interval_remove(entry_old, &memtype_rbroot); - return entry_old; + struct memtype *entry =3D interval_iter_first(&memtype_rbroot, start, end= - 1); + + while (entry && entry->start < end) { + if (entry->start =3D=3D start && entry->end =3D=3D end) { + interval_remove(entry, &memtype_rbroot); + return entry; + } + entry =3D interval_iter_next(entry, start, end - 1); + } + return ERR_PTR(-EINVAL); } =20 struct memtype *memtype_lookup(u64 addr) --=20 2.49.0 From nobody Sun Feb 8 04:12:46 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D58CC29553F for ; Mon, 12 May 2025 12:34:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053296; cv=none; b=vAs4cbxRfU6Muto1iJGf4vcdvcL367gwou6fRkNQPJL70HEv7ZTaM0/YNw9woHDaCpJvXP5vnMfkiPzPAiAtMLZzONYEGYY4xveJr6PSShV/Sc0bOr/D3mx+4Er86nR3R8TPoWx9syt5gicd47dpsE6NFFthbQZdaNJku8ydpDg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053296; c=relaxed/simple; bh=pVi4R8RYxTF7t8uftAo4cDXigtBNE8xhnByzL6xMI50=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VBxHEueuP+Z95KzlITh0681e/fKYKgpn9geMiQlxeoLyavbpf7OxTmtDh/7hkbzNn6tRa1TCcDXDzlFaa++JzhNXgu/7awJa3ou+7KqlgGQCDO9JAmaFVtLR7RHA4Tl6Uxhexmx4zZ6oQ/ic/O25bK9/xN6UfedWwdKiGZKoVK0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HIAIGOwF; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HIAIGOwF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747053293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B7NNc3thH4gIlgL655OdyQ8soQ2dq/lJKbobAXK9pSA=; b=HIAIGOwFvhbMghFDXhi34b7OPjVHwcYPaopgZyqU8XU8LdKNPag0rBjlA01K8qiXD4Pns1 M1399LkYIgRVm0mVUiX4da9aDrH95HRMZWdAK7GsluWl+udhkXyDQyI1DBNhv0ziMSDQOH 42JZ/hNR/SxEzcHLh4zIV7BFWkYQr8g= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-440-RcXie036M5C55hm8t9UgGQ-1; Mon, 12 May 2025 08:34:52 -0400 X-MC-Unique: RcXie036M5C55hm8t9UgGQ-1 X-Mimecast-MFC-AGG-ID: RcXie036M5C55hm8t9UgGQ_1747053291 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-442d472cf84so19760815e9.2 for ; Mon, 12 May 2025 05:34:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747053291; x=1747658091; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B7NNc3thH4gIlgL655OdyQ8soQ2dq/lJKbobAXK9pSA=; b=YOyd/m1Nt7nNNeAY5hGjvSLb07GDde3wWhSp3T3GlOPTSENnAAuuJ0i9KjXXs6wdWO s4DfY84tkOQFLTruEq0YqLBIC7lWJSx6z99O6+xSe8w3mvXRlnEAGsiNYqVlMI3Z5XiC 6VkWbpmBskKR4K3tB+U9VWkQ8QMfRlbi2fF7kfkmPE2b+GAXuUaEDk2Pno/T30cIAA1s yGN/VTmNIo2o9nkYlr/yto9+SrLQbAaWfUS3MMkS6e8PH2bJ+vmFfUCkPfayMoffYppG PsiPHHgI1Ydg9EJqSvtCKpIfpj6am0EjBBOct9qatZ/JF+3FaWz/UJQA1kZ1dIThUjfJ P+6A== X-Gm-Message-State: AOJu0Yy286YncmUlyJsvzr4kCcgobuaJQJpXFCRuq7rF8aIO8G0izj8g IT+8WS1UBQDnZeHgO/rTJT3ycqHeVtxz9JxC6pn1L8aYZ9wvqz7BamqglOUogrGs6eo2ODd2qJ0 xSSdKCbroFnQUsYu/CsHsH4QlLZ0pq/jlBRKV7NeH3sBg4czcSPfNjWOuSl5quWL12XDRX9cvHS tbF+h7DO+33ltQ+50nb67nwG0pEUPwmY4k6rzTpT0ONN46 X-Gm-Gg: ASbGncvvKBg9iHa0KBi0u4AkR6MNNG9YXVBtIJ3WoEsTEe4s+zh4q5o3t/Mgqofsq5q JWmnFOdqk8XduPf8Rye+LsZIwDIiI3HJdwJGnIPXoEFgSENssBRWJ57ojJd5vJ/K58invUqw0wL SH1pp5UFzzs4eKfkep1UbT4KccbisCg9P+UYHe2jCr7qqKDtsiE2YeDdS8UzwvH7504JHcel2OQ QtuP3oyF5Lbe0zYCA4/4y7ga/0sWe3O8v55ctSzhK82uq7Mj2q/Yd4JxP4VDoVdXBWshggx6Q28 DeYNwEgpe5ihKYkZHKqomRIBHORC1ultdxyKSm8rppiPRn6wb4vIk8aEuRKdMpf/HBqZhR9C X-Received: by 2002:a05:600c:6488:b0:43c:fffc:786c with SMTP id 5b1f17b1804b1-442d6d6ace2mr126162235e9.19.1747053291275; Mon, 12 May 2025 05:34:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5jxWWVElGWxNHl3crVYv65IUanKXS9MQimx+SU1bSVoqMYrPVegNxma7hfxGl7cXYCgZC+g== X-Received: by 2002:a05:600c:6488:b0:43c:fffc:786c with SMTP id 5b1f17b1804b1-442d6d6ace2mr126161635e9.19.1747053290770; Mon, 12 May 2025 05:34:50 -0700 (PDT) Received: from localhost (p200300d82f4a5800f1ae8e20d7f451b0.dip0.t-ipconnect.de. [2003:d8:2f4a:5800:f1ae:8e20:d7f4:51b0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-442cd3aeb79sm167091005e9.27.2025.05.12.05.34.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 May 2025 05:34:50 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-trace-kernel@vger.kernel.org, David Hildenbrand , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , Peter Xu , Ingo Molnar Subject: [PATCH v2 10/11] drm/i915: track_pfn() -> "pfnmap tracking" Date: Mon, 12 May 2025 14:34:23 +0200 Message-ID: <20250512123424.637989-11-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512123424.637989-1-david@redhat.com> References: <20250512123424.637989-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" track_pfn() does not exist, let's simply refer to it as "pfnmap tracking". Reviewed-by: Lorenzo Stoakes Acked-by: Ingo Molnar # x86 bits Signed-off-by: David Hildenbrand Reviewed-by: Liam R. Howlett --- drivers/gpu/drm/i915/i915_mm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_mm.c b/drivers/gpu/drm/i915/i915_mm.c index 76e2801619f09..c33bd3d830699 100644 --- a/drivers/gpu/drm/i915/i915_mm.c +++ b/drivers/gpu/drm/i915/i915_mm.c @@ -100,7 +100,7 @@ int remap_io_mapping(struct vm_area_struct *vma, =20 GEM_BUG_ON((vma->vm_flags & EXPECTED_FLAGS) !=3D EXPECTED_FLAGS); =20 - /* We rely on prevalidation of the io-mapping to skip track_pfn(). */ + /* We rely on prevalidation of the io-mapping to skip pfnmap tracking. */ r.mm =3D vma->vm_mm; r.pfn =3D pfn; r.prot =3D __pgprot((pgprot_val(iomap->prot) & _PAGE_CACHE_MASK) | @@ -140,7 +140,7 @@ int remap_io_sg(struct vm_area_struct *vma, }; int err; =20 - /* We rely on prevalidation of the io-mapping to skip track_pfn(). */ + /* We rely on prevalidation of the io-mapping to skip pfnmap tracking. */ GEM_BUG_ON((vma->vm_flags & EXPECTED_FLAGS) !=3D EXPECTED_FLAGS); =20 while (offset >=3D r.sgt.max >> PAGE_SHIFT) { --=20 2.49.0 From nobody Sun Feb 8 04:12:46 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A2732957B4 for ; Mon, 12 May 2025 12:34:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053298; cv=none; b=ElQti4626uv+gEcqKI8ZSBTNZmDsarBcMlOFFKcZjxGWsM5AglrkyRTgUOlUvbb17a9Ec+9GTBBrw5FJ4bMUB779KxiftjhdAB1s97j0NmM5pXbP0QrK9oSVsZDosFWDXi46tEP4QaHXnOX8I5hrYaFJopeB6+vfeFxufztr3Xs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747053298; c=relaxed/simple; bh=QxylKRP8NbNllb6QGFTI6Ghh7iVl6iJ+RfT2+Ev9jeg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qWKezeOgzuUOfQayvqzXhMJfi7hl6nwObUDuTrWRlrYg0aDn77NwBCPvQmwTlyJ7VajfMs6HheDbMruqtOcy2gBBiPQ9W0p/nBNv/Ve/B56+SVqpM/Sl80ojrnzuSHIsNBEb91Xvr1M0l/gqKdc326JHXZChyA9rP8MsHKA6pYk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=a63nv1Fu; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="a63nv1Fu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747053295; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bC3rmCqfA5icmQmv1eGXLPySmScZgaTKRTiPQFcrNeg=; b=a63nv1FuCkXs01OmgcbN629Q0IYbB4JMcxtBVxFFbH2/S9MZpYuzq376uA0b7g8X1mgWCE /0BLBuG/H0wFkPniTEujmMA+NyYPm4l5vpbANEdKIHHsCkUlOQK28jAeanIn8zHXkDi/C8 5uPofxAVsFkD9B4Rm3wKdlOdaj1QodE= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-235-79D5tFSuML2YIB2ITO2Nyg-1; Mon, 12 May 2025 08:34:54 -0400 X-MC-Unique: 79D5tFSuML2YIB2ITO2Nyg-1 X-Mimecast-MFC-AGG-ID: 79D5tFSuML2YIB2ITO2Nyg_1747053293 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43ceeaf1524so17071195e9.1 for ; Mon, 12 May 2025 05:34:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747053293; x=1747658093; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bC3rmCqfA5icmQmv1eGXLPySmScZgaTKRTiPQFcrNeg=; b=ZFWJtLE2HsARjbN/uaaEsoLPYFrkrLuNRcOpA5FrreSFX7htI/swioI4nVbX9oaHKV KUItfqa3130kvjVaC49a+VJ/7lbPt3YpzW0cMTYNn8tAhqd6OY9Pj3sQxDb41CF4MOr0 yQ6Xvy8oXuzitow0Ax+GSbnFHlYGiB27+bkQmolTX88v49WDWMepsU7sZhk6FMqkoYAw oas0upNc0BJ1iPrFaWiqKNx79h6bvPiS0jqE7ZSRSwAU15SouK0I24pDfwG8m54p3Mv7 yTHMUNCBqFTur/dwMUn8/wd27Sl26DSpqKofggAm7mKE/X96oJdE6Zy/ez5XrqYwrgq6 RkeQ== X-Gm-Message-State: AOJu0YyQIh+uzGkFSkXEsjHqCv7yTF9g4QKHwTxQqbAzH4fTyypVJhL3 6a5hkZAgvvcXniXud4iNJfLBJCC88QCKtgl9hfPNednC32bgQ0OR94ye2OWzE5C9dCAXgiFLWBv Gc6UDKbHdJ/M8FEk3qKb4IxFqJcWr3G75noZ5BbEPhy5e3y/1OPZfMXNxCjmp6LW6hm1vxGAJPI ysnmtbQiJegHz7scOhb2EfVrIG+kg+NypBgJcDlYoGAVnZ X-Gm-Gg: ASbGnctgAjM3s6zxEbgUTNZhbQDLTgQVrxPRYCTWlj65nnZXul8lgpmaBP4nZdlvlEr qJyYWRnRzNKQ44UxKuhe4PbaYSQm+0Dy2B3r97fr9IdlGSOIo+YprTDkNAsFx2nNQPy/7qwsxob a00rziFlPtrzGoBUaLDPE/uiWptEdlSGOVu300I/z9ajXzOEzUuFMiQtzPyiZhjOeSLyYKnHLlk 013uYC23sEk4MnHdxkLm/aKDE6f4w6x7XkLn2pH5nduowiPSnvl2J7EXpX5DlOjfc6uGtsJPYnh OmkoUOrIEm4KCbyjE2lTFvem3G34gyGvgh7u9IH5s/k7vxtf5olm57yAvxU09ckHdP8RGDgX X-Received: by 2002:a05:600c:c0c3:10b0:439:8878:5029 with SMTP id 5b1f17b1804b1-442d6d71e58mr72192025e9.2.1747053293137; Mon, 12 May 2025 05:34:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGmemaQ8osM6LIu2Hwsj+bFw5CfMQg914aObUDJRDyOqNqUwk6qAxyXq65jxeriv3mY00DEQ== X-Received: by 2002:a05:600c:c0c3:10b0:439:8878:5029 with SMTP id 5b1f17b1804b1-442d6d71e58mr72191505e9.2.1747053292674; Mon, 12 May 2025 05:34:52 -0700 (PDT) Received: from localhost (p200300d82f4a5800f1ae8e20d7f451b0.dip0.t-ipconnect.de. [2003:d8:2f4a:5800:f1ae:8e20:d7f4:51b0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-442d67d74b5sm125447555e9.2.2025.05.12.05.34.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 May 2025 05:34:52 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-trace-kernel@vger.kernel.org, David Hildenbrand , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , Peter Xu , Ingo Molnar Subject: [PATCH v2 11/11] mm/io-mapping: track_pfn() -> "pfnmap tracking" Date: Mon, 12 May 2025 14:34:24 +0200 Message-ID: <20250512123424.637989-12-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512123424.637989-1-david@redhat.com> References: <20250512123424.637989-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" track_pfn() does not exist, let's simply refer to it as "pfnmap tracking". Reviewed-by: Lorenzo Stoakes Acked-by: Ingo Molnar # x86 bits Signed-off-by: David Hildenbrand Reviewed-by: Liam R. Howlett --- mm/io-mapping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/io-mapping.c b/mm/io-mapping.c index f44a6a1347123..d3586e95c12c5 100644 --- a/mm/io-mapping.c +++ b/mm/io-mapping.c @@ -24,7 +24,7 @@ int io_mapping_map_user(struct io_mapping *iomap, struct = vm_area_struct *vma, pgprot_t remap_prot =3D __pgprot((pgprot_val(iomap->prot) & _PAGE_CACHE_M= ASK) | (pgprot_val(vma->vm_page_prot) & ~_PAGE_CACHE_MASK)); =20 - /* We rely on prevalidation of the io-mapping to skip track_pfn(). */ + /* We rely on prevalidation of the io-mapping to skip pfnmap tracking. */ return remap_pfn_range_notrack(vma, addr, pfn, size, remap_prot); } EXPORT_SYMBOL_GPL(io_mapping_map_user); --=20 2.49.0