Re: [PATCH 03/13] fs/proc: use softleaf_has_pfn() in pagemap PMD walker
From: Dev Jain
Date: Fri May 29 2026 - 05:34:51 EST
On 27/04/26 3:31 pm, Usama Arif wrote:
> pagemap_pmd_range_thp() assumes that every non-present PMD is a
> migration entry and unconditionally calls softleaf_to_page(). This
> will crash on any non-present PMD type that does not encode a PFN,
> such as the upcoming PMD-level swap entries.
>
> Guard the page lookup with softleaf_has_pfn(), matching how
> pte_to_pagemap_entry() already handles non-present PTEs.
>
> Signed-off-by: Usama Arif <usama.arif@xxxxxxxxx>
> ---
> fs/proc/task_mmu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 751b9ba160fb..6d9f43881e62 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -2042,8 +2042,8 @@ static int pagemap_pmd_range_thp(pmd_t *pmdp, unsigned long addr,
> flags |= PM_SOFT_DIRTY;
> if (pmd_swp_uffd_wp(pmd))
> flags |= PM_UFFD_WP;
> - VM_WARN_ON_ONCE(!pmd_is_migration_entry(pmd));
I think the existing VM_WARN_ON_ONCE here is wrong. We can indeed
reach this path from a non-migration entry. Sending a patch soon.
> - page = softleaf_to_page(entry);
> + if (softleaf_has_pfn(entry))
> + page = softleaf_to_page(entry);
> }
>
> if (page) {