Re: [PATCH v6 11/19] selftests/mm: add order-parameterized khugepaged collapse cases
From: Baolin Wang
Date: Wed Sep 23 2026 - 02:54:48 EST
On 9/19/26 8:24 AM, Kiryl Shutsemau wrote:
From: "Kiryl Shutsemau (Meta)" <kas@xxxxxxxxxx>
The mthp_khugepaged context runs the generic cases at a sub-PMD order,
which answers how many folios of that order a range ends up with. It
cannot say which order-sized window they landed in, so "the populated
window collapsed" and "the empty window next to it collapsed instead" look
alike.
Add four cases that check each window on its own, with the folio-order
helpers in vm_util:
- collapse_order_single_window(): only the populated window collapses;
- collapse_order_partial_window(): the default max_ptes_none lets a window
with one present PTE collapse;
- collapse_order_max_ptes_none(): with max_ptes_none=0 a full window
collapses and one missing a page does not;
- collapse_order_mixed_sources(): sources that are already large folios of
a smaller order collapse to the target.
Each case faults its region before MADV_HUGEPAGE with only the target
order enabled, so the sources are order 0 and the result can only come
from khugepaged. They wait for a full pass rather than for the result to
appear: without a completed pass, "not collapsed" and "not scanned yet"
are the same thing.
Assisted-by: LLM
Tested-by: Muhammad Usama Anjum <usama.anjum@xxxxxxx>
Signed-off-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
---
Tested-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>