[RESEND PATCH 4/4] selftests/mm: transhuge_stress: skip the test when thp not available

Chunyu Hu posted 4 patches 3 weeks, 5 days ago
There is a newer version of this series
[RESEND PATCH 4/4] selftests/mm: transhuge_stress: skip the test when thp not available
Posted by Chunyu Hu 3 weeks, 5 days ago
The test requires thp, skip the test when thp is not available to avoid
false positive.

Tested with thp disabled kernel.
Before the fix:
  # --------------------------------
  # running ./transhuge-stress -d 20
  # --------------------------------
  # TAP version 13
  # 1..1
  # transhuge-stress: allocate 1453 transhuge pages, using 2907 MiB virtual memory and 11 MiB of ram
  # Bail out! MADV_HUGEPAGE# Planned tests != run tests (1 != 0)
  # # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
  # [FAIL]
  not ok 60 transhuge-stress -d 20 # exit=1

After the fix:
  # --------------------------------
  # running ./transhuge-stress -d 20
  # --------------------------------
  # 1..0 # SKIP Transparent Hugepages not available
  # [SKIP]
  ok 5 transhuge-stress -d 20 # SKIP

CC: Li Wang <liwang@redhat.com>
Signed-off-by: Chunyu Hu <chuhu@redhat.com>
---
 tools/testing/selftests/mm/transhuge-stress.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/mm/transhuge-stress.c b/tools/testing/selftests/mm/transhuge-stress.c
index bcad47c09518..76316696426d 100644
--- a/tools/testing/selftests/mm/transhuge-stress.c
+++ b/tools/testing/selftests/mm/transhuge-stress.c
@@ -17,6 +17,7 @@
 #include <sys/mman.h>
 #include "vm_util.h"
 #include "kselftest.h"
+#include "thp_settings.h"
 
 int backing_fd = -1;
 int mmap_flags = MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE;
@@ -35,6 +36,9 @@ int main(int argc, char **argv)
 	int pagemap_fd;
 	int duration = 0;
 
+	if (!thp_is_enabled())
+		ksft_exit_skip("Transparent Hugepages not available\n");
+
 	ksft_print_header();
 
 	ram = sysconf(_SC_PHYS_PAGES);
-- 
2.53.0
Re: [RESEND PATCH 4/4] selftests/mm: transhuge_stress: skip the test when thp not available
Posted by David Hildenbrand (Arm) 3 weeks, 4 days ago
On 3/12/26 12:40, Chunyu Hu wrote:
> The test requires thp, skip the test when thp is not available to avoid
> false positive.
> 
> Tested with thp disabled kernel.
> Before the fix:
>   # --------------------------------
>   # running ./transhuge-stress -d 20
>   # --------------------------------
>   # TAP version 13
>   # 1..1
>   # transhuge-stress: allocate 1453 transhuge pages, using 2907 MiB virtual memory and 11 MiB of ram
>   # Bail out! MADV_HUGEPAGE# Planned tests != run tests (1 != 0)
>   # # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
>   # [FAIL]
>   not ok 60 transhuge-stress -d 20 # exit=1
> 
> After the fix:
>   # --------------------------------
>   # running ./transhuge-stress -d 20
>   # --------------------------------
>   # 1..0 # SKIP Transparent Hugepages not available
>   # [SKIP]
>   ok 5 transhuge-stress -d 20 # SKIP
> 
> CC: Li Wang <liwang@redhat.com>
> Signed-off-by: Chunyu Hu <chuhu@redhat.com>
> ---
>  tools/testing/selftests/mm/transhuge-stress.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/testing/selftests/mm/transhuge-stress.c b/tools/testing/selftests/mm/transhuge-stress.c
> index bcad47c09518..76316696426d 100644
> --- a/tools/testing/selftests/mm/transhuge-stress.c
> +++ b/tools/testing/selftests/mm/transhuge-stress.c
> @@ -17,6 +17,7 @@
>  #include <sys/mman.h>
>  #include "vm_util.h"
>  #include "kselftest.h"
> +#include "thp_settings.h"
>  
>  int backing_fd = -1;
>  int mmap_flags = MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE;
> @@ -35,6 +36,9 @@ int main(int argc, char **argv)
>  	int pagemap_fd;
>  	int duration = 0;
>  
> +	if (!thp_is_enabled())
> +		ksft_exit_skip("Transparent Hugepages not available\n");
> +
>  	ksft_print_header();

Shouldn't that go under the ksft_print_header(), like you did in patch #3?

-- 
Cheers,

David
Re: [RESEND PATCH 4/4] selftests/mm: transhuge_stress: skip the test when thp not available
Posted by Chunyu Hu 3 weeks, 4 days ago
On Thu, Mar 12, 2026 at 08:46:23PM +0100, David Hildenbrand (Arm) wrote:
> On 3/12/26 12:40, Chunyu Hu wrote:
> > The test requires thp, skip the test when thp is not available to avoid
> > false positive.
> > 
> > Tested with thp disabled kernel.
> > Before the fix:
> >   # --------------------------------
> >   # running ./transhuge-stress -d 20
> >   # --------------------------------
> >   # TAP version 13
> >   # 1..1
> >   # transhuge-stress: allocate 1453 transhuge pages, using 2907 MiB virtual memory and 11 MiB of ram
> >   # Bail out! MADV_HUGEPAGE# Planned tests != run tests (1 != 0)
> >   # # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
> >   # [FAIL]
> >   not ok 60 transhuge-stress -d 20 # exit=1
> > 
> > After the fix:
> >   # --------------------------------
> >   # running ./transhuge-stress -d 20
> >   # --------------------------------
> >   # 1..0 # SKIP Transparent Hugepages not available
> >   # [SKIP]
> >   ok 5 transhuge-stress -d 20 # SKIP
> > 
> > CC: Li Wang <liwang@redhat.com>
> > Signed-off-by: Chunyu Hu <chuhu@redhat.com>
> > ---
> >  tools/testing/selftests/mm/transhuge-stress.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/tools/testing/selftests/mm/transhuge-stress.c b/tools/testing/selftests/mm/transhuge-stress.c
> > index bcad47c09518..76316696426d 100644
> > --- a/tools/testing/selftests/mm/transhuge-stress.c
> > +++ b/tools/testing/selftests/mm/transhuge-stress.c
> > @@ -17,6 +17,7 @@
> >  #include <sys/mman.h>
> >  #include "vm_util.h"
> >  #include "kselftest.h"
> > +#include "thp_settings.h"
> >  
> >  int backing_fd = -1;
> >  int mmap_flags = MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE;
> > @@ -35,6 +36,9 @@ int main(int argc, char **argv)
> >  	int pagemap_fd;
> >  	int duration = 0;
> >  
> > +	if (!thp_is_enabled())
> > +		ksft_exit_skip("Transparent Hugepages not available\n");
> > +
> >  	ksft_print_header();
> 
> Shouldn't that go under the ksft_print_header(), like you did in patch #3?

It will print the TAP version. I'll change in v2 as you suggested. Thanks!

> 
> -- 
> Cheers,
> 
> David
>
Re: [RESEND PATCH 4/4] selftests/mm: transhuge_stress: skip the test when thp not available
Posted by Lorenzo Stoakes (Oracle) 3 weeks, 3 days ago
On Fri, Mar 13, 2026 at 10:43:27AM +0800, Chunyu Hu wrote:
> On Thu, Mar 12, 2026 at 08:46:23PM +0100, David Hildenbrand (Arm) wrote:
> > On 3/12/26 12:40, Chunyu Hu wrote:
> > > The test requires thp, skip the test when thp is not available to avoid
> > > false positive.
> > >
> > > Tested with thp disabled kernel.
> > > Before the fix:
> > >   # --------------------------------
> > >   # running ./transhuge-stress -d 20
> > >   # --------------------------------
> > >   # TAP version 13
> > >   # 1..1
> > >   # transhuge-stress: allocate 1453 transhuge pages, using 2907 MiB virtual memory and 11 MiB of ram
> > >   # Bail out! MADV_HUGEPAGE# Planned tests != run tests (1 != 0)
> > >   # # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
> > >   # [FAIL]
> > >   not ok 60 transhuge-stress -d 20 # exit=1
> > >
> > > After the fix:
> > >   # --------------------------------
> > >   # running ./transhuge-stress -d 20
> > >   # --------------------------------
> > >   # 1..0 # SKIP Transparent Hugepages not available
> > >   # [SKIP]
> > >   ok 5 transhuge-stress -d 20 # SKIP
> > >
> > > CC: Li Wang <liwang@redhat.com>
> > > Signed-off-by: Chunyu Hu <chuhu@redhat.com>
> > > ---
> > >  tools/testing/selftests/mm/transhuge-stress.c | 4 ++++
> > >  1 file changed, 4 insertions(+)
> > >
> > > diff --git a/tools/testing/selftests/mm/transhuge-stress.c b/tools/testing/selftests/mm/transhuge-stress.c
> > > index bcad47c09518..76316696426d 100644
> > > --- a/tools/testing/selftests/mm/transhuge-stress.c
> > > +++ b/tools/testing/selftests/mm/transhuge-stress.c
> > > @@ -17,6 +17,7 @@
> > >  #include <sys/mman.h>
> > >  #include "vm_util.h"
> > >  #include "kselftest.h"
> > > +#include "thp_settings.h"
> > >
> > >  int backing_fd = -1;
> > >  int mmap_flags = MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE;
> > > @@ -35,6 +36,9 @@ int main(int argc, char **argv)
> > >  	int pagemap_fd;
> > >  	int duration = 0;
> > >
> > > +	if (!thp_is_enabled())
> > > +		ksft_exit_skip("Transparent Hugepages not available\n");
> > > +
> > >  	ksft_print_header();
> >
> > Shouldn't that go under the ksft_print_header(), like you did in patch #3?
>
> It will print the TAP version. I'll change in v2 as you suggested. Thanks!

With that done, LGTM and:

Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>

>
> >
> > --
> > Cheers,
> >
> > David
> >
>

Cheers, Lorenzo
Re: [RESEND PATCH 4/4] selftests/mm: transhuge_stress: skip the test when thp not available
Posted by Zi Yan 3 weeks, 5 days ago
On 12 Mar 2026, at 7:40, Chunyu Hu wrote:

> The test requires thp, skip the test when thp is not available to avoid
> false positive.
>
> Tested with thp disabled kernel.
> Before the fix:
>   # --------------------------------
>   # running ./transhuge-stress -d 20
>   # --------------------------------
>   # TAP version 13
>   # 1..1
>   # transhuge-stress: allocate 1453 transhuge pages, using 2907 MiB virtual memory and 11 MiB of ram
>   # Bail out! MADV_HUGEPAGE# Planned tests != run tests (1 != 0)
>   # # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
>   # [FAIL]
>   not ok 60 transhuge-stress -d 20 # exit=1
>
> After the fix:
>   # --------------------------------
>   # running ./transhuge-stress -d 20
>   # --------------------------------
>   # 1..0 # SKIP Transparent Hugepages not available
>   # [SKIP]
>   ok 5 transhuge-stress -d 20 # SKIP
>
> CC: Li Wang <liwang@redhat.com>
> Signed-off-by: Chunyu Hu <chuhu@redhat.com>
> ---
>  tools/testing/selftests/mm/transhuge-stress.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
LGTM.

Reviewed-by: Zi Yan <ziy@nvidia.com>

Best Regards,
Yan, Zi