[PATCH v8 5/6] elf: Align large load segments to PMD huge page size for THP
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Fri Apr 10 10:18:30 GMT 2026
Hi HJ,
>> The goal of this patch is simply to be aware of THP being enabled and,
>> when possible, increase the alignment of LOAD segments so THP can work
>> more effectively. Overall it's a passive approach, the decision of
>> whether a mapping actually ends up using huge pages is entirely left
>> to THP.
>>
>> From an impl point of view, it tries to avoid introducing any
>> additional overhead as much as possible, including extra syscalls and
>> the like.
Indeed. And not just because it is unnecessary overhead, but also because
there were bug reports where containers crashed on the expensive
__get_thp_mode() call. Hence in malloc we don't call it by default.
> Why can't ld.so enable THP? A single __madvise call won't kill the THP
> performance.
It won't, but my question is whether it applies to file mappings in the same
way it works on anonymous mappings. Do you have evidence it does?
Rui's patch is conservative on purpose because it is a new feature. If after
some testing we conclude it works really well, we can improve it further.
Cheers,
Wilco
More information about the Libc-alpha
mailing list