about summary refs log tree commit diff
path: root/sysdeps/x86/cpu-tunables.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-06-17 06:34:46 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-06-22 13:09:33 -0700
commitecbbadbf107ea1155ae5b71a8b7bd48f38c76731 (patch)
treeedc19a18074492532661cf40364d633ac39e75b8 /sysdeps/x86/cpu-tunables.c
parentea04f0213135b13d80f568ca2c4127c2ec112537 (diff)
downloadglibc-ecbbadbf107ea1155ae5b71a8b7bd48f38c76731.tar.gz
glibc-ecbbadbf107ea1155ae5b71a8b7bd48f38c76731.tar.xz
glibc-ecbbadbf107ea1155ae5b71a8b7bd48f38c76731.zip
x86: Update CPU feature detection [BZ #26149]
1. Divide architecture features into the usable features and the preferred
features.  The usable features are for correctness and can be exported in
a stable ABI.  The preferred features are for performance and only for
glibc internal use.
2. Change struct cpu_features to

struct cpu_features
{
  struct cpu_features_basic basic;
  unsigned int *usable_p;
  struct cpuid_registers cpuid[COMMON_CPUID_INDEX_MAX];
  unsigned int usable[USABLE_FEATURE_INDEX_MAX];
  unsigned int preferred[PREFERRED_FEATURE_INDEX_MAX];
  ...
};

and initialize usable_p to pointer to the usable arary so that

struct cpu_features
{
  struct cpu_features_basic basic;
  unsigned int *usable_p;
  struct cpuid_registers cpuid[COMMON_CPUID_INDEX_MAX];
};

can be exported via a stable ABI.  The cpuid and usable arrays can be
expanded with backward binary compatibility for both .o and .so files.
3. Add COMMON_CPUID_INDEX_7_ECX_1 for AVX512_BF16.
4. Detect ENQCMD, PKS, AVX512_VP2INTERSECT, MD_CLEAR, SERIALIZE, HYBRID,
TSXLDTRK, L1D_FLUSH, CORE_CAPABILITIES and AVX512_BF16.
5. Rename CAPABILITIES to ARCH_CAPABILITIES.
6. Check if AVX512_VP2INTERSECT, AVX512_BF16 and PKU are usable.
7. Update CPU feature detection test.
Diffstat (limited to 'sysdeps/x86/cpu-tunables.c')
-rw-r--r--sysdeps/x86/cpu-tunables.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sysdeps/x86/cpu-tunables.c b/sysdeps/x86/cpu-tunables.c
index 38ad2c2e84..666ec571f2 100644
--- a/sysdeps/x86/cpu-tunables.c
+++ b/sysdeps/x86/cpu-tunables.c
@@ -54,7 +54,7 @@ extern __typeof (memcmp) DEFAULT_MEMCMP;
   _Static_assert (sizeof (#name) - 1 == len, #name " != " #len);	\
   if (!DEFAULT_MEMCMP (f, #name, len))					\
     {									\
-      cpu_features->feature[index_arch_##name]				\
+      cpu_features->feature_##name[index_arch_##name]			\
 	&= ~bit_arch_##name;						\
       break;								\
     }
@@ -66,10 +66,10 @@ extern __typeof (memcmp) DEFAULT_MEMCMP;
   if (!DEFAULT_MEMCMP (f, #name, len))					\
     {									\
       if (disable)							\
-	cpu_features->feature[index_arch_##name]			\
+	cpu_features->feature_##name[index_arch_##name]			\
 	  &= ~bit_arch_##name;						\
       else								\
-	cpu_features->feature[index_arch_##name]			\
+	cpu_features->feature_##name[index_arch_##name]			\
 	  |= bit_arch_##name;						\
       break;								\
     }
@@ -82,10 +82,10 @@ extern __typeof (memcmp) DEFAULT_MEMCMP;
   if (!DEFAULT_MEMCMP (f, #name, len))					\
     {									\
       if (disable)							\
-	cpu_features->feature[index_arch_##name]			\
+	cpu_features->feature_##name[index_arch_##name]			\
 	  &= ~bit_arch_##name;						\
       else if (CPU_FEATURES_ARCH_P (cpu_features, need))		\
-	cpu_features->feature[index_arch_##name]			\
+	cpu_features->feature_##name[index_arch_##name]			\
 	  |= bit_arch_##name;						\
       break;								\
     }
@@ -98,10 +98,10 @@ extern __typeof (memcmp) DEFAULT_MEMCMP;
   if (!DEFAULT_MEMCMP (f, #name, len))					\
     {									\
       if (disable)							\
-	cpu_features->feature[index_arch_##name]			\
+	cpu_features->feature_##name[index_arch_##name]			\
 	  &= ~bit_arch_##name;						\
       else if (CPU_FEATURES_CPU_P (cpu_features, need))			\
-	cpu_features->feature[index_arch_##name]			\
+	cpu_features->feature_##name[index_arch_##name]			\
 	  |= bit_arch_##name;						\
       break;								\
     }