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

WANG Rui wangrui@loongson.cn
Thu Mar 5 03:29:08 GMT 2026


On Thu, Mar 5, 2026 at 11:04 AM Xi Ruoyao <xry111@xry111.site> wrote:
>
> On Thu, 2026-03-05 at 10:58 +0800, WANG Rui wrote:
> > This allows the dynamic loader to apply THP-friendly alignment without
> > requiring the `glibc.elf.hugetlb` tunable to be explicitly set.
>
> tunables.texi should be updated to reflect the different default on
> LoongArch.
>
> > +#define DL_MAP_DEFAULT_THP_PAGESIZE (32 * 1024 * 1024)
>
> Is the huge page size always 32M regardless of the normal page size?

LoongArch supports multiple normal page and huge page sizes. The 16K
normal page with a 32M huge page is the most common baseline in
practice. That's why I hardcode 32M here, it matches the typical setup
and avoids the need for runtime probing.

If the normal page size is smaller than 16K, the corresponding huge
page size is also smaller, and in that case mappings are much more
likely to be THP-eligible even without explicitly aligning the start
address.

Conversely, if the normal page size exceeds 16K, the huge page size
becomes much larger than MAX_THP_PAGESIZE (32M), so we intentionally
omit handling those configurations here.

Thanks,
Rui



More information about the Libc-alpha mailing list