Skip to content

Commit cfe9a44

Browse files
Chunyu-Huakpm00
authored andcommitted
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>
1 parent dad4964 commit cfe9a44

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

tools/testing/selftests/mm/transhuge-stress.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <sys/mman.h>
1818
#include "vm_util.h"
1919
#include "kselftest.h"
20+
#include "thp_settings.h"
2021

2122
int backing_fd = -1;
2223
int mmap_flags = MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE;
@@ -37,6 +38,9 @@ int main(int argc, char **argv)
3738

3839
ksft_print_header();
3940

41+
if (!thp_is_enabled())
42+
ksft_exit_skip("Transparent Hugepages not available\n");
43+
4044
ram = sysconf(_SC_PHYS_PAGES);
4145
if (ram > SIZE_MAX / psize() / 4)
4246
ram = SIZE_MAX / 4;

0 commit comments

Comments
 (0)