Re: [PATCH v4 5/7] mm/khugepaged: Refactor the PTE state checks into a helper
Pedro Falcato <[email protected]>
| Newsgroups | org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel,org.kvack.linux-mm |
|---|---|
| Message-ID | <anxPu3TBiI9bi53x@pedro-suse> |
On Tue, Aug 11, 2026 at 06:48:37AM -0600, 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]. > > [1] https://lore.kernel.org/linux-mm/[email protected]/ > Suggested-by: David Hildenbrand <[email protected]> > Signed-off-by: Nico Pache (Red Hat) <[email protected]> > --- > mm/khugepaged.c | 298 +++++++++++++++++++++++++++++--------------------------- > 1 file changed, 157 insertions(+), 141 deletions(-) Ugh, this is quite a big change, can you break it down into a bunch of patches? It's quite hard to properly review otherwise. The spirit of the change looks good itself, but the devil is always in the details :) -- Pedro