* Re: [PATCH v3 2/6] mm: mincore: remove special handling for VM_PFNMAP
[not found] ` <20260717091347.1144789-3-wangkefeng.wang@huawei.com>
@ 2026-07-20 9:25 ` David Hildenbrand (Arm)
2026-07-20 9:26 ` David Hildenbrand (Arm)
2026-07-20 12:41 ` [PATCH v3-fixup 2/6] mm: mincore: fixup for " Kefeng Wang
2 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-07-20 9:25 UTC (permalink / raw)
To: Kefeng Wang, Andrew Morton
Cc: linux-mm, Liam R . Howlett, Lorenzo Stoakes, Vlastimil Babka,
Jann Horn, Pedro Falcato, Zi Yan
On 7/17/26 10:13, Kefeng Wang wrote:
> As David pointed out, "it’s hard to believe that someone depends
> on pages in VM_PFNMAP to *not* be present", so remove the historical
> behavior that always reports VM_PFNMAP pages as non-resident.
>
> Adding mincore_pud_range() allows the page table walker to traverse
> the full page table hierarchy without splitting a huge PUD, enabling
> much more precise identification of resident pages in PFNMAP VMAs.
>
> Link: https://lore.kernel.org/linux-mm/0e619d71-1c3d-4534-8376-2982c7348c31@kernel.org/
> Suggested-by: David Hildenbrand (Arm) <david@kernel.org>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> mm/mincore.c | 24 ++++++++++++++++--------
> 1 file changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/mm/mincore.c b/mm/mincore.c
> index 53b982803771..3fccaa5c96f8 100644
> --- a/mm/mincore.c
> +++ b/mm/mincore.c
> @@ -160,6 +160,21 @@ static int mincore_unmapped_range(unsigned long addr, unsigned long end,
> return 0;
> }
>
> +static int mincore_pud_range(pud_t *pudp, unsigned long addr, unsigned long end,
s/mincore_pud_range/mincore_pud_entry/
> + struct mm_walk *walk)
> +{
> + if (pud_is_huge(pudp_get(pudp))) {
> + int nr = (end - addr) >> PAGE_SHIFT;
Could be const.
> + unsigned char *vec = walk->private;
Might be able to just cast that as part of the memset.
> +
> + memset(vec, 1, nr);
> + walk->action = ACTION_CONTINUE;
> + walk->private += nr;
> + }
> +
> + return 0;
> +}
With the rename
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3 2/6] mm: mincore: remove special handling for VM_PFNMAP
[not found] ` <20260717091347.1144789-3-wangkefeng.wang@huawei.com>
2026-07-20 9:25 ` [PATCH v3 2/6] mm: mincore: remove special handling for VM_PFNMAP David Hildenbrand (Arm)
@ 2026-07-20 9:26 ` David Hildenbrand (Arm)
2026-07-20 12:41 ` [PATCH v3-fixup 2/6] mm: mincore: fixup for " Kefeng Wang
2 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-07-20 9:26 UTC (permalink / raw)
To: Kefeng Wang, Andrew Morton
Cc: linux-mm, Liam R . Howlett, Lorenzo Stoakes, Vlastimil Babka,
Jann Horn, Pedro Falcato, Zi Yan
On 7/17/26 10:13, Kefeng Wang wrote:
> As David pointed out, "it’s hard to believe that someone depends
> on pages in VM_PFNMAP to *not* be present", so remove the historical
> behavior that always reports VM_PFNMAP pages as non-resident.
>
> Adding mincore_pud_range() allows the page table walker to traverse
> the full page table hierarchy without splitting a huge PUD, enabling
> much more precise identification of resident pages in PFNMAP VMAs.
>
> Link: https://lore.kernel.org/linux-mm/0e619d71-1c3d-4534-8376-2982c7348c31@kernel.org/
> Suggested-by: David Hildenbrand (Arm) <david@kernel.org>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> mm/mincore.c | 24 ++++++++++++++++--------
> 1 file changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/mm/mincore.c b/mm/mincore.c
> index 53b982803771..3fccaa5c96f8 100644
> --- a/mm/mincore.c
> +++ b/mm/mincore.c
> @@ -160,6 +160,21 @@ static int mincore_unmapped_range(unsigned long addr, unsigned long end,
> return 0;
> }
>
> +static int mincore_pud_range(pud_t *pudp, unsigned long addr, unsigned long end,
> + struct mm_walk *walk)
> +{
> + if (pud_is_huge(pudp_get(pudp))) {
> + int nr = (end - addr) >> PAGE_SHIFT;
Ah, and best to use an unsigned long here for consistency.
--
Cheers,
David
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v3-fixup 2/6] mm: mincore: fixup for remove special handling for VM_PFNMAP
[not found] ` <20260717091347.1144789-3-wangkefeng.wang@huawei.com>
2026-07-20 9:25 ` [PATCH v3 2/6] mm: mincore: remove special handling for VM_PFNMAP David Hildenbrand (Arm)
2026-07-20 9:26 ` David Hildenbrand (Arm)
@ 2026-07-20 12:41 ` Kefeng Wang
2 siblings, 0 replies; 6+ messages in thread
From: Kefeng Wang @ 2026-07-20 12:41 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-mm, David Hildenbrand, Liam R . Howlett, Lorenzo Stoakes,
Vlastimil Babka, Jann Horn, Pedro Falcato, Zi Yan, Kefeng Wang
Address David's comments
- rename mincore_pud_range to mincore_pud_entry
- change int nr to const unsigned long
- remove a local vec variable
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
mm/mincore.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/mm/mincore.c b/mm/mincore.c
index d7841a38b54a..9ea81638d09f 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -146,16 +146,15 @@ static int mincore_unmapped_range(unsigned long addr, unsigned long end,
return 0;
}
-static int mincore_pud_range(pud_t *pudp, unsigned long addr, unsigned long end,
+static int mincore_pud_entry(pud_t *pudp, unsigned long addr, unsigned long end,
struct mm_walk *walk)
{
if (pud_is_huge(pudp_get(pudp))) {
- int nr = (end - addr) >> PAGE_SHIFT;
- unsigned char *vec = walk->private;
+ const unsigned long nr = (end - addr) >> PAGE_SHIFT;
- memset(vec, 1, nr);
- walk->action = ACTION_CONTINUE;
+ memset(walk->private, 1, nr);
walk->private += nr;
+ walk->action = ACTION_CONTINUE;
}
return 0;
@@ -233,7 +232,7 @@ static inline bool can_do_mincore(struct vm_area_struct *vma)
}
static const struct mm_walk_ops mincore_walk_ops = {
- .pud_entry = mincore_pud_range,
+ .pud_entry = mincore_pud_entry,
.pmd_entry = mincore_pte_range,
.pte_hole = mincore_unmapped_range,
.hugetlb_entry = mincore_hugetlb,
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread