On 4/29/26 2:12 AM, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <[email protected]>
>
> 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.
>
> Signed-off-by: Mike Rapoport (Microsoft) <[email protected]>
I have run this test before and after applying the patch. Before the
patch, the test skipped if the required hugepages were not allocated.
After the patch, it correctly allocates the required hugepages and
passes successfully, restoring the original hugepage settings at exit.
Tested-by: Sarthak Sharma <[email protected]>
> ---
> tools/testing/selftests/mm/hugetlb-madvise.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/hugetlb-madvise.c
> b/tools/testing/selftests/mm/hugetlb-madvise.c
> index 3c08eb6db6a2..b20648d025e6 100644
> --- a/tools/testing/selftests/mm/hugetlb-madvise.c
> +++ b/tools/testing/selftests/mm/hugetlb-madvise.c
> @@ -68,9 +68,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)