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 <[email protected]>
> Reviewed-by: Zi Yan <[email protected]>
> Signed-off-by: Yeoreum Yun <[email protected]>
> ---
> 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