Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/mm/uffd-stress: stricten constraint on free hugepages needed before the test

The test requires at least 2 * (bytes/page_size) hugetlb memory, since we
require identical number of hugepages for src and dst location. Fix this.

Along with the above, as explained in patch "selftests/mm/uffd-stress:
Make test operate on less hugetlb memory", the racy nature of the test
requires that we have some extra number of hugepages left beyond what is
required. Therefore, stricten this constraint.

Link: https://lkml.kernel.org/r/20250909061531.57272-3-dev.jain@arm.com
Fixes: 5a6aa60d1823 ("selftests/mm: skip uffd hugetlb tests with insufficient hugepages")
Signed-off-by: Dev Jain <dev.jain@arm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Mariano Pache <npache@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Dev Jain and committed by
Andrew Morton
1580cd50 060b6c72

+11 -6
+11 -6
tools/testing/selftests/mm/uffd-stress.c
··· 448 448 parse_test_type_arg(argv[1]); 449 449 bytes = atol(argv[2]) * 1024 * 1024; 450 450 451 - if (test_type == TEST_HUGETLB && 452 - get_free_hugepages() < bytes / page_size) { 453 - printf("skip: Skipping userfaultfd... not enough hugepages\n"); 454 - return KSFT_SKIP; 455 - } 456 - 457 451 nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); 458 452 if (nr_cpus > 32) { 459 453 /* Don't let calculation below go to zero. */ ··· 456 462 nr_parallel = 32; 457 463 } else { 458 464 nr_parallel = nr_cpus; 465 + } 466 + 467 + /* 468 + * src and dst each require bytes / page_size number of hugepages. 469 + * Ensure nr_parallel - 1 hugepages on top of that to account 470 + * for racy extra reservation of hugepages. 471 + */ 472 + if (test_type == TEST_HUGETLB && 473 + get_free_hugepages() < 2 * (bytes / page_size) + nr_parallel - 1) { 474 + printf("skip: Skipping userfaultfd... not enough hugepages\n"); 475 + return KSFT_SKIP; 459 476 } 460 477 461 478 nr_pages_per_cpu = bytes / page_size / nr_parallel;