Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] mm: mincore: misc cleanups
@ 2026-07-10 12:00 Kefeng Wang
  2026-07-10 12:00 ` [PATCH v2 1/5] mm: mincore: remove special handling for VM_PFNMAP Kefeng Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Kefeng Wang @ 2026-07-10 12:00 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

This series cleans up and simplifies the mincore. Most importantly,
it removes the historical special handling for VM_PFNMAP mappings,
reporting them as resident memory instead of always being non-resident
memory.

v2:
- Separate per-VMA lock changes as suggested by Pedro, it should be
  based on the new API [1], will resend once new API out. 
- Check VM_PFNMAP explicitly in can_do_mincore() to avoid trigger a
  split in the page table walk, found in sashiko[[2]
- Replace GFP_USER with GFP_KERNEL, suggested by Andrew
- Add Pedro RB and mincore_page() refactor patch

[1] https://lore.kernel.org/linux-mm/20260610230415.C0521C88@davehans-spike.ostc.intel.com/ 
[2] https://sashiko.dev/#/patchset/20260701144047.3786939-1-wangkefeng.wang%40huawei.com?part=2

Kefeng Wang (5):
  mm: mincore: remove special handling for VM_PFNMAP
  mm: mincore: replace __get_free_page() with kmalloc()
  mm: mincore: remove xa_is_value() in mincore_swap()
  mm: mincore: improve mincore_hugetlb()
  mm: mincore: refactor mincore_page()

 mm/mincore.c | 66 ++++++++++++++++++----------------------------------
 1 file changed, 22 insertions(+), 44 deletions(-)

-- 
2.55.0



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/5] mm: mincore: remove special handling for VM_PFNMAP
  2026-07-10 12:00 [PATCH v2 0/5] mm: mincore: misc cleanups Kefeng Wang
@ 2026-07-10 12:00 ` Kefeng Wang
  2026-07-10 12:07   ` David Hildenbrand (Arm)
  2026-07-10 12:00 ` [PATCH v2 2/5] mm: mincore: replace __get_free_page() with kmalloc() Kefeng Wang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Kefeng Wang @ 2026-07-10 12:00 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

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.
Instead, make them now reported as resident by checking the
VMA_PFNMAP_BIT, simplifying the code.

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 | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/mm/mincore.c b/mm/mincore.c
index 53b982803771..0eb832ee0a30 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -219,7 +219,7 @@ static inline bool can_do_mincore(struct vm_area_struct *vma)
 {
 	if (vma_is_anonymous(vma))
 		return true;
-	if (!vma->vm_file)
+	if (!vma->vm_file || vma_test(vma, VMA_PFNMAP_BIT))
 		return false;
 	/*
 	 * Reveal pagecache information only for non-anonymous mappings that
@@ -259,14 +259,6 @@ static long do_mincore(unsigned long addr, unsigned long pages, unsigned char *v
 		return pages;
 	}
 
-	/*
-	 * mincore historically reports PFNMAP mappings as non-resident.
-	 */
-	if (vma->vm_flags & VM_PFNMAP) {
-		__mincore_unmapped_range(addr, end, vma, vec);
-		return (end - addr) >> PAGE_SHIFT;
-	}
-
 	err = walk_page_range_vma(vma, addr, end, &mincore_walk_ops, vec);
 	if (err < 0)
 		return err;
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 2/5] mm: mincore: replace __get_free_page() with kmalloc()
  2026-07-10 12:00 [PATCH v2 0/5] mm: mincore: misc cleanups Kefeng Wang
  2026-07-10 12:00 ` [PATCH v2 1/5] mm: mincore: remove special handling for VM_PFNMAP Kefeng Wang
@ 2026-07-10 12:00 ` Kefeng Wang
  2026-07-10 12:09   ` David Hildenbrand (Arm)
  2026-07-10 12:00 ` [PATCH v2 3/5] mm: mincore: remove xa_is_value() in mincore_swap() Kefeng Wang
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Kefeng Wang @ 2026-07-10 12:00 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

Remove ugly casts by using the more natural kmalloc/kfree allocation,
also replace GFP_USER(pointless here) with GFP_KERNEL.

Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/mincore.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/mincore.c b/mm/mincore.c
index 0eb832ee0a30..bff19a0df9f5 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -12,6 +12,7 @@
 #include <linux/gfp.h>
 #include <linux/pagewalk.h>
 #include <linux/mman.h>
+#include <linux/slab.h>
 #include <linux/syscalls.h>
 #include <linux/swap.h>
 #include <linux/leafops.h>
@@ -313,7 +314,7 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len,
 	if (!access_ok(vec, pages))
 		return -EFAULT;
 
-	tmp = (void *) __get_free_page(GFP_USER);
+	tmp = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	if (!tmp)
 		return -EAGAIN;
 
@@ -338,6 +339,6 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len,
 		start += retval << PAGE_SHIFT;
 		retval = 0;
 	}
-	free_page((unsigned long) tmp);
+	kfree(tmp);
 	return retval;
 }
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 3/5] mm: mincore: remove xa_is_value() in mincore_swap()
  2026-07-10 12:00 [PATCH v2 0/5] mm: mincore: misc cleanups Kefeng Wang
  2026-07-10 12:00 ` [PATCH v2 1/5] mm: mincore: remove special handling for VM_PFNMAP Kefeng Wang
  2026-07-10 12:00 ` [PATCH v2 2/5] mm: mincore: replace __get_free_page() with kmalloc() Kefeng Wang
@ 2026-07-10 12:00 ` Kefeng Wang
  2026-07-10 12:09   ` David Hildenbrand (Arm)
  2026-07-10 12:00 ` [PATCH v2 4/5] mm: mincore: improve mincore_hugetlb() Kefeng Wang
  2026-07-10 12:00 ` [PATCH v2 5/5] mm: mincore: refactor mincore_page() Kefeng Wang
  4 siblings, 1 reply; 11+ messages in thread
From: Kefeng Wang @ 2026-07-10 12:00 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

The swap_cache_get_folio() no longer returns shadow entries, so the
xa_is_value() check is unnecessary.

Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/mincore.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/mincore.c b/mm/mincore.c
index bff19a0df9f5..8b5e6afefb91 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -91,8 +91,7 @@ static unsigned char mincore_swap(swp_entry_t entry, bool shmem)
 	folio = swap_cache_get_folio(entry);
 	if (shmem)
 		put_swap_device(si);
-	/* The swap cache space contains either folio, shadow or NULL */
-	if (folio && !xa_is_value(folio)) {
+	if (folio) {
 		present = folio_test_uptodate(folio);
 		folio_put(folio);
 	}
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 4/5] mm: mincore: improve mincore_hugetlb()
  2026-07-10 12:00 [PATCH v2 0/5] mm: mincore: misc cleanups Kefeng Wang
                   ` (2 preceding siblings ...)
  2026-07-10 12:00 ` [PATCH v2 3/5] mm: mincore: remove xa_is_value() in mincore_swap() Kefeng Wang
@ 2026-07-10 12:00 ` Kefeng Wang
  2026-07-10 12:17   ` David Hildenbrand (Arm)
  2026-07-10 12:00 ` [PATCH v2 5/5] mm: mincore: refactor mincore_page() Kefeng Wang
  4 siblings, 1 reply; 11+ messages in thread
From: Kefeng Wang @ 2026-07-10 12:00 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

The walk_hugetlb_range() always passes a non-NULL pte, so remove the
dead NULL check. Replace the per-page iteration loop with memset()
for better performance.

Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/mincore.c | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/mm/mincore.c b/mm/mincore.c
index 8b5e6afefb91..9952bc3edf76 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -28,30 +28,17 @@ static int mincore_hugetlb(pte_t *pte, unsigned long hmask, unsigned long addr,
 			unsigned long end, struct mm_walk *walk)
 {
 #ifdef CONFIG_HUGETLB_PAGE
-	unsigned char present;
+	unsigned long nr = (end - addr) >> PAGE_SHIFT;
 	unsigned char *vec = walk->private;
+	unsigned char present;
 	spinlock_t *ptl;
+	pte_t ptep;
 
 	ptl = huge_pte_lock(hstate_vma(walk->vma), walk->mm, pte);
-
-	/*
-	 * Hugepages under user process are always in RAM and never
-	 * swapped out, but theoretically it needs to be checked.
-	 */
-	if (!pte) {
-		present = 0;
-	} else {
-		const pte_t ptep = huge_ptep_get(walk->mm, addr, pte);
-
-		if (huge_pte_none(ptep) || pte_is_marker(ptep))
-			present = 0;
-		else
-			present = 1;
-	}
-
-	for (; addr != end; vec++, addr += PAGE_SIZE)
-		*vec = present;
-	walk->private = vec;
+	ptep = huge_ptep_get(walk->mm, addr, pte);
+	present = !(huge_pte_none(ptep) || pte_is_marker(ptep));
+	memset(vec, present, nr);
+	walk->private += nr;
 	spin_unlock(ptl);
 #else
 	BUG();
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 5/5] mm: mincore: refactor mincore_page()
  2026-07-10 12:00 [PATCH v2 0/5] mm: mincore: misc cleanups Kefeng Wang
                   ` (3 preceding siblings ...)
  2026-07-10 12:00 ` [PATCH v2 4/5] mm: mincore: improve mincore_hugetlb() Kefeng Wang
@ 2026-07-10 12:00 ` Kefeng Wang
  2026-07-10 12:19   ` David Hildenbrand (Arm)
  4 siblings, 1 reply; 11+ messages in thread
From: Kefeng Wang @ 2026-07-10 12:00 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

Use early returns to reduce indentation and improve readability.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/mincore.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/mm/mincore.c b/mm/mincore.c
index 9952bc3edf76..30a3317082d1 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -94,7 +94,7 @@ static unsigned char mincore_swap(swp_entry_t entry, bool shmem)
  */
 static unsigned char mincore_page(struct address_space *mapping, pgoff_t index)
 {
-	unsigned char present = 0;
+	unsigned char present;
 	struct folio *folio;
 
 	/*
@@ -104,17 +104,16 @@ static unsigned char mincore_page(struct address_space *mapping, pgoff_t index)
 	 * tmpfs's .fault). So swapped out tmpfs mappings are tested here.
 	 */
 	folio = filemap_get_entry(mapping, index);
-	if (folio) {
-		if (xa_is_value(folio)) {
-			if (shmem_mapping(mapping))
-				return mincore_swap(radix_to_swp_entry(folio),
-						    true);
-			else
-				return 0;
-		}
-		present = folio_test_uptodate(folio);
-		folio_put(folio);
+	if (!folio)
+		return 0;
+
+	if (xa_is_value(folio)) {
+		if (!shmem_mapping(mapping))
+			return 0;
+		return mincore_swap(radix_to_swp_entry(folio), true);
 	}
+	present = folio_test_uptodate(folio);
+	folio_put(folio);
 
 	return present;
 }
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/5] mm: mincore: remove special handling for VM_PFNMAP
  2026-07-10 12:00 ` [PATCH v2 1/5] mm: mincore: remove special handling for VM_PFNMAP Kefeng Wang
@ 2026-07-10 12:07   ` David Hildenbrand (Arm)
  0 siblings, 0 replies; 11+ messages in thread
From: David Hildenbrand (Arm) @ 2026-07-10 12:07 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/10/26 14:00, 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.
> Instead, make them now reported as resident by checking the
> VMA_PFNMAP_BIT, simplifying the code.
> 
> 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 | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/mm/mincore.c b/mm/mincore.c
> index 53b982803771..0eb832ee0a30 100644
> --- a/mm/mincore.c
> +++ b/mm/mincore.c
> @@ -219,7 +219,7 @@ static inline bool can_do_mincore(struct vm_area_struct *vma)
>  {
>  	if (vma_is_anonymous(vma))
>  		return true;
> -	if (!vma->vm_file)
> +	if (!vma->vm_file || vma_test(vma, VMA_PFNMAP_BIT))
>  		return false;
>  	/*
>  	 * Reveal pagecache information only for non-anonymous mappings that
> @@ -259,14 +259,6 @@ static long do_mincore(unsigned long addr, unsigned long pages, unsigned char *v
>  		return pages;
>  	}
>  
> -	/*
> -	 * mincore historically reports PFNMAP mappings as non-resident.
> -	 */
> -	if (vma->vm_flags & VM_PFNMAP) {
> -		__mincore_unmapped_range(addr, end, vma, vec);
> -		return (end - addr) >> PAGE_SHIFT;
> -	}
> -
>  	err = walk_page_range_vma(vma, addr, end, &mincore_walk_ops, vec);
>  	if (err < 0)
>  		return err;


What about MAP_PRIVATE PFN mappings with anonymous pages in there that could
have migration entries?

I'd assume that we'd want to scan the thing and simply mark present ptes as ...
present.

-- 
Cheers,

David


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 2/5] mm: mincore: replace __get_free_page() with kmalloc()
  2026-07-10 12:00 ` [PATCH v2 2/5] mm: mincore: replace __get_free_page() with kmalloc() Kefeng Wang
@ 2026-07-10 12:09   ` David Hildenbrand (Arm)
  0 siblings, 0 replies; 11+ messages in thread
From: David Hildenbrand (Arm) @ 2026-07-10 12:09 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/10/26 14:00, Kefeng Wang wrote:
> Remove ugly casts by using the more natural kmalloc/kfree allocation,
> also replace GFP_USER(pointless here) with GFP_KERNEL.
> 
> Reviewed-by: Pedro Falcato <pfalcato@suse.de>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 3/5] mm: mincore: remove xa_is_value() in mincore_swap()
  2026-07-10 12:00 ` [PATCH v2 3/5] mm: mincore: remove xa_is_value() in mincore_swap() Kefeng Wang
@ 2026-07-10 12:09   ` David Hildenbrand (Arm)
  0 siblings, 0 replies; 11+ messages in thread
From: David Hildenbrand (Arm) @ 2026-07-10 12:09 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/10/26 14:00, Kefeng Wang wrote:
> The swap_cache_get_folio() no longer returns shadow entries, so the
> xa_is_value() check is unnecessary.
> 
> Reviewed-by: Pedro Falcato <pfalcato@suse.de>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 4/5] mm: mincore: improve mincore_hugetlb()
  2026-07-10 12:00 ` [PATCH v2 4/5] mm: mincore: improve mincore_hugetlb() Kefeng Wang
@ 2026-07-10 12:17   ` David Hildenbrand (Arm)
  0 siblings, 0 replies; 11+ messages in thread
From: David Hildenbrand (Arm) @ 2026-07-10 12:17 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/10/26 14:00, Kefeng Wang wrote:
> The walk_hugetlb_range() always passes a non-NULL pte, so remove the
> dead NULL check. Replace the per-page iteration loop with memset()
> for better performance.
> 
> Reviewed-by: Pedro Falcato <pfalcato@suse.de>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  mm/mincore.c | 27 +++++++--------------------
>  1 file changed, 7 insertions(+), 20 deletions(-)
> 
> diff --git a/mm/mincore.c b/mm/mincore.c
> index 8b5e6afefb91..9952bc3edf76 100644
> --- a/mm/mincore.c
> +++ b/mm/mincore.c
> @@ -28,30 +28,17 @@ static int mincore_hugetlb(pte_t *pte, unsigned long hmask, unsigned long addr,
>  			unsigned long end, struct mm_walk *walk)
>  {
>  #ifdef CONFIG_HUGETLB_PAGE
> -	unsigned char present;
> +	unsigned long nr = (end - addr) >> PAGE_SHIFT;
>  	unsigned char *vec = walk->private;
> +	unsigned char present;
>  	spinlock_t *ptl;
> +	pte_t ptep;
>  
>  	ptl = huge_pte_lock(hstate_vma(walk->vma), walk->mm, pte);
> -
> -	/*
> -	 * Hugepages under user process are always in RAM and never
> -	 * swapped out, but theoretically it needs to be checked.
> -	 */
> -	if (!pte) {
> -		present = 0;
> -	} else {
> -		const pte_t ptep = huge_ptep_get(walk->mm, addr, pte);
> -
> -		if (huge_pte_none(ptep) || pte_is_marker(ptep))
> -			present = 0;
> -		else
> -			present = 1;
> -	}
> -
> -	for (; addr != end; vec++, addr += PAGE_SIZE)
> -		*vec = present;
> -	walk->private = vec;
> +	ptep = huge_ptep_get(walk->mm, addr, pte);
> +	present = !(huge_pte_none(ptep) || pte_is_marker(ptep));

Easier to read as

	present = !huge_pte_none(ptep) && !pte_is_marker(ptep);

But now I wonder "why not pte_present()".

Calling this "present" is misleading. It's maybe "resident"?

I guess we want to indicate migration entries and hwpoison entries as "1".

-- 
Cheers,

David


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 5/5] mm: mincore: refactor mincore_page()
  2026-07-10 12:00 ` [PATCH v2 5/5] mm: mincore: refactor mincore_page() Kefeng Wang
@ 2026-07-10 12:19   ` David Hildenbrand (Arm)
  0 siblings, 0 replies; 11+ messages in thread
From: David Hildenbrand (Arm) @ 2026-07-10 12:19 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/10/26 14:00, Kefeng Wang wrote:
> Use early returns to reduce indentation and improve readability.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  mm/mincore.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/mm/mincore.c b/mm/mincore.c
> index 9952bc3edf76..30a3317082d1 100644
> --- a/mm/mincore.c
> +++ b/mm/mincore.c
> @@ -94,7 +94,7 @@ static unsigned char mincore_swap(swp_entry_t entry, bool shmem)
>   */
>  static unsigned char mincore_page(struct address_space *mapping, pgoff_t index)
>  {
> -	unsigned char present = 0;
> +	unsigned char present;
>  	struct folio *folio;
>  
>  	/*
> @@ -104,17 +104,16 @@ static unsigned char mincore_page(struct address_space *mapping, pgoff_t index)
>  	 * tmpfs's .fault). So swapped out tmpfs mappings are tested here.
>  	 */
>  	folio = filemap_get_entry(mapping, index);
> -	if (folio) {
> -		if (xa_is_value(folio)) {
> -			if (shmem_mapping(mapping))
> -				return mincore_swap(radix_to_swp_entry(folio),
> -						    true);
> -			else
> -				return 0;
> -		}
> -		present = folio_test_uptodate(folio);
> -		folio_put(folio);
> +	if (!folio)
> +		return 0;
> +
> +	if (xa_is_value(folio)) {
> +		if (!shmem_mapping(mapping))
> +			return 0;
> +		return mincore_swap(radix_to_swp_entry(folio), true);
>  	}
> +	present = folio_test_uptodate(folio);
> +	folio_put(folio);

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-07-10 12:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-10 12:00 [PATCH v2 0/5] mm: mincore: misc cleanups Kefeng Wang
2026-07-10 12:00 ` [PATCH v2 1/5] mm: mincore: remove special handling for VM_PFNMAP Kefeng Wang
2026-07-10 12:07   ` David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 2/5] mm: mincore: replace __get_free_page() with kmalloc() Kefeng Wang
2026-07-10 12:09   ` David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 3/5] mm: mincore: remove xa_is_value() in mincore_swap() Kefeng Wang
2026-07-10 12:09   ` David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 4/5] mm: mincore: improve mincore_hugetlb() Kefeng Wang
2026-07-10 12:17   ` David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 5/5] mm: mincore: refactor mincore_page() Kefeng Wang
2026-07-10 12:19   ` David Hildenbrand (Arm)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox