From: Nico Pache Date: Wed, 6 Mar 2024 22:37:13 +0000 (-0700) Subject: selftests/mm: skip uffd hugetlb tests with insufficient hugepages X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5a6aa60d18236c2f8ebc438db3e80e61714a8904;p=linux.git selftests/mm: skip uffd hugetlb tests with insufficient hugepages Now that run_vmtests.sh does not guarantee that the correct hugepage count is available, add a check inside the userfaultfd hugetlb test to verify the nr_hugepages count before continuing. Link: https://lkml.kernel.org/r/20240306223714.320681-3-npache@redhat.com Signed-off-by: Nico Pache Cc: Ben Hutchings Cc: Muchun Song Cc: Muhammad Usama Anjum Cc: Shuah Khan Signed-off-by: Andrew Morton --- diff --git a/tools/testing/selftests/mm/uffd-stress.c b/tools/testing/selftests/mm/uffd-stress.c index 7e83829bbb335..f78bab0f3d458 100644 --- a/tools/testing/selftests/mm/uffd-stress.c +++ b/tools/testing/selftests/mm/uffd-stress.c @@ -441,6 +441,12 @@ int main(int argc, char **argv) parse_test_type_arg(argv[1]); bytes = atol(argv[2]) * 1024 * 1024; + if (test_type == TEST_HUGETLB && + get_free_hugepages() < bytes / page_size) { + printf("skip: Skipping userfaultfd... not enough hugepages\n"); + return KSFT_SKIP; + } + nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); nr_pages_per_cpu = bytes / page_size / nr_cpus;