Re: [PATCH] mm/page_vma_mapped: continue past nonmatching huge PMDs
From: David Hildenbrand (Arm)
Date: Fri Oct 16 2026 - 03:50:51 EST
On 10/16/26 03:15, Kyle Zeng wrote:
> A PTE-mapped large folio can straddle PMD boundaries after an unaligned
> mremap(). If the first part is discarded and replaced with an unrelated
> huge PMD, page_vma_mapped_walk() stops instead of looking for the rest
> of the folio in subsequent PMDs.
>
> This also affects migration entries. A walk that stops at an unrelated
> huge PMD can leave migration PTEs behind when migration or an anonymous
> folio split restores the mappings. Those entries do not hold mapping
> references and can outlive the source folio.
> > Skip the current PMD rather than ending the walk on a flag or PFN
> mismatch. Do the same if the PMD became nonpresent before the locked
> recheck. Release the PMD lock, clear the per-PMD state and advance with
> step_forward(), so the existing range limit controls termination.
> This covers present, migration and device-private huge PMDs while
> preserving the matching-PMD and split-to-PTE paths.
>
> Fixes: ace71a19cec5 ("mm: introduce page_vma_mapped_walk()")
THP migration was added in
616b8371539 ("mm: thp: enable thp migration in generic path")
which was a couple (3?) of release after ace71a19cec5. Doesn't really make a
difference for backporting, so we can just keep the Fixes as is (it's the
obvious right thing to do :) ).
> Cc: <stable@xxxxxxxxxxxxxxx>
> Assisted-by: LLM
We can drop these now.
> Signed-off-by: Kyle Zeng <kylebot@xxxxxxxxxx>
> ---
Thanks!
Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
--
Cheers,
David