]> git.ipfire.org Git - thirdparty/glibc.git/commit
loongarch: Enable THP-aligned load segments by default on 64-bit master
authorWANG Rui <wangrui@loongson.cn>
Tue, 14 Apr 2026 15:26:58 +0000 (15:26 +0000)
committerWilco Dijkstra <wilco.dijkstra@arm.com>
Thu, 16 Apr 2026 13:34:49 +0000 (13:34 +0000)
commitef044cc6d79c5646b521569417da890154ea1813
tree4329993743107713a33f565a47df7c5174fc9b9f
parent2f9fc3fba6562c888204159c09d654cb3499e38b
loongarch: Enable THP-aligned load segments by default on 64-bit

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
setting `glibc.elf.thp=1` during startup. Define the default THP
page size for load segment alignment on LoongArch64 as 32MB.

This allows the dynamic loader to apply THP-friendly alignment without
requiring the `glibc.elf.thp` tunable to be explicitly set.

Benchmarks

Machine: Loongson 3A6000 (LoongArch64)
Kernel: 6.18.13
  CONFIG_READ_ONLY_THP_FOR_FS=y
  CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=y

Workload 1: building Cargo 1.93.0
Rustc: nightly-2026-02-26

                Without patch        With patch
instructions    3,690,358,948,176    3,690,301,774,568
cpu-cycles      4,233,025,766,760    4,035,866,635,741
itlb-misses     9,708,829,532        2,700,014,717
time elapsed    302.40 s             289.68 s

Instructions remain essentially unchanged. iTLB misses drop by about
72%, reducing CPU cycles by about 4.7% and wall time by about 4.2%.

Workload 2: building Linux kernel v7.0-rc1
LLVM: 21.1.8

                Without patch        With patch
instructions    14,163,739,876,387   14,169,418,598,675
cpu-cycles      19,231,890,317,741   16,851,494,928,181
itlb-misses     91,142,010,440       90,779,245
time elapsed    1022.09 s            893.22 s

Instructions remain roughly the same. iTLB misses drop from about 91B
to about 90M (roughly 99.9% reduction), reducing CPU cycles by about
12% and wall time by about 12.6%.

Reviewed-by: caiyinyu <caiyinyu@loongson.cn>
Signed-off-by: WANG Rui <wangrui@loongson.cn>
sysdeps/unix/sysv/linux/loongarch/cpu-features.c
sysdeps/unix/sysv/linux/loongarch/lp64/dl-map-segment-align.h [new file with mode: 0644]