[PATCH] malloc: Enable 2MB THP by default on Aarch64

Dev Jain dev.jain@arm.com
Wed Dec 3 07:03:39 GMT 2025


On 26/11/25 7:32 pm, Wilco Dijkstra wrote:
> Hi Dev,
>
> So before we call madvice_thp for the first time, we have this code:
>
>        if (__glibc_unlikely (mp_.thp_pagesize != 0))
>          {
>            uintptr_t lastbrk = (uintptr_t) MORECORE (0);
>            uintptr_t top = ALIGN_UP (lastbrk + size, mp_.thp_pagesize);
>            size = top - lastbrk;
>          }
>
> It seems to me we should call thp_init() before this so that thp_pagesize
> is set correctly and we align to a huge page if needed (rather than wait
> for the next allocation).

I think we should do this *and* leave the call in madvise_thp() also. Even
before we hit the brk extension code, we may call sysmalloc_mmap() which will
call madvise_thp().

> Cheers,
> Wilco


More information about the Libc-alpha mailing list