[PATCH v2 20/20 DO-NOT-MERGE] selftests/mm: Add HVO pmd-split fault injection tests

From: James Houghton

Date: Fri Oct 02 2026 - 20:23:37 EST


Run the stress test with PMD splitting failure injection enabled (if
supported). Keep in mind that vmemmap PMDs are only ever split, never
collapsed back to PMDs, so run this step first, before the main stress
test.

Assisted-by: LLM
Signed-off-by: James Houghton <jthoughton@xxxxxxxxxx>
---
tools/testing/selftests/mm/hugetlb_vmemmap_stress.sh | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/mm/hugetlb_vmemmap_stress.sh b/tools/testing/selftests/mm/hugetlb_vmemmap_stress.sh
index 94357a4a45c2..2c874d15399a 100755
--- a/tools/testing/selftests/mm/hugetlb_vmemmap_stress.sh
+++ b/tools/testing/selftests/mm/hugetlb_vmemmap_stress.sh
@@ -4,13 +4,16 @@
# Stress test for HugeTLB vmemmap optimization (HVO).
#
# Phases:
-# 1. accounting: allocate N hugepages, check that nr_memmap_pages +
+# 1. pmd-inject: churn the pool with fail_hugetlb_vmemmap_pmd enabled.
+# Runs first because vmemmap PMDs are only split once, so later phases
+# would leave few PMD splits to fail.
+# 2. accounting: allocate N hugepages, check that nr_memmap_pages +
# nr_memmap_boot_pages drops by exactly N * (vmemmap pages per folio - 1),
# then free them and check it returns to the baseline.
-# 2. stress: churn the pool (optimize/restore) while concurrently reading
+# 3. stress: churn the pool (optimize/restore) while concurrently reading
# struct pages (/proc/kpageflags, /proc/kpagecount), compacting memory,
# and optionally reading page_owner and offlining/onlining memory.
-# 3. pte-inject: like 2, with fail_hugetlb_vmemmap_pte enabled; this hits
+# 4. pte-inject: like 2, with fail_hugetlb_vmemmap_pte enabled; this hits
# both the optimize rollback and the restore (partial HVO) paths.
#
# After each phase the pool is drained back to its original size, memmap
@@ -252,7 +255,7 @@ cleanup() {
local blk t

stop_workers
- for t in fail_hugetlb_vmemmap_pte; do
+ for t in fail_hugetlb_vmemmap_pte fail_hugetlb_vmemmap_pmd; do
[ -d "$(fa_dir $t)" ] && fa_disable $t > /dev/null
done
if [ -f "$tmpdir/hotplug" ]; then
@@ -333,6 +336,7 @@ accounting_phase() {

echo "$marker" > /dev/kmsg

+stress_phase pmd-inject fail_hugetlb_vmemmap_pmd
accounting_phase
stress_phase stress ""
stress_phase pte-inject fail_hugetlb_vmemmap_pte
--
2.56.0.rc1.315.gc6ed9934b7-goog