Rename the glibc.tune namespace to glibc.cpu

The glibc.tune namespace is vaguely named since it is a 'tunable', so
give it a more specific name that describes what it refers to.  Rename
the tunable namespace to 'cpu' to more accurately reflect what it
encompasses.  Also rename glibc.tune.cpu to glibc.cpu.name since
glibc.cpu.cpu is weird.

	* NEWS: Mention the change.
	* elf/dl-tunables.list: Rename tune namespace to cpu.
	* sysdeps/powerpc/dl-tunables.list: Likewise.
	* sysdeps/x86/dl-tunables.list: Likewise.
	* sysdeps/aarch64/dl-tunables.list: Rename tune.cpu to
	cpu.name.
	* elf/dl-hwcaps.c (_dl_important_hwcaps): Adjust.
	* elf/dl-hwcaps.h (GET_HWCAP_MASK): Likewise.
	* manual/README.tunables: Likewise.
	* manual/tunables.texi: Likewise.
	* sysdeps/powerpc/cpu-features.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/cpu-features.c
	(init_cpu_features): Likewise.
	* sysdeps/x86/cpu-features.c: Likewise.
	* sysdeps/x86/cpu-features.h: Likewise.
	* sysdeps/x86/cpu-tunables.c: Likewise.
	* sysdeps/x86_64/Makefile: Likewise.
	* sysdeps/x86/dl-cet.c: Likewise.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Siddhesh Poyarekar 2018-08-02 23:49:19 +05:30
parent 506d7fb1d4
commit dce452dc52
17 changed files with 46 additions and 45 deletions

3
NEWS
View File

@ -13,7 +13,8 @@ Major new features:
Deprecated and removed features, and other changes affecting compatibility: Deprecated and removed features, and other changes affecting compatibility:
[Add deprecations, removals and changes affecting compatibility here] * The glibc.tune tunable namespace has been renamed to glibc.cpu and the
tunable glibc.tune.cpu has been renamed to glibc.cpu.name.
Changes to build and runtime requirements: Changes to build and runtime requirements:

View File

@ -140,7 +140,7 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
string and bit like you can ignore an OS-supplied HWCAP bit. */ string and bit like you can ignore an OS-supplied HWCAP bit. */
hwcap_mask |= (uint64_t) mask << _DL_FIRST_EXTRA; hwcap_mask |= (uint64_t) mask << _DL_FIRST_EXTRA;
#if HAVE_TUNABLES #if HAVE_TUNABLES
TUNABLE_SET (glibc, tune, hwcap_mask, uint64_t, hwcap_mask); TUNABLE_SET (glibc, cpu, hwcap_mask, uint64_t, hwcap_mask);
#else #else
GLRO(dl_hwcap_mask) = hwcap_mask; GLRO(dl_hwcap_mask) = hwcap_mask;
#endif #endif

View File

@ -19,7 +19,7 @@
#include <elf/dl-tunables.h> #include <elf/dl-tunables.h>
#if HAVE_TUNABLES #if HAVE_TUNABLES
# define GET_HWCAP_MASK() TUNABLE_GET (glibc, tune, hwcap_mask, uint64_t, NULL) # define GET_HWCAP_MASK() TUNABLE_GET (glibc, cpu, hwcap_mask, uint64_t, NULL)
#else #else
# ifdef SHARED # ifdef SHARED
# define GET_HWCAP_MASK() GLRO(dl_hwcap_mask) # define GET_HWCAP_MASK() GLRO(dl_hwcap_mask)

View File

@ -86,7 +86,7 @@ glibc {
type: SIZE_T type: SIZE_T
} }
} }
tune { cpu {
hwcap_mask { hwcap_mask {
type: UINT_64 type: UINT_64
env_alias: LD_HWCAP_MASK env_alias: LD_HWCAP_MASK

View File

@ -105,11 +105,11 @@ where 'check' is the tunable name, 'int32_t' is the C type of the tunable and
To get and set tunables in a different namespace from that module, use the full To get and set tunables in a different namespace from that module, use the full
form of the macros as follows: form of the macros as follows:
val = TUNABLE_GET_FULL (glibc, tune, hwcap_mask, uint64_t, NULL) val = TUNABLE_GET_FULL (glibc, cpu, hwcap_mask, uint64_t, NULL)
TUNABLE_SET_FULL (glibc, tune, hwcap_mask, uint64_t, val) TUNABLE_SET_FULL (glibc, cpu, hwcap_mask, uint64_t, val)
where 'glibc' is the top namespace, 'tune' is the tunable namespace and the where 'glibc' is the top namespace, 'cpu' is the tunable namespace and the
remaining arguments are the same as the short form macros. remaining arguments are the same as the short form macros.
When TUNABLE_NAMESPACE is not defined in a module, TUNABLE_GET is equivalent to When TUNABLE_NAMESPACE is not defined in a module, TUNABLE_GET is equivalent to

View File

@ -295,23 +295,23 @@ The default value of this tunable is @samp{3}.
@cindex non_temporal_threshold tunables @cindex non_temporal_threshold tunables
@cindex tunables, non_temporal_threshold @cindex tunables, non_temporal_threshold
@deftp {Tunable namespace} glibc.tune @deftp {Tunable namespace} glibc.cpu
Behavior of @theglibc{} can be tuned to assume specific hardware capabilities Behavior of @theglibc{} can be tuned to assume specific hardware capabilities
by setting the following tunables in the @code{tune} namespace: by setting the following tunables in the @code{cpu} namespace:
@end deftp @end deftp
@deftp Tunable glibc.tune.hwcap_mask @deftp Tunable glibc.cpu.hwcap_mask
This tunable supersedes the @env{LD_HWCAP_MASK} environment variable and is This tunable supersedes the @env{LD_HWCAP_MASK} environment variable and is
identical in features. identical in features.
The @code{AT_HWCAP} key in the Auxiliary Vector specifies instruction set The @code{AT_HWCAP} key in the Auxiliary Vector specifies instruction set
extensions available in the processor at runtime for some architectures. The extensions available in the processor at runtime for some architectures. The
@code{glibc.tune.hwcap_mask} tunable allows the user to mask out those @code{glibc.cpu.hwcap_mask} tunable allows the user to mask out those
capabilities at runtime, thus disabling use of those extensions. capabilities at runtime, thus disabling use of those extensions.
@end deftp @end deftp
@deftp Tunable glibc.tune.hwcaps @deftp Tunable glibc.cpu.hwcaps
The @code{glibc.tune.hwcaps=-xxx,yyy,-zzz...} tunable allows the user to The @code{glibc.cpu.hwcaps=-xxx,yyy,-zzz...} tunable allows the user to
enable CPU/ARCH feature @code{yyy}, disable CPU/ARCH feature @code{xxx} enable CPU/ARCH feature @code{yyy}, disable CPU/ARCH feature @code{xxx}
and @code{zzz} where the feature name is case-sensitive and has to match and @code{zzz} where the feature name is case-sensitive and has to match
the ones in @code{sysdeps/x86/cpu-features.h}. the ones in @code{sysdeps/x86/cpu-features.h}.
@ -319,8 +319,8 @@ the ones in @code{sysdeps/x86/cpu-features.h}.
This tunable is specific to i386 and x86-64. This tunable is specific to i386 and x86-64.
@end deftp @end deftp
@deftp Tunable glibc.tune.cached_memopt @deftp Tunable glibc.cpu.cached_memopt
The @code{glibc.tune.cached_memopt=[0|1]} tunable allows the user to The @code{glibc.cpu.cached_memopt=[0|1]} tunable allows the user to
enable optimizations recommended for cacheable memory. If set to enable optimizations recommended for cacheable memory. If set to
@code{1}, @theglibc{} assumes that the process memory image consists @code{1}, @theglibc{} assumes that the process memory image consists
of cacheable (non-device) memory only. The default, @code{0}, of cacheable (non-device) memory only. The default, @code{0},
@ -329,8 +329,8 @@ indicates that the process may use device memory.
This tunable is specific to powerpc, powerpc64 and powerpc64le. This tunable is specific to powerpc, powerpc64 and powerpc64le.
@end deftp @end deftp
@deftp Tunable glibc.tune.cpu @deftp Tunable glibc.cpu.name
The @code{glibc.tune.cpu=xxx} tunable allows the user to tell @theglibc{} to The @code{glibc.cpu.name=xxx} tunable allows the user to tell @theglibc{} to
assume that the CPU is @code{xxx} where xxx may have one of these values: assume that the CPU is @code{xxx} where xxx may have one of these values:
@code{generic}, @code{falkor}, @code{thunderxt88}, @code{thunderx2t99}, @code{generic}, @code{falkor}, @code{thunderxt88}, @code{thunderx2t99},
@code{thunderx2t99p1}. @code{thunderx2t99p1}.
@ -338,27 +338,27 @@ assume that the CPU is @code{xxx} where xxx may have one of these values:
This tunable is specific to aarch64. This tunable is specific to aarch64.
@end deftp @end deftp
@deftp Tunable glibc.tune.x86_data_cache_size @deftp Tunable glibc.cpu.x86_data_cache_size
The @code{glibc.tune.x86_data_cache_size} tunable allows the user to set The @code{glibc.cpu.x86_data_cache_size} tunable allows the user to set
data cache size in bytes for use in memory and string routines. data cache size in bytes for use in memory and string routines.
This tunable is specific to i386 and x86-64. This tunable is specific to i386 and x86-64.
@end deftp @end deftp
@deftp Tunable glibc.tune.x86_shared_cache_size @deftp Tunable glibc.cpu.x86_shared_cache_size
The @code{glibc.tune.x86_shared_cache_size} tunable allows the user to The @code{glibc.cpu.x86_shared_cache_size} tunable allows the user to
set shared cache size in bytes for use in memory and string routines. set shared cache size in bytes for use in memory and string routines.
@end deftp @end deftp
@deftp Tunable glibc.tune.x86_non_temporal_threshold @deftp Tunable glibc.cpu.x86_non_temporal_threshold
The @code{glibc.tune.x86_non_temporal_threshold} tunable allows the user The @code{glibc.cpu.x86_non_temporal_threshold} tunable allows the user
to set threshold in bytes for non temporal store. to set threshold in bytes for non temporal store.
This tunable is specific to i386 and x86-64. This tunable is specific to i386 and x86-64.
@end deftp @end deftp
@deftp Tunable glibc.tune.x86_ibt @deftp Tunable glibc.cpu.x86_ibt
The @code{glibc.tune.x86_ibt} tunable allows the user to control how The @code{glibc.cpu.x86_ibt} tunable allows the user to control how
indirect branch tracking (IBT) should be enabled. Accepted values are indirect branch tracking (IBT) should be enabled. Accepted values are
@code{on}, @code{off}, and @code{permissive}. @code{on} always turns @code{on}, @code{off}, and @code{permissive}. @code{on} always turns
on IBT regardless of whether IBT is enabled in the executable and its on IBT regardless of whether IBT is enabled in the executable and its
@ -370,8 +370,8 @@ IBT on non-CET executables and shared libraries.
This tunable is specific to i386 and x86-64. This tunable is specific to i386 and x86-64.
@end deftp @end deftp
@deftp Tunable glibc.tune.x86_shstk @deftp Tunable glibc.cpu.x86_shstk
The @code{glibc.tune.x86_shstk} tunable allows the user to control how The @code{glibc.cpu.x86_shstk} tunable allows the user to control how
the shadow stack (SHSTK) should be enabled. Accepted values are the shadow stack (SHSTK) should be enabled. Accepted values are
@code{on}, @code{off}, and @code{permissive}. @code{on} always turns on @code{on}, @code{off}, and @code{permissive}. @code{on} always turns on
SHSTK regardless of whether SHSTK is enabled in the executable and its SHSTK regardless of whether SHSTK is enabled in the executable and its

View File

@ -17,8 +17,8 @@
# <http://www.gnu.org/licenses/>. # <http://www.gnu.org/licenses/>.
glibc { glibc {
tune { cpu {
cpu { name {
type: STRING type: STRING
} }
} }

View File

@ -30,7 +30,7 @@ init_cpu_features (struct cpu_features *cpu_features)
tunables is enable, since for this case user can explicit disable tunables is enable, since for this case user can explicit disable
unaligned optimizations. */ unaligned optimizations. */
#if HAVE_TUNABLES #if HAVE_TUNABLES
int32_t cached_memfunc = TUNABLE_GET (glibc, tune, cached_memopt, int32_t, int32_t cached_memfunc = TUNABLE_GET (glibc, cpu, cached_memopt, int32_t,
NULL); NULL);
cpu_features->use_cached_memopt = (cached_memfunc > 0); cpu_features->use_cached_memopt = (cached_memfunc > 0);
#else #else

View File

@ -17,7 +17,7 @@
# <http://www.gnu.org/licenses/>. # <http://www.gnu.org/licenses/>.
glibc { glibc {
tune { cpu {
cached_memopt { cached_memopt {
type: INT_32 type: INT_32
minval: 0 minval: 0

View File

@ -57,7 +57,7 @@ init_cpu_features (struct cpu_features *cpu_features)
#if HAVE_TUNABLES #if HAVE_TUNABLES
/* Get the tunable override. */ /* Get the tunable override. */
const char *mcpu = TUNABLE_GET (glibc, tune, cpu, const char *, NULL); const char *mcpu = TUNABLE_GET (glibc, cpu, name, const char *, NULL);
if (mcpu != NULL) if (mcpu != NULL)
midr = get_midr_from_mcpu (mcpu); midr = get_midr_from_mcpu (mcpu);
#endif #endif

View File

@ -47,13 +47,13 @@ $(objpfx)tst-cet-legacy-4.out: $(objpfx)tst-cet-legacy-mod-4.so
ifneq (no,$(have-tunables)) ifneq (no,$(have-tunables))
$(objpfx)tst-cet-legacy-4a: $(libdl) $(objpfx)tst-cet-legacy-4a: $(libdl)
$(objpfx)tst-cet-legacy-4a.out: $(objpfx)tst-cet-legacy-mod-4.so $(objpfx)tst-cet-legacy-4a.out: $(objpfx)tst-cet-legacy-mod-4.so
tst-cet-legacy-4a-ENV = GLIBC_TUNABLES=glibc.tune.x86_shstk=permissive tst-cet-legacy-4a-ENV = GLIBC_TUNABLES=glibc.cpu.x86_shstk=permissive
$(objpfx)tst-cet-legacy-4b: $(libdl) $(objpfx)tst-cet-legacy-4b: $(libdl)
$(objpfx)tst-cet-legacy-4b.out: $(objpfx)tst-cet-legacy-mod-4.so $(objpfx)tst-cet-legacy-4b.out: $(objpfx)tst-cet-legacy-mod-4.so
tst-cet-legacy-4b-ENV = GLIBC_TUNABLES=glibc.tune.x86_shstk=on tst-cet-legacy-4b-ENV = GLIBC_TUNABLES=glibc.cpu.x86_shstk=on
$(objpfx)tst-cet-legacy-4c: $(libdl) $(objpfx)tst-cet-legacy-4c: $(libdl)
$(objpfx)tst-cet-legacy-4c.out: $(objpfx)tst-cet-legacy-mod-4.so $(objpfx)tst-cet-legacy-4c.out: $(objpfx)tst-cet-legacy-mod-4.so
tst-cet-legacy-4c-ENV = GLIBC_TUNABLES=glibc.tune.x86_shstk=off tst-cet-legacy-4c-ENV = GLIBC_TUNABLES=glibc.cpu.x86_shstk=off
endif endif
endif endif

View File

@ -22,7 +22,7 @@
#include <libc-pointer-arith.h> #include <libc-pointer-arith.h>
#if HAVE_TUNABLES #if HAVE_TUNABLES
# define TUNABLE_NAMESPACE tune # define TUNABLE_NAMESPACE cpu
# include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */ # include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */
# include <elf/dl-tunables.h> # include <elf/dl-tunables.h>
@ -419,7 +419,7 @@ no_cpuid:
/* Reuse dl_platform, dl_hwcap and dl_hwcap_mask for x86. */ /* Reuse dl_platform, dl_hwcap and dl_hwcap_mask for x86. */
#if !HAVE_TUNABLES && defined SHARED #if !HAVE_TUNABLES && defined SHARED
/* The glibc.tune.hwcap_mask tunable is initialized already, so no need to do /* The glibc.cpu.hwcap_mask tunable is initialized already, so no need to do
this. */ this. */
GLRO(dl_hwcap_mask) = HWCAP_IMPORTANT; GLRO(dl_hwcap_mask) = HWCAP_IMPORTANT;
#endif #endif
@ -494,7 +494,7 @@ no_cpuid:
/* Disable IBT and/or SHSTK if they are enabled by kernel, but /* Disable IBT and/or SHSTK if they are enabled by kernel, but
disabled by environment variable: disabled by environment variable:
GLIBC_TUNABLES=glibc.tune.hwcaps=-IBT,-SHSTK GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
*/ */
unsigned int cet_feature = 0; unsigned int cet_feature = 0;
if (!HAS_CPU_FEATURE (IBT)) if (!HAS_CPU_FEATURE (IBT))

View File

@ -141,7 +141,7 @@ struct cpu_features
unsigned long int xsave_state_size; unsigned long int xsave_state_size;
/* The full state size for XSAVE when XSAVEC is disabled by /* The full state size for XSAVE when XSAVEC is disabled by
GLIBC_TUNABLES=glibc.tune.hwcaps=-XSAVEC_Usable GLIBC_TUNABLES=glibc.cpu.hwcaps=-XSAVEC_Usable
*/ */
unsigned int xsave_state_full_size; unsigned int xsave_state_full_size;
unsigned int feature[FEATURE_INDEX_MAX]; unsigned int feature[FEATURE_INDEX_MAX];

View File

@ -17,7 +17,7 @@
<http://www.gnu.org/licenses/>. */ <http://www.gnu.org/licenses/>. */
#if HAVE_TUNABLES #if HAVE_TUNABLES
# define TUNABLE_NAMESPACE tune # define TUNABLE_NAMESPACE cpu
# include <stdbool.h> # include <stdbool.h>
# include <stdint.h> # include <stdint.h>
# include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */ # include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */
@ -116,7 +116,7 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
the hardware which wasn't available when the selection was made. the hardware which wasn't available when the selection was made.
The environment variable: The environment variable:
GLIBC_TUNABLES=glibc.tune.hwcaps=-xxx,yyy,-zzz,.... GLIBC_TUNABLES=glibc.cpu.hwcaps=-xxx,yyy,-zzz,....
can be used to enable CPU/ARCH feature yyy, disable CPU/ARCH feature can be used to enable CPU/ARCH feature yyy, disable CPU/ARCH feature
yyy and zzz, where the feature name is case-sensitive and has to yyy and zzz, where the feature name is case-sensitive and has to

View File

@ -128,7 +128,7 @@ dl_cet_check (struct link_map *m, const char *program)
/* Enable IBT and SHSTK only if they are enabled in executable. /* Enable IBT and SHSTK only if they are enabled in executable.
NB: IBT and SHSTK may be disabled by environment variable: NB: IBT and SHSTK may be disabled by environment variable:
GLIBC_TUNABLES=glibc.tune.hwcaps=-IBT,-SHSTK GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
*/ */
enable_ibt &= (HAS_CPU_FEATURE (IBT) enable_ibt &= (HAS_CPU_FEATURE (IBT)
&& (enable_ibt_type == CET_ALWAYS_ON && (enable_ibt_type == CET_ALWAYS_ON

View File

@ -17,7 +17,7 @@
# <http://www.gnu.org/licenses/>. # <http://www.gnu.org/licenses/>.
glibc { glibc {
tune { cpu {
hwcaps { hwcaps {
type: STRING type: STRING
} }

View File

@ -57,7 +57,7 @@ modules-names += x86_64/tst-x86_64mod-1
LDFLAGS-tst-x86_64mod-1.so = -Wl,-soname,tst-x86_64mod-1.so LDFLAGS-tst-x86_64mod-1.so = -Wl,-soname,tst-x86_64mod-1.so
ifneq (no,$(have-tunables)) ifneq (no,$(have-tunables))
# Test the state size for XSAVE when XSAVEC is disabled. # Test the state size for XSAVE when XSAVEC is disabled.
tst-x86_64-1-ENV = GLIBC_TUNABLES=glibc.tune.hwcaps=-XSAVEC_Usable tst-x86_64-1-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-XSAVEC_Usable
endif endif
$(objpfx)tst-x86_64-1: $(objpfx)x86_64/tst-x86_64mod-1.so $(objpfx)tst-x86_64-1: $(objpfx)x86_64/tst-x86_64mod-1.so
@ -74,7 +74,7 @@ $(objpfx)tst-platform-1.out: $(objpfx)x86_64/tst-platformmod-2.so
# Turn off AVX512F_Usable and AVX2_Usable so that GLRO(dl_platform) is # Turn off AVX512F_Usable and AVX2_Usable so that GLRO(dl_platform) is
# always set to x86_64. # always set to x86_64.
tst-platform-1-ENV = LD_PRELOAD=$(objpfx)\$$PLATFORM/tst-platformmod-2.so \ tst-platform-1-ENV = LD_PRELOAD=$(objpfx)\$$PLATFORM/tst-platformmod-2.so \
GLIBC_TUNABLES=glibc.tune.hwcaps=-AVX512F_Usable,-AVX2_Usable GLIBC_TUNABLES=glibc.cpu.hwcaps=-AVX512F_Usable,-AVX2_Usable
endif endif
tests += tst-audit3 tst-audit4 tst-audit5 tst-audit6 tst-audit7 \ tests += tst-audit3 tst-audit4 tst-audit5 tst-audit6 tst-audit7 \