[PATCH v8 6/6] loongarch: Enable THP-aligned load segments by default on 64-bit
H.J. Lu
hjl.tools@gmail.com
Sun Apr 12 22:59:50 GMT 2026
On Sun, Apr 12, 2026 at 10:14 PM Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>
> Hi HJ,
>
> > glibc shouldn't assume THP status which is set by kernel.
>
> We cannot safely get the THP status using the /sys/kernel/mm interface:
>
> commit 2e8a940df14e9e03fd5bd01015ebbd00c1a5e9b4
> Author: Wilco Dijkstra <wilco.dijkstra@arm.com>
> Date: Fri Feb 27 20:20:45 2026 +0000
>
> malloc: Avoid accessing /sys/kernel/mm files
>
> On AArch64 malloc always checks /sys/kernel/mm/transparent_hugepage/enabled to
> set the THP mode. However this check is quite expensive and the file may not
> be accessible in containers. If DEFAULT_THP_PAGESIZE is non-zero, use
> malloc_thp_mode_madvise so that we take advantage of THP in all cases. Since
> madvise is a fast systemcall, it adds only a small overhead compared to the
> cost of mmap and populating the pages.
>
> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
>
Exactly. It is OK to assume madvise THP. But it is wrong to assume
always THP.
--
H.J.
More information about the Libc-alpha
mailing list