Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/mm: transhuge_stress: skip the test when thp not available

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
# --------------------------------
# TAP version 13
# 1..0 # SKIP Transparent Hugepages not available
# [SKIP]
ok 5 transhuge-stress -d 20 # SKIP

Link: https://lore.kernel.org/20260402014543.1671131-7-chuhu@redhat.com
Signed-off-by: Chunyu Hu <chuhu@redhat.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: Li Wang <liwang@redhat.com>
Cc: Nico Pache <npache@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Chunyu Hu and committed by
Andrew Morton
cfe9a446 dad4964a

+4
+4
tools/testing/selftests/mm/transhuge-stress.c
··· 17 17 #include <sys/mman.h> 18 18 #include "vm_util.h" 19 19 #include "kselftest.h" 20 + #include "thp_settings.h" 20 21 21 22 int backing_fd = -1; 22 23 int mmap_flags = MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE; ··· 37 36 int duration = 0; 38 37 39 38 ksft_print_header(); 39 + 40 + if (!thp_is_enabled()) 41 + ksft_exit_skip("Transparent Hugepages not available\n"); 40 42 41 43 ram = sysconf(_SC_PHYS_PAGES); 42 44 if (ram > SIZE_MAX / psize() / 4)