On 4/29/26 2:12 AM, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <[email protected]>
> 
> hugetlb_madv_vs_map 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 the test before and after applying the patch. Before the
patch, the test skipped if there was not exactly 1 free hugepage
available. After the patch, it correctly allocates one hugepage and the
test passes successfully, restoring the original hugepage settings on exit.

Tested-by: Sarthak Sharma <[email protected]>

> ---
>  tools/testing/selftests/mm/hugetlb_madv_vs_map.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c 
> b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
> index dfbd71a7f709..6c95dd23ca81 100644
> --- a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
> +++ b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
> @@ -77,7 +77,6 @@ void *map_extra(void *unused)
>  int main(void)
>  {
>       pthread_t thread1, thread2, thread3;
> -     unsigned long free_hugepages;
>       void *ret;
>  
>       /*
> @@ -89,11 +88,9 @@ int main(void)
>       ksft_print_header();
>       ksft_set_plan(1);
>  
> -     free_hugepages = hugetlb_free_default_pages();
> -
> -     if (free_hugepages != 1)
> +     if (!hugetlb_setup_default(1))
>               ksft_exit_skip("This test needs one and only one page to 
> execute. Got %lu\n",
> -                            free_hugepages);
> +                            hugetlb_free_default_pages());
>  
>       mmap_size = default_huge_page_size();
>  


Reply via email to