[PATCH v8 6/6] loongarch: Enable THP-aligned load segments by default on 64-bit

WANG Rui wangrui@loongson.cn
Sun Apr 12 23:53:06 GMT 2026


On Mon, Apr 13, 2026 at 7:08 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> 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.

I don’t think it’s fair to call limiting the optimization to THP mode
= always “wrong” or an “issue”.

>From a deployment perspective, especially for a new feature that may
not be beneficial in every corner case, starting with THP mode =
always is a more conservative and practical approach. It helps reduce
the risk of unexpected regressions.

Users who set THP to always are already taking a more aggressive
stance on using THP, and generally are less concerned about potential
edge-case performance issues. In contrast, users running in madvise
mode tend to be more cautious, and they usually expect stronger
evidence and more data before enabling something like this by default.

Thanks,
Rui



More information about the Libc-alpha mailing list