summaryrefslogtreecommitdiff
path: root/malloc/arena.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-08-30 14:01:00 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-12-15 17:35:39 -0300
commit0f982c182760bd7689769ee7590df592d0a132c0 (patch)
treef538197b6d1f3d2bd4eda217fccb4c824d3b5929 /malloc/arena.c
parent0849eed45daabf30a02c153695041597d6d43b2d (diff)
downloadglibc-0f982c182760bd7689769ee7590df592d0a132c0.tar
glibc-0f982c182760bd7689769ee7590df592d0a132c0.tar.gz
glibc-0f982c182760bd7689769ee7590df592d0a132c0.tar.bz2
glibc-0f982c182760bd7689769ee7590df592d0a132c0.zip
malloc: Enable huge page support on main arena
This patch adds support huge page support on main arena allocation, enable with tunable glibc.malloc.hugetlb=2. The patch essentially disable the __glibc_morecore() sbrk() call (similar when memory tag does when sbrk() call does not support it) and fallback to default page size if the memory allocation fails. Checked on x86_64-linux-gnu. Reviewed-by: DJ Delorie <dj@redhat.com>
Diffstat (limited to 'malloc/arena.c')
-rw-r--r--malloc/arena.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/malloc/arena.c b/malloc/arena.c
index e1852f8597..3ed4ef3f05 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -364,6 +364,10 @@ ptmalloc_init (void)
# endif
TUNABLE_GET (mxfast, size_t, TUNABLE_CALLBACK (set_mxfast));
TUNABLE_GET (hugetlb, size_t, TUNABLE_CALLBACK (set_hugetlb));
+ if (mp_.hp_pagesize > 0)
+ /* Force mmap for main arena instead of sbrk, so hugepages are explicitly
+ used. */
+ __always_fail_morecore = true;
#else
if (__glibc_likely (_environ != NULL))
{