aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
authorMike Rapoport (Microsoft) <rppt@kernel.org>2026-05-11 19:28:22 +0300
committerAndrew Morton <akpm@linux-foundation.org>2026-05-28 21:31:50 -0700
commit9e62ef7d31c83fff56acc5084634b4d7e4f021c4 (patch)
tree5309a8f33d88d7ebf1f0ef6a0db591befc8969da /tools
parentda26069d346288bdae8c25c8722a55b7e824f9d6 (diff)
downloadlinux-next-history-9e62ef7d31c83fff56acc5084634b4d7e4f021c4.tar.gz
selftests/mm: hugetlb-madvise: add setup of HugeTLB pages
hugetlb-madvise 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. Link: https://lore.kernel.org/20260511162840.375890-39-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>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/mm/hugetlb-madvise.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/tools/testing/selftests/mm/hugetlb-madvise.c b/tools/testing/selftests/mm/hugetlb-madvise.c
index 8adcd91d078df..555b4b3d14307 100644
--- a/tools/testing/selftests/mm/hugetlb-madvise.c
+++ b/tools/testing/selftests/mm/hugetlb-madvise.c
@@ -4,12 +4,6 @@
*
* Basic functional testing of madvise MADV_DONTNEED and MADV_REMOVE
* on hugetlb mappings.
- *
- * Before running this test, make sure the administrator has pre-allocated
- * at least MIN_FREE_PAGES hugetlb pages and they are free. In addition,
- * the test takes an argument that is the path to a file in a hugetlbfs
- * filesystem. Therefore, a hugetlbfs filesystem must be mounted on some
- * directory.
*/
#define _GNU_SOURCE
@@ -68,9 +62,9 @@ int main(int argc, char **argv)
if (!base_page_size)
ksft_exit_fail_msg("Unable to determine base page size\n");
+ if (!hugetlb_setup_default(MIN_FREE_PAGES))
+ ksft_exit_skip("Not enough free huge pages (have %lu, need %d)\n", hugetlb_free_default_pages(), MIN_FREE_PAGES);
free_hugepages = hugetlb_free_default_pages();
- if (free_hugepages < MIN_FREE_PAGES)
- ksft_exit_skip("Not enough free huge pages (have %lu, need %d)\n", free_hugepages, MIN_FREE_PAGES);
fd = memfd_create(argv[0], MFD_HUGETLB);
if (fd < 0)