[PATCH v3 38/54] selftests/mm: hugetlb_madv_vs_map: add setup of HugeTLB pages

Mike Rapoport
2026-04-28T20:47:01Z

hugetlb_madv_vs_map test skips testing if there are no free huge pages
prepared by a wrapper script.

Add setup of HugeTLB pages to the test and make sure that the original
settings are restored on the test exit.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
tools/testing/selftests/mm/hugetlb_madv_vs_map.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
index dfbd71a7f709..6c95dd23ca81 100644
--- a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
+++ b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
@@ -77,7 +77,6 @@ void *map_extra(void *unused)
int main(void)
{
pthread_t thread1, thread2, thread3;
- unsigned long free_hugepages;
void *ret;

/*
@@ -89,11 +88,9 @@ int main(void)
ksft_print_header();
ksft_set_plan(1);

- free_hugepages = hugetlb_free_default_pages();
-
- if (free_hugepages != 1)
+ if (!hugetlb_setup_default(1))
ksft_exit_skip("This test needs one and only one page to execute. Got %lu\n",
- free_hugepages);
+ hugetlb_free_default_pages());

mmap_size = default_huge_page_size();

--
2.53.0