selftests/mm: skip uffd hugetlb tests with insufficient hugepages
authorNico Pache <npache@redhat.com>
Wed, 6 Mar 2024 22:37:13 +0000 (15:37 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 12 Mar 2024 20:07:18 +0000 (13:07 -0700)
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 <npache@redhat.com>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/uffd-stress.c

index 7e83829bbb335b98022c354a6871e8f6340e7328..f78bab0f3d458feb6a7a92e078738cb09c825ea6 100644 (file)
@@ -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;