[PATCH] support: Also run malloc hugetlb2 tests when transparent hugepage is 'always'

Adhemerval Zanella adhemerval.zanella@linaro.org
Mon Jun 1 13:17:29 GMT 2026


The glibc.malloc.hugetlb=1 is redundant with kernel is n 'always'
mode, but the madvise does work, and the tunable should not fail.

Suggested-by: Yury Khrustalev <yury.khrustalev@arm.com>
---
 support/support_check_hugetlb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/support/support_check_hugetlb.c b/support/support_check_hugetlb.c
index be7e10e80d6..2ea78e4fa39 100644
--- a/support/support_check_hugetlb.c
+++ b/support/support_check_hugetlb.c
@@ -28,13 +28,14 @@
 #include <support/check.h>
 
 bool
-support_thp_is_madvise (void)
+support_thp_work_madvise (void)
 {
   int fd = open ("/sys/kernel/mm/transparent_hugepage/enabled", O_RDONLY);
   if (fd == -1)
     return false;
 
 #define MODE_MADVISE "always [madvise] never\n"
+#define MODE_ALWAYS  "[always] madvise never\n"
 
   char str[sizeof(MODE_MADVISE)];
   ssize_t s = read (fd, str, sizeof (str));
@@ -42,7 +43,7 @@ support_thp_is_madvise (void)
   if (s != sizeof (str) - 1)
     return false;
   str[s] = '\0';
-  return strcmp (str, MODE_MADVISE) == 0;
+  return strcmp (str, MODE_MADVISE) == 0 || strcmp (str, MODE_ALWAYS);
 }
 
 bool
@@ -69,7 +70,7 @@ support_check_malloc_hugetlb (void)
     return;
 
   size_t hugetlb = TUNABLE_GET_FULL (glibc, malloc, hugetlb, size_t, NULL);
-  if (hugetlb == 1 && !support_thp_is_madvise ())
+  if (hugetlb == 1 && !support_thp_work_madvise ())
     FAIL_UNSUPPORTED ("glibc.malloc.hugetlb=1 requires"
                       " /sys/kernel/mm/transparent_hugepage/enabled"
                       " = madvise");
-- 
2.43.0



More information about the Libc-alpha mailing list