Re: [PATCH v2 1/2] kselftest: mm: prevent random failure of huge page split for khugepaged
From: David Hildenbrand (Arm)
Date: Thu Aug 27 2026 - 07:04:25 EST
On 8/26/26 14:24, Yeoreum Yun wrote:
> There're some random failure for split_huge_page_test when khugepaged
> collapses pages into pmd again which had split by the test.
>
> Prevent the khugepaged's collapses for split page by setting the
> mapped pmd-huge-page with MADV_NOHUGEPAGE before split.
>
> Reported-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>
> Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>
> Signed-off-by: Yeoreum Yun <yeoreum.yun@xxxxxxx>
> ---
> tools/testing/selftests/mm/split_huge_page_test.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index 86a603692826..8f68bc94a5ca 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -180,6 +180,10 @@ static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, int nr_hp
> if (!rss_anon_before)
> ksft_exit_fail_msg("No RssAnon is allocated before split\n");
>
> + /* Prevent khugepaged from collapsing the pages. */
> + if (madvise(one_page, len, MADV_NOHUGEPAGE))
> + ksft_print_msg("MADV_NOHUGEPAGE failed to prevent khugepaged from collapsing pages.\n");
> +
Ok, this is really only expected to fail on extremely old kernels or kernels
without CONFIG_TRANSPARENT_HUGEPAGE (where we should never get to that point :) ).
Can we just turn that into a
ksft_exit_fail_perror("madvise(MADV_NOHUGEPAGE)");
I'm okay with a ksft_print_msg() as well, but would shorten the message quite a
lot ("MADV_NOHUGEPAGE failed" or sth).
--
Cheers,
David