Re: [PATCH v3 2/4] tools/lib/mm: move hugepage_settings out of selftests
From: Mike Rapoport
Date: Tue May 26 2026 - 05:10:04 EST
On Mon, May 25, 2026 at 11:43:37AM +0530, Sarthak Sharma wrote:
> Hi Mike!
>
> On 5/24/26 10:36 PM, Mike Rapoport wrote:
> > On Thu, 21 May 2026 16:47:59 +0530, Sarthak Sharma <sarthak.sharma@xxxxxxx> wrote:
> >
> > Hi Sarthak,
> >
> >>
> >> diff --git a/tools/testing/selftests/mm/hugepage_settings.c b/tools/lib/mm/hugepage_settings.c
> >> similarity index 98%
> >> rename from tools/testing/selftests/mm/hugepage_settings.c
> >> rename to tools/lib/mm/hugepage_settings.c
> >> index 5e947abb7425..b08b27776fc5 100644
> >> --- a/tools/testing/selftests/mm/hugepage_settings.c
> >> +++ b/tools/lib/mm/hugepage_settings.c
> >> @@ -383,8 +387,6 @@ int detect_hugetlb_page_sizes(unsigned long sizes[], int max)
> >> if (sscanf(entry->d_name, "hugepages-%zukB", &kb) != 1)
> >> continue;
> >> sizes[count++] = kb * 1024;
> >> - ksft_print_msg("[INFO] detected hugetlb page size: %zu KiB\n",
> >> - kb);
> >
> > I believe this message is useful for debugging.
>
> I removed this because hugepage_settings.c is now moving out of
> selftests, and converting the ksft_print_msg() calls to plain printf()
> would break TAP output for selftests.
>
> I can add these diagnostic lines back, but since this is now a shared
> helper, in order to preserve TAP compatibility, I'll have to do a
> fprintf(stderr, "# ..."). I feel this would look a bit odd from a
> non-selftest invocation though.
I think "# ... " is not that bad to begin with :)
> Another option is to add a logging hook so selftests can wire this to
> ksft_print_msg() while non-selftest users can use normal stderr, but
> that feels too much for 2 print statements and would extend the scope of
> this series.
>
> Please let me know if you have a preference here.
--
Sincerely yours,
Mike.