[glibc] support: Also run malloc hugetlb=1 tests when transparent hugepage is 'always'
Adhemerval Zanella via Glibc-cvs <[email protected]> Wed, 3 Jun 2026 12:30:02 +0000 (GMT)
| Newsgroups | gmane.comp.lib.glibc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0b271861516cb0c736ef2097a1a916caca43dbeb commit 0b271861516cb0c736ef2097a1a916caca43dbeb Author: Adhemerval Zanella <[email protected]> Date: Tue Jun 2 16:34:01 2026 -0300 support: Also run malloc hugetlb=1 tests when transparent hugepage is 'always' 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 <[email protected]> Reviewed-by: Yury Khrustalev <[email protected]> Diff: --- support/support_check_hugetlb.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/support/support_check_hugetlb.c b/support/support_check_hugetlb.c index be7e10e80d..c73946c894 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) == 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");