{"id":2219874,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2219874/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/patch/20260405035323.558335-2-wangrui@loongson.cn/","project":{"id":41,"url":"http://patchwork.ozlabs.org/api/1.2/projects/41/?format=json","name":"GNU C Library","link_name":"glibc","list_id":"libc-alpha.sourceware.org","list_email":"libc-alpha@sourceware.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260405035323.558335-2-wangrui@loongson.cn>","list_archive_url":null,"date":"2026-04-05T03:53:17","name":"[v8,1/6] hugepages: Move THP helpers to generic hugepages abstraction","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"adb642232d9cb9e7cf9ff5b05d2ec4c42396cb3a","submitter":{"id":85150,"url":"http://patchwork.ozlabs.org/api/1.2/people/85150/?format=json","name":"WANG Rui","email":"wangrui@loongson.cn"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/glibc/patch/20260405035323.558335-2-wangrui@loongson.cn/mbox/","series":[{"id":498763,"url":"http://patchwork.ozlabs.org/api/1.2/series/498763/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/list/?series=498763","date":"2026-04-05T03:53:16","name":"elf: THP-aware load segment alignment","version":8,"mbox":"http://patchwork.ozlabs.org/series/498763/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2219874/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219874/checks/","tags":{},"related":[],"headers":{"Return-Path":"<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":["incoming@patchwork.ozlabs.org","libc-alpha@sourceware.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","libc-alpha@sourceware.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n dmarc=none (p=none dis=none) header.from=loongson.cn","sourceware.org; spf=pass smtp.mailfrom=loongson.cn","server2.sourceware.org;\n arc=none smtp.remote-ip=114.242.206.163"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fpJWz5m7bz1yD3\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 13:55:27 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id C45874BA2E20\n\tfor <incoming@patchwork.ozlabs.org>; Sun,  5 Apr 2026 03:55:25 +0000 (GMT)","from mail.loongson.cn (mail.loongson.cn [114.242.206.163])\n by sourceware.org (Postfix) with ESMTP id 7E5314BA2E24\n for <libc-alpha@sourceware.org>; Sun,  5 Apr 2026 03:54:07 +0000 (GMT)","from loongson.cn (unknown [223.64.120.66])\n by gateway (Coremail) with SMTP id _____8BxVcHc3NFphBgiAA--.48242S3;\n Sun, 05 Apr 2026 11:54:04 +0800 (CST)","from localhost (unknown [223.64.120.66])\n by front1 (Coremail) with SMTP id qMiowJBxDOHK3NFpP1JlAA--.44692S3;\n Sun, 05 Apr 2026 11:53:58 +0800 (CST)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org C45874BA2E20","OpenDKIM Filter v2.11.0 sourceware.org 7E5314BA2E24"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 7E5314BA2E24","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 7E5314BA2E24","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775361248; cv=none;\n b=FyE2957nWd4qBw3ucXBcy1GsPUaL3dJXB8F0DzWoXCNFO2qpDwWY7Um58hOIfZ19YppBwioyf/lxJBOWmWvJgWuVIw/l52bJvuH2YkGDxF9ZvYRfUeHTmQDG1pDTw3lcog4u0z0Qq6Q1MfC7BqLb/Iu4Uem8NJ+ukGJqAxh7guw=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775361248; c=relaxed/simple;\n bh=2QoRue9+GOUrEgPoMFpUKF9s+pYaEgpPicbdeiPK72k=;\n h=From:To:Subject:Date:Message-ID:MIME-Version;\n b=gy18FoLj3JLJmiJ5eOFeY5/lEQspAjvNfG9VX1jhjAasuMUjr3hDfNrlU4i2jAuO+4qcJ+rOM7EtNyk0dq8kgODuPmRPyUniH3fAqgWFzkknKOCUtE0kStxFDciu+gGwOMCBnBQs1Ia7Vgz9WLkdoNcSfJycoAyeYedxBAOXGCA=","ARC-Authentication-Results":"i=1; server2.sourceware.org","From":"WANG Rui <wangrui@loongson.cn>","To":"libc-alpha@sourceware.org","Cc":"Adhemerval Zanella <adhemerval.zanella@linaro.org>,\n Dev Jain <dev.jain@arm.com>, Florian Weimer <fweimer@redhat.com>,\n Wilco Dijkstra <Wilco.Dijkstra@arm.com>, Xi Ruoyao <xry111@xry111.site>,\n WANG Xuerui <git@xen0n.name>, caiyinyu <caiyinyu@loongson.cn>,\n mengqinggang <mengqinggang@loongson.cn>,\n Huacai Chen <chenhuacai@kernel.org>, hjl.tools@gmail.com,\n WANG Rui <wangrui@loongson.cn>","Subject":"[PATCH v8 1/6] hugepages: Move THP helpers to generic hugepages\n abstraction","Date":"Sun,  5 Apr 2026 11:53:17 +0800","Message-ID":"<20260405035323.558335-2-wangrui@loongson.cn>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260405035323.558335-1-wangrui@loongson.cn>","References":"<20260405035323.558335-1-wangrui@loongson.cn>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-CM-TRANSID":"qMiowJBxDOHK3NFpP1JlAA--.44692S3","X-CM-SenderInfo":"pzdqw2txl6z05rqj20fqof0/","X-Coremail-Antispam":"1Uk129KBj9fXoWfJFWxuFykWw1rtF48Aw4DJrc_yoW8JF4kGo\n WfGFWrJF4rXrn8ZrWxCa90qa1jk34kuw4rJFnxZrZxWayjqr1rAr40ka95Wr9xGF45KFyx\n JFyrK3W5tF18tr95l-sFpf9Il3svdjkaLaAFLSUrUUUU8b8apTn2vfkv8UJUUUU8wcxFpf\n 9Il3svdxBIdaVrn0xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3\n UjIYCTnIWjp_UUUYX7kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI\n 8IcIk0rVWrJVCq3wAFIxvE14AKwVWUAVWUZwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG\n Y2AK021l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14\n v26r4j6F4UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v2\n 6r4j6r4UJwAaw2AFwI0_Jrv_JF1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0c\n Ia020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jw0_\n WrylYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwI\n xGrwCY1x0262kKe7AKxVWUAVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWU\n JVW8JwCFI7km07C267AKxVWUXVWUAwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4\n vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IY\n x2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26c\n xKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAF\n wI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jzc_-UUUUU=","X-BeenThere":"libc-alpha@sourceware.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Libc-alpha mailing list <libc-alpha.sourceware.org>","List-Unsubscribe":"<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>","List-Archive":"<https://sourceware.org/pipermail/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-request@sourceware.org?subject=help>","List-Subscribe":"<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>","Errors-To":"libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"},"content":"The helpers for determining the default transparent huge page size\nand THP mode are currently implemented in malloc-hugepages. However,\nthese interfaces are not malloc-specific and are also needed by other\nsubsystems (e.g. the dynamic loader for segment alignment).\n\nIntroduce a new generic hugepages abstraction and move the THP mode\ndetection, default THP page size probing, and hugepage configuration\nhelpers there. The malloc code now calls into the generic helpers\ninstead of duplicating the sysfs parsing.\n\nThere is no functional change. This is a pure refactoring to make\nthe THP detection reusable outside of malloc.\n\nReviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>\nSigned-off-by: WANG Rui <wangrui@loongson.cn>\n---\n elf/dl-tunables.c                             |  7 ++--\n malloc/malloc-internal.h                      |  2 +-\n malloc/malloc.c                               | 27 ++++++++-------\n sysdeps/generic/Makefile                      |  4 +--\n .../{malloc-hugepages.c => hugepages.c}       | 13 ++++----\n .../{malloc-hugepages.h => hugepages.h}       | 32 ++++++++++--------\n .../{malloc-hugepages.h => hugepages.h}       |  4 +--\n .../linux/{malloc-hugepages.c => hugepages.c} | 33 ++++++++++---------\n 8 files changed, 63 insertions(+), 59 deletions(-)\n rename sysdeps/generic/{malloc-hugepages.c => hugepages.c} (76%)\n rename sysdeps/generic/{malloc-hugepages.h => hugepages.h} (68%)\n rename sysdeps/unix/sysv/linux/aarch64/{malloc-hugepages.h => hugepages.h} (91%)\n rename sysdeps/unix/sysv/linux/{malloc-hugepages.c => hugepages.c} (89%)","diff":"diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c\nindex 1440d3fa6a5..5c65e8b4583 100644\n--- a/elf/dl-tunables.c\n+++ b/elf/dl-tunables.c\n@@ -33,7 +33,7 @@\n #include <array_length.h>\n #include <dl-minimal-malloc.h>\n #include <dl-symbol-redir-ifunc.h>\n-#include <malloc-hugepages.h>\n+#include <hugepages.h>\n \n #define TUNABLES_INTERNAL 1\n #include \"dl-tunables.h\"\n@@ -297,8 +297,9 @@ __tunables_init (char **envp)\n   char *envval = NULL;\n   char **prev_envp = envp;\n \n-  /* Default to glibc.malloc.hugetlb=1 if DEFAULT_THP_PAGESIZE is non-zero.  */\n-  if (DEFAULT_THP_PAGESIZE > 0)\n+  /* Default to glibc.malloc.hugetlb=1 if MALLOC_DEFAULT_THP_PAGESIZE\n+     is non-zero.  */\n+  if (MALLOC_DEFAULT_THP_PAGESIZE > 0)\n     TUNABLE_SET (glibc, malloc, hugetlb, 1);\n \n   /* Ignore tunables for AT_SECURE programs.  */\ndiff --git a/malloc/malloc-internal.h b/malloc/malloc-internal.h\nindex dd326af1ea0..a6340bfd888 100644\n--- a/malloc/malloc-internal.h\n+++ b/malloc/malloc-internal.h\n@@ -22,7 +22,7 @@\n #include <malloc-machine.h>\n #include <malloc-sysdep.h>\n #include <malloc-size.h>\n-#include <malloc-hugepages.h>\n+#include <hugepages.h>\n #include <calloc-clear-memory.h>\n \n /* Called in the parent process before a fork.  */\ndiff --git a/malloc/malloc.c b/malloc/malloc.c\nindex 6a888b0eb7d..febd7b516f4 100644\n--- a/malloc/malloc.c\n+++ b/malloc/malloc.c\n@@ -1759,7 +1759,7 @@ struct malloc_par\n   INTERNAL_SIZE_T arena_max;\n \n   /* Transparent Large Page support.  */\n-  enum malloc_thp_mode_t thp_mode;\n+  enum thp_mode_t thp_mode;\n   INTERNAL_SIZE_T thp_pagesize;\n   /* A value different than 0 means to align mmap allocation to hp_pagesize\n      add hp_flags on flags.  */\n@@ -1814,7 +1814,7 @@ static struct malloc_par mp_ =\n   .trim_threshold = DEFAULT_TRIM_THRESHOLD,\n #define NARENAS_FROM_NCORES(n) ((n) * (sizeof (long) == 4 ? 2 : 8))\n   .arena_test = NARENAS_FROM_NCORES (1),\n-  .thp_mode = malloc_thp_mode_not_supported\n+  .thp_mode = thp_mode_not_supported\n #if USE_TCACHE\n   ,\n   .tcache_count = TCACHE_FILL_COUNT,\n@@ -1896,7 +1896,7 @@ madvise_thp (void *p, INTERNAL_SIZE_T size)\n \n   /* Only use __madvise if the system is using 'madvise' mode and the size\n      is at least a huge page, otherwise the call is wasteful. */\n-  if (mp_.thp_mode != malloc_thp_mode_madvise || size < mp_.thp_pagesize)\n+  if (mp_.thp_mode != thp_mode_madvise || size < mp_.thp_pagesize)\n     return;\n \n   /* Linux requires the input address to be page-aligned, and unaligned\n@@ -5017,33 +5017,32 @@ do_set_mxfast (size_t value)\n static __always_inline int\n do_set_hugetlb (size_t value)\n {\n-  /* Enable THP if DEFAULT_THP_PAGESIZE is non-zero.  */\n-  if (DEFAULT_THP_PAGESIZE > 0)\n+  /* Enable THP if MALLOC_DEFAULT_THP_PAGESIZE is non-zero.  */\n+  if (MALLOC_DEFAULT_THP_PAGESIZE > 0)\n     {\n-      mp_.thp_mode = malloc_thp_mode_madvise;\n-      mp_.thp_pagesize = DEFAULT_THP_PAGESIZE;\n+      mp_.thp_mode = thp_mode_madvise;\n+      mp_.thp_pagesize = MALLOC_DEFAULT_THP_PAGESIZE;\n     }\n \n   if (value == 0)\n     {\n       /* Turn off THP support completely.  */\n-      mp_.thp_mode = malloc_thp_mode_never;\n+      mp_.thp_mode = thp_mode_never;\n       mp_.thp_pagesize = 0;\n     }\n   else if (value == 1)\n     {\n       /* Avoid querying the THP page size/mode since accessing /sys/kernel/mm\n \t is relatively slow and might not be accessible in containers.  */\n-      if (DEFAULT_THP_PAGESIZE > 0)\n+      if (MALLOC_DEFAULT_THP_PAGESIZE > 0)\n \treturn 0;\n \n-      mp_.thp_mode = __malloc_thp_mode ();\n-      if (mp_.thp_mode == malloc_thp_mode_madvise\n-          || mp_.thp_mode == malloc_thp_mode_always)\n-\tmp_.thp_pagesize = __malloc_default_thp_pagesize ();\n+      mp_.thp_mode = __get_thp_mode ();\n+      if (mp_.thp_mode == thp_mode_madvise || mp_.thp_mode == thp_mode_always)\n+\tmp_.thp_pagesize = __get_thp_size ();\n     }\n   else if (value >= 2)\n-    __malloc_hugepage_config (value == 2 ? 0 : value, &mp_.hp_pagesize,\n+    __get_hugepage_config (value == 2 ? 0 : value, &mp_.hp_pagesize,\n \t\t\t      &mp_.hp_flags);\n   return 0;\n }\ndiff --git a/sysdeps/generic/Makefile b/sysdeps/generic/Makefile\nindex 0c25592f35b..53c4efa63e5 100644\n--- a/sysdeps/generic/Makefile\n+++ b/sysdeps/generic/Makefile\n@@ -32,9 +32,9 @@ endif\n endif\n \n ifeq ($(subdir),malloc)\n-sysdep_malloc_debug_routines += malloc-hugepages\n+sysdep_malloc_debug_routines += hugepages\n endif\n \n ifeq ($(subdir),misc)\n-sysdep_routines += malloc-hugepages\n+sysdep_routines += hugepages\n endif\ndiff --git a/sysdeps/generic/malloc-hugepages.c b/sysdeps/generic/hugepages.c\nsimilarity index 76%\nrename from sysdeps/generic/malloc-hugepages.c\nrename to sysdeps/generic/hugepages.c\nindex 57b82a2438d..28bab662b13 100644\n--- a/sysdeps/generic/malloc-hugepages.c\n+++ b/sysdeps/generic/hugepages.c\n@@ -16,23 +16,22 @@\n    License along with the GNU C Library; see the file COPYING.LIB.  If\n    not, see <https://www.gnu.org/licenses/>.  */\n \n-#include <malloc-hugepages.h>\n+#include <hugepages.h>\n \n unsigned long int\n-__malloc_default_thp_pagesize (void)\n+__get_thp_size (void)\n {\n   return 0;\n }\n \n-enum malloc_thp_mode_t\n-__malloc_thp_mode (void)\n+enum thp_mode_t\n+__get_thp_mode (void)\n {\n-  return malloc_thp_mode_not_supported;\n+  return thp_mode_not_supported;\n }\n \n-/* Return the default transparent huge page size.  */\n void\n-__malloc_hugepage_config (size_t requested, size_t *pagesize, int *flags)\n+__get_hugepage_config (size_t requested, size_t *pagesize, int *flags)\n {\n   *pagesize = 0;\n   *flags = 0;\ndiff --git a/sysdeps/generic/malloc-hugepages.h b/sysdeps/generic/hugepages.h\nsimilarity index 68%\nrename from sysdeps/generic/malloc-hugepages.h\nrename to sysdeps/generic/hugepages.h\nindex ab2690f7b8a..5fc9b5c8dea 100644\n--- a/sysdeps/generic/malloc-hugepages.h\n+++ b/sysdeps/generic/hugepages.h\n@@ -1,4 +1,4 @@\n-/* Malloc huge page support.  Generic implementation.\n+/* Huge page support.  Generic implementation.\n    Copyright (C) 2021-2026 Free Software Foundation, Inc.\n    This file is part of the GNU C Library.\n \n@@ -16,33 +16,37 @@\n    License along with the GNU C Library; see the file COPYING.LIB.  If\n    not, see <https://www.gnu.org/licenses/>.  */\n \n-#ifndef _MALLOC_HUGEPAGES_H\n-#define _MALLOC_HUGEPAGES_H\n+#ifndef _HUGEPAGES_H\n+#define _HUGEPAGES_H\n \n #include <stddef.h>\n \n /* Return the default transparent huge page size.  */\n-unsigned long int __malloc_default_thp_pagesize (void) attribute_hidden;\n+unsigned long int __get_thp_size (void) attribute_hidden;\n \n-enum malloc_thp_mode_t\n+enum thp_mode_t\n {\n-  malloc_thp_mode_always,\n-  malloc_thp_mode_madvise,\n-  malloc_thp_mode_never,\n-  malloc_thp_mode_not_supported\n+  thp_mode_always,\n+  thp_mode_madvise,\n+  thp_mode_never,\n+  thp_mode_not_supported\n };\n \n-enum malloc_thp_mode_t __malloc_thp_mode (void) attribute_hidden;\n+enum thp_mode_t __get_thp_mode (void) attribute_hidden;\n \n /* Return the supported huge page size from the REQUESTED sizes on PAGESIZE\n    along with the required extra mmap flags on FLAGS,  Requesting the value\n    of 0 returns the default huge page size, otherwise the value will be\n    matched against the sizes supported by the system.  */\n-void __malloc_hugepage_config (size_t requested, size_t *pagesize, int *flags)\n+void __get_hugepage_config (size_t requested, size_t *pagesize, int *flags)\n      attribute_hidden;\n \n-#ifndef DEFAULT_THP_PAGESIZE\n-# define DEFAULT_THP_PAGESIZE\t0\n+#ifndef MALLOC_DEFAULT_THP_PAGESIZE\n+# define MALLOC_DEFAULT_THP_PAGESIZE\t0\n #endif\n \n-#endif /* _MALLOC_HUGEPAGES_H */\n+#ifndef MAX_THP_PAGESIZE\n+# define MAX_THP_PAGESIZE\t(32 * 1024 * 1024)\n+#endif\n+\n+#endif /* _HUGEPAGES_H */\ndiff --git a/sysdeps/unix/sysv/linux/aarch64/malloc-hugepages.h b/sysdeps/unix/sysv/linux/aarch64/hugepages.h\nsimilarity index 91%\nrename from sysdeps/unix/sysv/linux/aarch64/malloc-hugepages.h\nrename to sysdeps/unix/sysv/linux/aarch64/hugepages.h\nindex 2204112e4e5..4f9de8a3949 100644\n--- a/sysdeps/unix/sysv/linux/aarch64/malloc-hugepages.h\n+++ b/sysdeps/unix/sysv/linux/aarch64/hugepages.h\n@@ -16,6 +16,6 @@\n    License along with the GNU C Library; see the file COPYING.LIB.  If\n    not, see <https://www.gnu.org/licenses/>.  */\n \n-#define DEFAULT_THP_PAGESIZE\t(1UL << 21)\n+#define MALLOC_DEFAULT_THP_PAGESIZE\t(1UL << 21)\n \n-#include_next <malloc-hugepages.h>\n+#include_next <hugepages.h>\ndiff --git a/sysdeps/unix/sysv/linux/malloc-hugepages.c b/sysdeps/unix/sysv/linux/hugepages.c\nsimilarity index 89%\nrename from sysdeps/unix/sysv/linux/malloc-hugepages.c\nrename to sysdeps/unix/sysv/linux/hugepages.c\nindex 77b49374e60..707a75c2a29 100644\n--- a/sysdeps/unix/sysv/linux/malloc-hugepages.c\n+++ b/sysdeps/unix/sysv/linux/hugepages.c\n@@ -18,16 +18,13 @@\n \n #include <intprops.h>\n #include <dirent.h>\n-#include <malloc-hugepages.h>\n+#include <hugepages.h>\n #include <not-cancel.h>\n #include <sys/mman.h>\n \n unsigned long int\n-__malloc_default_thp_pagesize (void)\n+__get_thp_size (void)\n {\n-  if (DEFAULT_THP_PAGESIZE != 0)\n-    return DEFAULT_THP_PAGESIZE;\n-\n   int fd = __open64_nocancel (\n     \"/sys/kernel/mm/transparent_hugepage/hpage_pmd_size\", O_RDONLY);\n   if (fd == -1)\n@@ -50,13 +47,13 @@ __malloc_default_thp_pagesize (void)\n   return r;\n }\n \n-enum malloc_thp_mode_t\n-__malloc_thp_mode (void)\n+enum thp_mode_t\n+__get_thp_mode (void)\n {\n   int fd = __open64_nocancel (\"/sys/kernel/mm/transparent_hugepage/enabled\",\n \t\t\t      O_RDONLY);\n   if (fd == -1)\n-    return malloc_thp_mode_not_supported;\n+    return thp_mode_not_supported;\n \n   static const char mode_always[]  = \"[always] madvise never\\n\";\n   static const char mode_madvise[] = \"always [madvise] never\\n\";\n@@ -65,24 +62,26 @@ __malloc_thp_mode (void)\n   char str[sizeof(mode_always)];\n   ssize_t s = __read_nocancel (fd, str, sizeof (str));\n   if (s >= sizeof str || s < 0)\n-    return malloc_thp_mode_not_supported;\n+    return thp_mode_not_supported;\n   str[s] = '\\0';\n   __close_nocancel (fd);\n \n   if (s == sizeof (mode_always) - 1)\n     {\n       if (strcmp (str, mode_always) == 0)\n-\treturn malloc_thp_mode_always;\n+\treturn thp_mode_always;\n       else if (strcmp (str, mode_madvise) == 0)\n-\treturn malloc_thp_mode_madvise;\n+\treturn thp_mode_madvise;\n       else if (strcmp (str, mode_never) == 0)\n-\treturn malloc_thp_mode_never;\n+\treturn thp_mode_never;\n     }\n-  return malloc_thp_mode_not_supported;\n+  return thp_mode_not_supported;\n }\n \n+#if !IS_IN (rtld)\n+\n static size_t\n-malloc_default_hugepage_size (void)\n+get_default_hugepage_size (void)\n {\n   int fd = __open64_nocancel (\"/proc/meminfo\", O_RDONLY);\n   if (fd == -1)\n@@ -136,14 +135,14 @@ hugepage_flags (size_t pagesize)\n }\n \n void\n-__malloc_hugepage_config (size_t requested, size_t *pagesize, int *flags)\n+__get_hugepage_config (size_t requested, size_t *pagesize, int *flags)\n {\n   *pagesize = 0;\n   *flags = 0;\n \n   if (requested == 0)\n     {\n-      *pagesize = malloc_default_hugepage_size ();\n+      *pagesize = get_default_hugepage_size ();\n       if (*pagesize != 0)\n \t*flags = hugepage_flags (*pagesize);\n       return;\n@@ -205,3 +204,5 @@ __malloc_hugepage_config (size_t requested, size_t *pagesize, int *flags)\n \n   __close_nocancel (dirfd);\n }\n+\n+#endif /* !IS_IN(rtld) */\n","prefixes":["v8","1/6"]}