[PATCH 2/3] Add --with-test-tunables configure option

Yury Khrustalev yury.khrustalev@arm.com
Fri Nov 6 10:42:19 GMT 2026


Some tests use test-specific tunables defined in makefiles via

  tst-name-TUNABLES += value

In some use cases it may be necessary to use global tunable value
for all tests that don't override them. This was only possible via
using the GLIBC_TUNABLES environment variable. However, this will
affect every wrapper process used to run a test which might not
be desirable. To solve this, we introduce new configure option

  --with-test-tunables=value

This option allows to set global tunable value to be used by tests.
By default, this value is empty.

The resulting tunable string is formed from:

  1. Configure option --with-test-tunables=value
  2. Ambient environment variable GLIBC_TUNABLES
  3. Test-specific tunables

The order is important because tunables appearing later in the line
will take precedence over prior tunables in case there is the same
tunable mention more than once with different values.

Ultimately, the test process will receive an appropriate environment
variable GLIBC_TUNABLES. At this point, the tunables will be consumed
by the process and usual rules (including making use of the system-
wide tunables) will apply.
---
 INSTALL                                       |  6 +++++
 NEWS                                          |  2 ++
 Rules                                         | 11 +++++----
 config.make.in                                |  1 +
 configure                                     | 17 +++++++++++++
 configure.ac                                  | 10 ++++++++
 manual/install.texi                           |  6 +++++
 sysdeps/unix/sysv/linux/aarch64/Makefile      |  8 +++----
 .../sysv/linux/aarch64/tst-thp-size-mod.S     | 24 +++++++++++++++++++
 .../unix/sysv/linux/aarch64/tst-thp-size.S    | 22 +++++++++++++++++
 10 files changed, 99 insertions(+), 8 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/aarch64/tst-thp-size-mod.S
 create mode 100644 sysdeps/unix/sysv/linux/aarch64/tst-thp-size.S

diff --git a/INSTALL b/INSTALL
index 0f3745d3b2..ccceec28ae 100644
--- a/INSTALL
+++ b/INSTALL
@@ -124,6 +124,12 @@ passed to 'configure'.  For example:
      factor can be changed at run time using 'TIMEOUTFACTOR' environment
      variable.
 
+'--with-test-tunables=VALUE'
+     Specify Glibc tunables that should be passed to all tests. Each test
+     will receive tunables from this value followed by the value of the
+     optional environment variable @var{GLIBC_TUNABLES} followed by any
+     test-specific tunables.
+
 '--disable-shared'
      Don't build shared libraries even if it is possible.  Not all
      systems support shared libraries; you need ELF support and
diff --git a/NEWS b/NEWS
index eee1e44a92..e53ac42506 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ Major new features:
 
 * Additional optimized and correctly rounded mathematical functions have
   been imported from the CORE-MATH project, in particular cbrt.
+* Added new configure option --with-test-tunables to support passing Glibc
+  tunables that should be used by most tests.
 
 Deprecated and removed features, and other changes affecting compatibility:
 
diff --git a/Rules b/Rules
index 1a2df1ed12..b7dc5ff856 100644
--- a/Rules
+++ b/Rules
@@ -381,14 +381,17 @@ $(foreach t,$(tests-malloc-check),$(eval $(call malloc-check-ENVS,$(t))))
 
 # Generate environment variable GLIBC_TUNABLES to be appended to
 # the test environment, appending tunables specifically added for
-# each test to the ambient GLIBC_TUNABLES environment variable.
-# The *-TUNABLES-only can be used by a test to override any ambient
+# each test to the ambient GLIBC_TUNABLES environment variable
+# and global set of tunables set at configure time via the parameter
+# --with-test-tunables. The ambient environment variable overrides
+# configure parameter and per-test tunable override any global tunables.
+# The *-TUNABLES-only can be used by a test to replace any ambient
 # tunables.
 define test-tun-joined
-$(subst $(empty) ,:,$(strip $($*-TUNABLES)))
+$(subst $(empty) ,:,$(strip $(test-tunables-value) $(GLIBC_TUNABLES) $($*-TUNABLES)))
 endef
 define test-tunables-all
-$(if $($*-TUNABLES),$(if $(GLIBC_TUNABLES),GLIBC_TUNABLES=$(GLIBC_TUNABLES):$(test-tun-joined),GLIBC_TUNABLES=$(test-tun-joined)),)
+$(if $(test-tun-joined),GLIBC_TUNABLES=$(test-tun-joined))
 endef
 define test-tunables-only
 GLIBC_TUNABLES=$(subst $(empty) ,:,$(strip $($*-TUNABLES-only)))
diff --git a/config.make.in b/config.make.in
index 8b467a2efd..ce650a6617 100644
--- a/config.make.in
+++ b/config.make.in
@@ -88,6 +88,7 @@ use-nscd = @use_nscd@
 build-hardcoded-path-in-tests= @hardcoded_path_in_tests@
 build-pt-chown = @build_pt_chown@
 man-pages-version = @man_pages_version@
+test-tunables-value = @test_tunables_value@
 
 # Build tools.
 CC = @CC@
diff --git a/configure b/configure
index 604279533a..e6845ce495 100755
--- a/configure
+++ b/configure
@@ -707,6 +707,7 @@ force_install
 bindnow
 hardcoded_path_in_tests
 enable_timezone_tools
+test_tunables_value
 man_pages_version
 rtld_early_cflags
 extra_nonshared_cflags
@@ -794,6 +795,7 @@ with_nonshared_cflags
 with_rtld_early_cflags
 with_timeoutfactor
 with_man_pages
+with_test_tunables
 enable_sanity_checks
 enable_shared
 enable_profile
@@ -1521,6 +1523,9 @@ Optional Packages:
                           specify an integer to scale the timeout
   --with-man-pages=VERSION
                           tie manual to a specific man-pages version
+  --with-test-tunables=VALUE
+                          specify tunables to be used for all tests unless
+                          overridden
   --with-cpu=CPU          select code for CPU variant
 
 Some influential environment variables:
@@ -4509,6 +4514,18 @@ fi
 
 
 
+test_tunables_value=""
+
+
+# Check whether --with-test-tunables was given.
+if test ${with_test_tunables+y}
+then :
+  withval=$with_test_tunables; test_tunables_value=$withval
+fi
+
+
+
+
 # Check whether --enable-sanity-checks was given.
 if test ${enable_sanity_checks+y}
 then :
diff --git a/configure.ac b/configure.ac
index 2fe7980fc9..1990e4b6f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -206,6 +206,16 @@ AC_ARG_WITH([man-pages],
 	    [])
 AC_SUBST(man_pages_version)
 
+test_tunables_value=""
+
+AC_ARG_WITH([test-tunables],
+	    AS_HELP_STRING([--with-test-tunables=VALUE],
+			   [specify tunables to be used for all tests unless overridden]),
+	    [test_tunables_value=$withval],
+	    [])
+AC_SUBST(test_tunables_value)
+
+
 AC_ARG_ENABLE([sanity-checks],
 	      AS_HELP_STRING([--disable-sanity-checks],
 			     [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
diff --git a/manual/install.texi b/manual/install.texi
index e2f45b8e6f..ca1b42eaee 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -151,6 +151,12 @@ Specify an integer @var{NUM} to scale the timeout of test programs.
 This factor can be changed at run time using @env{TIMEOUTFACTOR}
 environment variable.
 
+@item --with-test-tunables=@var{VALUE}
+Specify Glibc tunables that should be passed to all tests. Each test will
+receive tunables from this value followed by the value of the optional
+environment variable @env{GLIBC_TUNABLES} followed by any test-specific
+tunables (@pxref{Tunables}).
+
 @c disable static doesn't work currently
 @c @item --disable-static
 @c Don't build static libraries.  Static libraries aren't that useful these
diff --git a/sysdeps/unix/sysv/linux/aarch64/Makefile b/sysdeps/unix/sysv/linux/aarch64/Makefile
index 2507452577..a292fffc44 100644
--- a/sysdeps/unix/sysv/linux/aarch64/Makefile
+++ b/sysdeps/unix/sysv/linux/aarch64/Makefile
@@ -105,7 +105,7 @@ tst-bti-dep-prot-preload-TUNABLES += glibc.cpu.aarch64_bti=0
 
 $(objpfx)tst-bti-permissive-preload.out: $(objpfx)tst-bti-mod-unprot-preload.so
 tst-bti-permissive-preload-ENV = LD_PRELOAD=$(objpfx)tst-bti-mod-unprot-preload.so
-tst-bti-permissive-preload-TUNABLES += glibc.cpu.aarch64_bti=0
+tst-bti-permissive-preload-TUNABLES-only += glibc.cpu.aarch64_bti=0
 
 CFLAGS-tst-bti-abort-unprot.o += -mbranch-protection=none
 CFLAGS-tst-bti-ld-debug-exe.o += -mbranch-protection=none
@@ -122,8 +122,8 @@ tst-bti-dlopen-imm-TUNABLES += glibc.cpu.aarch64_bti=1
 tst-bti-dlopen-prot-TUNABLES += glibc.cpu.aarch64_bti=1
 tst-bti-dlopen-transitive-TUNABLES += glibc.cpu.aarch64_bti=1
 
-tst-bti-permissive-imm-TUNABLES += glibc.cpu.aarch64_bti=0
-tst-bti-permissive-transitive-TUNABLES += glibc.cpu.aarch64_bti=0
+tst-bti-permissive-imm-TUNABLES-only += glibc.cpu.aarch64_bti=0
+tst-bti-permissive-transitive-TUNABLES-only += glibc.cpu.aarch64_bti=0
 tst-bti-permissive-dlopen-TUNABLES-only = glibc.cpu.aarch64_bti=0
 
 $(objpfx)tst-bti-unprot-audit.out: $(objpfx)tst-bti-mod-unprot-audit.so
@@ -133,7 +133,7 @@ $(objpfx)tst-bti-prot-audit.out: $(objpfx)tst-bti-mod-prot-audit.so
 $(objpfx)tst-bti-prot-audit: $(objpfx)tst-bti-mod-prot.so
 tst-bti-prot-audit-ARGS = -- $(host-test-program-cmd)
 
-tst-bti-permissive-audit-TUNABLES += glibc.cpu.aarch64_bti=0
+tst-bti-permissive-audit-TUNABLES-only += glibc.cpu.aarch64_bti=0
 $(objpfx)tst-bti-permissive-audit.out: $(objpfx)tst-bti-mod-unprot-audit.so
 $(objpfx)tst-bti-permissive-audit: $(objpfx)tst-bti-mod.so
 tst-bti-permissive-audit-ARGS = -- $(host-test-program-cmd)
diff --git a/sysdeps/unix/sysv/linux/aarch64/tst-thp-size-mod.S b/sysdeps/unix/sysv/linux/aarch64/tst-thp-size-mod.S
new file mode 100644
index 0000000000..ed8c90e511
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/tst-thp-size-mod.S
@@ -0,0 +1,24 @@
+/* A module that provides THP code size for testing.
+
+   Copyright (C) 2026 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+    .globl thp_size
+thp_size:
+    .space 32 * 1024 * 1024
diff --git a/sysdeps/unix/sysv/linux/aarch64/tst-thp-size.S b/sysdeps/unix/sysv/linux/aarch64/tst-thp-size.S
new file mode 100644
index 0000000000..e6ed9e36c3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/tst-thp-size.S
@@ -0,0 +1,22 @@
+/* A file that provides THP code size for testing.
+   Copyright (C) 2026 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+	.text
+	.space 2 * THP_PAGE_SIZE
-- 
2.47.3



More information about the Libc-alpha mailing list