This is a simple test case that reproduces an mm problem[1], where a page fault races with madvise(), and it is not trivial to reproduce and debug. This test-case aims to avoid such race problems from happening again, impacting workloads that leverages external allocators, such as tcmalloc, jemalloc, etc. Changelog: --------- V2: * Remove some unnecessary checks * Skip the test instead of failing in some cases [1] https://lore.kernel.org/all/20231001005659.2185316-1-riel@xxxxxxxxxxx/#r Breno Leitao (2): selftests/mm: export get_free_hugepages() selftests/mm: Add a new test for madv and hugetlb tools/testing/selftests/mm/Makefile | 1 + tools/testing/selftests/mm/hugetlb-madvise.c | 19 ----- .../selftests/mm/hugetlb_fault_after_madv.c | 73 +++++++++++++++++++ tools/testing/selftests/mm/run_vmtests.sh | 4 + tools/testing/selftests/mm/vm_util.c | 19 +++++ tools/testing/selftests/mm/vm_util.h | 1 + 6 files changed, 98 insertions(+), 19 deletions(-) create mode 100644 tools/testing/selftests/mm/hugetlb_fault_after_madv.c -- 2.34.1