]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
support: Also run malloc hugetlb=1 tests when transparent hugepage is 'always'
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 2 Jun 2026 19:34:01 +0000 (16:34 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 3 Jun 2026 12:09:27 +0000 (09:09 -0300)
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>
Reviewed-by: Yury Khrustalev <yury.khrustalev@arm.com>
support/support_check_hugetlb.c

index be7e10e80d637e35498d70b97dddc92b99d96be7..c73946c894cd79f1f58b3eda1edfd1333cabf876 100644 (file)
 #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) == 0;
 }
 
 bool
@@ -69,10 +70,10 @@ 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");
+                      " either always or madvise");
   if (hugetlb == 2 && !support_hugepages_reserved ())
     FAIL_UNSUPPORTED ("glibc.malloc.hugetlb=2 requires"
                       " /proc/sys/vm/nr_hugepages > 0");