[PATCH 0/4] selftests/mm: check large folio results through check_huge() only

From: Kiryl Shutsemau

Date: Tue Sep 29 2026 - 09:19:22 EST


From: "Kiryl Shutsemau (Meta)" <kas@xxxxxxxxxx>

The mm selftests had two ways to check that a range came out as folios
of a given order. check_huge_anon() and check_huge_file() counted
folios of the order in the range. is_range_backed_by_order() checked
each window for a folio with its head at the window start. Baolin found
the two sets in khugepaged.c confusing [1], and the answer at the time
was to merge them once Yeoreum's rewrite of check_huge_*() on top of
pagemap and kpageflags landed. It is in mm-new now.

Make check_huge() check windows below the PMD size, route every caller
through it, and make is_range_backed_by_order() an internal of vm_util.c.
The split test's count-based check goes the same way, which also makes
it notice a split at the wrong offset. On the way check_huge() stops
reopening pagemap and kpageflags on every call, which was the other
reason the separate helper existed.

Tested on mm-new 2589c5593c20 with KASAN, in 16G guests, x86-64/4K under
KVM and arm64/64K under TCG: the khugepaged matrix at every order,
split_huge_page_test, pagemap_ioctl and khugepaged all:all on tmpfs pass
with the same counts as before.

[1] https://lore.kernel.org/all/65bf1722-c1fd-452a-88c1-c030b042cfbc@xxxxxxxxxxxxxxxxx/

Kiryl Shutsemau (Meta) (4):
selftests/mm: open pagemap and kpageflags once for check_huge()
selftests/mm: check sub-PMD ranges window by window in check_huge()
selftests/mm: check collapse results through check_huge() only
selftests/mm: check split results by position, drop
gather_folio_orders()

.../testing/selftests/mm/folio_order_check.c | 28 +-
tools/testing/selftests/mm/khugepaged.c | 47 ++-
.../selftests/mm/khugepaged_sync_check.c | 7 +-
.../selftests/mm/split_huge_page_test.c | 104 +++---
tools/testing/selftests/mm/vm_util.c | 320 ++++++------------
tools/testing/selftests/mm/vm_util.h | 7 +-
6 files changed, 176 insertions(+), 337 deletions(-)


base-commit: 2589c5593c200e5146db848730baa1d7dd0c9f4e
--
2.54.0