malloc: Improve MAP_HUGETLB with glibc.malloc.hugetlb=2
commitbc6d79f4ae99206e7ec7d6a8c5abf26cdefc8bff
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 23 Nov 2023 17:29:15 +0000 (23 14:29 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 29 Nov 2023 12:30:04 +0000 (29 09:30 -0300)
treea906df3c4053624060dc0d61063f1a658eceead1
parenta4c3f5f46e850c977cda81c251036475aab8313c
malloc: Improve MAP_HUGETLB with glibc.malloc.hugetlb=2

Even for explicit large page support, allocation might use mmap without
the hugepage bit set if the requested size is smaller than
mmap_threshold.  For this case where mmap is issued, MAP_HUGETLB is set
iff the allocation size is larger than the used large page.

To force such allocations to use large pages, also tune the mmap_threhold
(if it is not explicit set by a tunable).  This forces allocation to
follow the sbrk path, which will fall back to mmap (which will try large
pages before galling back to default mmap).

Checked on x86_64-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org>
malloc/arena.c