On 9/10/26 6:45 PM, Kiryl Shutsemau wrote:
On Wed, Sep 09, 2026 at 06:01:13PM +0800, Baolin Wang wrote:
On 9/8/26 8:50 PM, Kiryl Shutsemau wrote:
From: "Kiryl Shutsemau (Meta)" <[email protected]>
An mTHP collapse test needs to know that a range is backed by folios of the
target order, and that they sit where a collapse would put them. Nothing
answers that today: is_backed_by_folio() classifies the folio behind a
single page, and check_huge_anon() reads smaps AnonHugePages, which only
accounts PMD mappings.
Have you checked check_large_folios() in vm_util.c? It seems to meet your
requirements, or am I missing something?
The changelog is out of date, sorry: since 6dedaf0d46a9 check_huge_anon()
counts mTHP folios through check_large_folios() rather than reading
smaps, and it is what check_huge() already uses for mthp_khugepaged.
It could do this job too, called once per window.
What is_range_backed_by_order() adds is alignment check: the folio has
to sit at the window start. And check_large_folios() reopens two fds per
per call which kinda wasteful.
OK. But can we extend the check_huge_xxx() functions to meet your
requirements, for example by adding a check_aligned_huge_xxx() that
wraps the underlying implementation of check_large_folios()?
I still find it confusing that khugepaged.c has two separate sets of
functions for checking large folios.
Also, Yeoreum has also extended check_large_folios() further[1].
[1]
https://lore.kernel.org/all/[email protected]/