On 9/10/26 9:04 PM, Kiryl Shutsemau wrote:
On Thu, Sep 10, 2026 at 07:14:42PM +0800, Baolin Wang wrote:
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.
Agreed that two sets is one too many. Yeoreum's series rewrites
check_huge_xxx() on top of pagemap and kpageflags, which is what
is_backed_by_folio() already walks, so once that lands the two can meet:
the mTHP branch of check_huge() checks each window for a folio of the
order at its start, and is_range_backed_by_order() goes away or becomes
its internal. That also makes the generic mTHP cases stricter for free.
Look forward to seeing this happen:)
I would rather do that as a follow-up than fold it into either series
now, since both touch the same functions.
Sure.