[PATCH v2] malloc: Enable 2MB THP by default on Aarch64
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Thu Dec 11 23:28:02 GMT 2025
Hi Adhemerval,
> The only thing bothering me is now there is no option users can *disable*
> it for whatever reason. We should at least update the manual/tunables.texi
> documentation that glibc.malloc.hugetlb=1 is the default for AArch64, and
> that it uses a different Huge Page than the one defined by the kernel
> (/sys/kernel/mm/transparent_hugepage/hpage_pmd_size).
>
> Maybe it would be better to work toward adding an aarch64-specific tunable
> knob to set glibc.malloc.hugetlb=1 as the default. At least it aligns better
> with other architectures and gives aarch64 an option to disable this if
> users want the previous semantics.
The idea was to avoid using the glibc.malloc.hugetlb=1 code path by default since
that does several expensive system calls at startup even if you never use malloc.
We could easily use glibc.malloc.hugetlb=0 as the disable option (eg. set thp_mode
to never in that case and check that in thp_init() instead).
In terms of huge page sizes, we have to use reasonable limits rather than just using
the system or user sizes. The current malloc has no checks whatsoever, so it would
fail quickly due to wasting most memory or trying to create arenas that are too large.
Does it sound reasonable to round up a 1.0001GB allocation to 2GB just to use 1GB
huge pages?
Cheers,
Wilco
More information about the Libc-alpha
mailing list