[PATCH v2 4/4] loongarch: Enable THP-aligned load segments by default and define THP page size
Florian Weimer
fweimer@redhat.com
Thu Feb 26 11:54:38 GMT 2026
* WANG Rui:
> On LoongArch64 Linux, aligning ELF load segments to Transparent Huge Page
> (THP) boundaries provides consistent performance benefits for large
> binaries by reducing TLB pressure and improving instruction fetch
> efficiency.
>
> Enable THP-based load segment alignment by default on LoongArch64 by
> defining `DL_MAP_SEGMENT_ALIGN_THP_DEFAULT`. This allows the dynamic
> loader to apply THP-friendly alignment without requiring the
> `glibc.malloc.hugetlb` tunable to be explicitly set.
>
> Define the default THP page size as 32MB for LoongArch64, reflecting the
> architecture’s normal 16KB page size and PMD-level huge page geometry.
> This value is used by the THP infrastructure to determine appropriate
> alignment and mapping decisions.
>
> * sysdeps/unix/sysv/linux/loongarch/lp64/dl-map-segment-align.h:
> Enable THP-based load segment alignment by default.
> * sysdeps/unix/sysv/linux/loongarch/lp64/malloc-hugepages.h:
> Define the default THP page size.
>
> Signed-off-by: WANG Rui <wangrui@loongson.cn>
> ---
> elf/tst-decorate-maps.c | 2 +-
> .../loongarch/lp64/dl-map-segment-align.h | 23 +++++++++++++++++++
> .../linux/loongarch/lp64/malloc-hugepages.h | 21 +++++++++++++++++
> 3 files changed, 45 insertions(+), 1 deletion(-)
> create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/dl-map-segment-align.h
> create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/malloc-hugepages.h
>
> diff --git a/elf/tst-decorate-maps.c b/elf/tst-decorate-maps.c
> index fa3637af89..d3e6a5540f 100644
> --- a/elf/tst-decorate-maps.c
> +++ b/elf/tst-decorate-maps.c
> @@ -109,7 +109,7 @@ do_test_threads (bool set_guard)
> xpthread_barrier_init (&b, NULL, num_threads + 1);
>
> /* Issue a large malloc to trigger a mmap call. */
> - void *p = xmalloc (2 * 1024 * 1024);
> + void *p = xmalloc (32 * 1024 * 1024);
>
> pthread_t thr[num_threads];
> {
The commit message should mention/explain this change.
Thanks,
Florian
More information about the Libc-alpha
mailing list