On Thu, Mar 12, 2026 at 10:11:12AM -0400, Zi Yan wrote:
> On 12 Mar 2026, at 7:40, Chunyu Hu wrote:
> 
> > When thp is not enabled on some kernel config such as realtime kernel, the
> > test will report failure. Fix the false positive by skipping the test
> > directly when thp is not enabled.
> >
> > There's a naming conflict on write_file() function, both thp_settings.h and
> > split_huge_page_test.c define it. To make use of thp_is_enabled() helper in
> > the thp_settings.h, rename this local write_file to safe_write_file to
> > avoid the conflict. The reason to use 'safe_' is it does some error check.
> 
> Both write_file() do safe checks. Actually the code of both functions looks
> almost identical except that the thp_settings one does exit() instead of
> ksft_exit_fail_msg().
> 
> Can you rename the split_huge_page_test’s write_file() to write_file_local()
> and add a comment above the function like
> /* add _local to avoid a function conflict with thp_settings.h */?

Looks like we can move the version that uses ksft_exit_fail_msg() to
vm_util and drop the other one.
 
> With that, feel free to add:
> 
> Reviewed-by: Zi Yan <[email protected]>
> 
> Thanks.
> 
> >
> > Tested with thp disabled kernel:
> > Before The fix:
> >   # --------------------------------------------------
> >   # running ./split_huge_page_test /tmp/xfs_dir_Ywup9p
> >   # --------------------------------------------------
> >   # TAP version 13
> >   # Bail out! Reading PMD pagesize failed
> >   # # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
> >   # [FAIL]
> >   not ok 61 split_huge_page_test /tmp/xfs_dir_Ywup9p # exit=1
> >
> > After the fix:
> >   # --------------------------------------------------
> >   # running ./split_huge_page_test /tmp/xfs_dir_YHPUPl
> >   # --------------------------------------------------
> >   # TAP version 13
> >   # 1..0 # SKIP Transparent Hugepages not available
> >   # [SKIP]
> >   ok 6 split_huge_page_test /tmp/xfs_dir_YHPUPl # SKIP
> >
> > CC: Li Wang <[email protected]>
> > Signed-off-by: Chunyu Hu <[email protected]>
> > ---
> >  tools/testing/selftests/mm/split_huge_page_test.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/mm/split_huge_page_test.c 
> > b/tools/testing/selftests/mm/split_huge_page_test.c
> > index e0167111bdd1..615b75ca62cc 100644
> > --- a/tools/testing/selftests/mm/split_huge_page_test.c
> > +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> > @@ -21,6 +21,7 @@
> >  #include <time.h>
> >  #include "vm_util.h"
> >  #include "kselftest.h"
> > +#include "thp_settings.h"
> >
> >  uint64_t pagesize;
> >  unsigned int pageshift;
> > @@ -255,7 +256,7 @@ static int check_after_split_folio_orders(char 
> > *vaddr_start, size_t len,
> >     return status;
> >  }
> >
> > -static void write_file(const char *path, const char *buf, size_t buflen)
> > +static void safe_write_file(const char *path, const char *buf, size_t 
> > buflen)
> >  {
> >     int fd;
> >     ssize_t numwritten;
> > @@ -283,7 +284,7 @@ static void write_debugfs(const char *fmt, ...)
> >     if (ret >= INPUT_MAX)
> >             ksft_exit_fail_msg("%s: Debugfs input is too long\n", __func__);
> >
> > -   write_file(SPLIT_DEBUGFS, input, ret + 1);
> > +   safe_write_file(SPLIT_DEBUGFS, input, ret + 1);
> >  }
> >
> >  static char *allocate_zero_filled_hugepage(size_t len)
> > @@ -772,6 +773,10 @@ int main(int argc, char **argv)
> >             ksft_finished();
> >     }
> >
> > +   if (!thp_is_enabled()) {
> > +           ksft_exit_skip("Transparent Hugepages not available\n");
> > +   }
> > +
> >     if (argc > 1)
> >             optional_xfs_path = argv[1];
> >
> > -- 
> > 2.53.0
> 
> 
> Best Regards,
> Yan, Zi

-- 
Sincerely yours,
Mike.

Reply via email to