diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-08-30 14:01:00 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-12-15 17:35:39 -0300 |
commit | 0f982c182760bd7689769ee7590df592d0a132c0 (patch) | |
tree | f538197b6d1f3d2bd4eda217fccb4c824d3b5929 /malloc/malloc.c | |
parent | 0849eed45daabf30a02c153695041597d6d43b2d (diff) | |
download | glibc-0f982c182760bd7689769ee7590df592d0a132c0.tar.gz glibc-0f982c182760bd7689769ee7590df592d0a132c0.tar.xz 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/malloc.c')
-rw-r--r-- | malloc/malloc.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c index 32050be4cc..b67f2c84ee 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -2741,8 +2741,16 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) segregated mmap region. */ - char *mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, pagesize, - MMAP_AS_MORECORE_SIZE, 0, av); + char *mbrk = MAP_FAILED; +#if HAVE_TUNABLES + if (mp_.hp_pagesize > 0) + mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, + mp_.hp_pagesize, mp_.hp_pagesize, + mp_.hp_flags, av); +#endif + if (mbrk == MAP_FAILED) + mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, pagesize, + MMAP_AS_MORECORE_SIZE, 0, av); if (mbrk != MAP_FAILED) { /* We do not need, and cannot use, another sbrk call to find end */ |