[PATCH] malloc: Avoid accessing /sys/kernel/mm files
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Tue Mar 3 18:06:26 GMT 2026
Hi Aurelien,
On 2026-03-01 22:37, Aurelien Jarno wrote:
> Hi Wilco,
>
> On 2026-02-27 21:03, Wilco Dijkstra wrote:
> >
> > 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.
> >
> > Passes regress, OK for commit?
>
> The strategy sounds good if you confirm it does not have performance
> impact. Not having to probe a file in /sys is definitely way better.
It actually appears to be slightly faster overall on SPEC. For short-lived utilities that
use little memory it should be faster due to avoiding the read of /sys during startup.
Cheers,
Wilco
More information about the Libc-alpha
mailing list