Re: [PATCH v4 5/7] mm/khugepaged: Refactor the PTE state checks into a helper

From: Andrew Morton

Date: Wed Aug 12 2026 - 15:40:49 EST


On Wed, 12 Aug 2026 10:40:08 +0200 "David Hildenbrand (Arm)" <david@xxxxxxxxxx> wrote:

> On 8/11/26 14:48, Nico Pache (Red Hat) wrote:
> > For anonymous collapse, the collapse_scan_pmd() and
> > __collapse_huge_page_isolate() functions share a large portion of their
> > logic. These functions both check the state of the PTEs and verify the
> > following:
> > - max_pte_* values are not exceeded
> > - uffd is not active
> > - lazyfree properties
> > - non-anonymous
> >
> > Merge these checks into a helper collapse_check_pte() to reduce code
> > duplication. We also add a helper struct for this function called
> > pte_check_context which allows us to pass the required parameters in a
> > clean and elegant manner.
> >
> > A helper function is also introduced pte_check_fail() to provide a clean
> > interface to set the pte_check_context failure results and return
> > PTE_CHECK_FAIL state. This helps reduce code duplications across the new
> > collapse_check_pte function.
> >
> > Two slight modifications are done to the original functionality. We now
> > warn (instead of crash) if the anon test fails, and we leverage the
> > vm_normal_folio function instead of page->folio, this should be
> > functionally equivalent.
> >
> > No other functional changes intended.
> >
> > This patch is heavily based off work done by Lance Yang, but modified to
> > deal with conflicts and feedback received during the review cycle [1].
> >
>
> TL;DR, I think this patch here needs some more work, and we should not fast
> track it at this point.

This has been floating around since July 6, so it's never been
fast-tracked!

> @Andrew, can we delay this patch here for this merge window? Removing it from
> mm-unstable shouldn't conflict with any other patch in this series.

np. "cleanups" aren't high priority.

I'll move the entire series into mm-new (and hence out of linux-next)
and shall await developments.