Re: [PATCH v5 08/19] selftests/mm: add folio-order check for address ranges
From: Kiryl Shutsemau
Date: Thu Sep 10 2026 - 07:05:28 EST
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)" <kas@xxxxxxxxxx>
> >
> > 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.
The collapse_order_* cases check three windows per case, so I wanted a
helper whose contract is "this window is one folio of this order".
I will fix the changelog if the series gets respun.
--
Kiryl Shutsemau / Kirill A. Shutemov