[PATCH v2] tests: Remove target-specific huge-page size definition for THP-aware load segment alignment
Xi Ruoyao
xry111@xry111.site
Sat Aug 1 21:09:53 GMT 2026
On MIPS64 and AArch64 systems with 16-KiB pages, the PMD size is 32MB.
As we already have multiple platforms requiring such a large size and
it's the maximum THP size we support to align the load segments, it's
easier to raise the default instead of adding more special cases.
Link: https://sourceware.org/glibc/wiki/Testing/Tests/elf/tst-thp-1
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
---
Tested on aarch64-linux with a 16 KiB page kernel.
sysdeps/unix/sysv/linux/Makefile | 16 ++++++----------
sysdeps/unix/sysv/linux/loongarch/Makefile | 3 ---
sysdeps/unix/sysv/linux/sparc/Makefile | 5 -----
sysdeps/unix/sysv/linux/tst-thp-size.S | 4 +++-
4 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 14a56d5cc3..34856a3b2f 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -730,21 +730,17 @@ tests-special += \
# tests-special
endif
-ifndef THP-PAGE-SIZE
# Align PT_LOAD segments in THP tests to THP page size so that kernel will
-# map PIE to the address aligned to THP page size. Default THP page size
-# to 2MB which can be overridden in Makefile in subdirectories.
-THP-PAGE-SIZE = 0x200000
-endif
-
-THP-PAGE-SIZE-CFLAGS = -DTHP_PAGE_SIZE=$(THP-PAGE-SIZE)
-THP-PAGE-SIZE-LDFLAGS = -Wl,-z,max-page-size=$(THP-PAGE-SIZE)
+# map PIE to the address aligned to THP page size. The maximum THP size we
+# support to align the load segments (and we skip the tests with even
+# larger THP) is 32 MiB.
+THP-PAGE-SIZE-LDFLAGS = -Wl,-z,max-page-size=0x2000000
-# -Wl,-z,max-page-size=$(THP-PAGE-SIZE) alone doesn't work for PDE when
+# -Wl,-z,max-page-size=0x2000000 alone doesn't work for PDE when
# text-segment address is lower than the maximum page size:
# https://sourceware.org/bugzilla/show_bug.cgi?id=34184
ifneq (,$(load-address-ldflag))
-LOAD-THP-ADDRESS-LDFLAGS = $(load-address-ldflag)=$(THP-PAGE-SIZE)
+LOAD-THP-ADDRESS-LDFLAGS = $(load-address-ldflag)=0x2000000
endif
LDFLAGS-tst-thp-size-mod.so = -Wl,-z,noseparate-code \
diff --git a/sysdeps/unix/sysv/linux/loongarch/Makefile b/sysdeps/unix/sysv/linux/loongarch/Makefile
index d5beb62440..0d5f087862 100644
--- a/sysdeps/unix/sysv/linux/loongarch/Makefile
+++ b/sysdeps/unix/sysv/linux/loongarch/Makefile
@@ -12,6 +12,3 @@ abi-ilp32s-condition := __WORDSIZE == 32 && defined __loongarch_soft_float
abi-ilp32d-condition := __WORDSIZE == 32 && defined __loongarch_double_float
abi-lp64s-condition := __WORDSIZE == 64 && defined __loongarch_soft_float
abi-lp64d-condition := __WORDSIZE == 64 && defined __loongarch_double_float
-
-# Align THP tests to 32MB.
-THP-PAGE-SIZE = 0x2000000
diff --git a/sysdeps/unix/sysv/linux/sparc/Makefile b/sysdeps/unix/sysv/linux/sparc/Makefile
index 57e73d0a14..e0056c9413 100644
--- a/sysdeps/unix/sysv/linux/sparc/Makefile
+++ b/sysdeps/unix/sysv/linux/sparc/Makefile
@@ -14,8 +14,3 @@ endif
ifeq ($(subdir),signal)
sysdep_routines += sigreturn_stub
endif
-
-ifeq ($(subdir),elf)
-# The sparc64 uses an 8KB base page and 8MB PMD transparent huge page
-THP-PAGE-SIZE = 0x800000
-endif
diff --git a/sysdeps/unix/sysv/linux/tst-thp-size.S b/sysdeps/unix/sysv/linux/tst-thp-size.S
index 29c5f4e750..154b167509 100644
--- a/sysdeps/unix/sysv/linux/tst-thp-size.S
+++ b/sysdeps/unix/sysv/linux/tst-thp-size.S
@@ -17,4 +17,6 @@
<https://www.gnu.org/licenses/>. */
.text
- .space 2 * THP_PAGE_SIZE
+ /* 64 MiB, twice of MAX_THP_PAGESIZE in dl-map-segment-align.h and
+ tst-thp-align.c */
+ .space 0x4000000
--
2.55.0
More information about the Libc-alpha
mailing list