]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests/mm: uffd-stress: use hugetlb_save and alloc huge pages
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Mon, 11 May 2026 16:28:33 +0000 (19:28 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 21 Jun 2026 18:37:29 +0000 (11:37 -0700)
uffd-stress skips HugeTLB tests 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.

Link: https://lore.kernel.org/20260511162840.375890-50-rppt@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Tested-by: Luiz Capitulino <luizcap@redhat.com>
Tested-by: Sarthak Sharma <sarthak.sharma@arm.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Donet Tom <donettom@linux.ibm.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: Liam Howlett <liam@infradead.org>
Cc: Li Wang <li.wang@linux.dev>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Nico Pache <npache@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/uffd-stress.c

index 7c719d789249d019d1bd80e65db236c8ec2da602..43cc79590136658d90689313dea80f9b06a7e91f 100644 (file)
@@ -480,9 +480,12 @@ int main(int argc, char **argv)
         * Ensure nr_parallel - 1 hugepages on top of that to account
         * for racy extra reservation of hugepages.
         */
-       if (gopts->test_type == TEST_HUGETLB &&
-          hugetlb_free_default_pages() < 2 * (bytes / gopts->page_size) + gopts->nr_parallel - 1)
-               ksft_exit_skip("Skipping userfaultfd... not enough hugepages\n");
+       if (gopts->test_type == TEST_HUGETLB) {
+               unsigned long nr = 2 * (bytes / gopts->page_size) + gopts->nr_parallel - 1;
+
+               if (!hugetlb_setup_default(nr))
+                       ksft_exit_skip("Skipping userfaultfd... not enough hugepages\n");
+       }
 
        gopts->nr_pages_per_cpu = bytes / gopts->page_size / gopts->nr_parallel;
        if (!gopts->nr_pages_per_cpu) {