x86: Use __get_cpu_features to get cpu_features

Message ID CAMe9rOrhykpr2VKmy2UuG33+5XNBLN7dvz9VjAcSG9gxbv0Jsg@mail.gmail.com
State New, archived
Headers

Commit Message

H.J. Lu May 24, 2017, 1:29 p.m. UTC
  On Tue, May 23, 2017 at 10:09 PM, Siddhesh Poyarekar
<siddhesh@gotplt.org> wrote:
> On Wednesday 24 May 2017 08:33 AM, H.J. Lu wrote:
>> Remove is_intel, is_amd and max_cpuid macros.  Use __get_cpu_features
>> to get cpu_features instead.
>
> LGTM.
>

This is what I checked in.

Thanks.
  

Patch

From a8b869ab948080c7821825503ad6a7fadfd77706 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 23 May 2017 19:56:43 -0700
Subject: [PATCH] x86: Use __get_cpu_features to get cpu_features

Remove is_intel, is_amd and max_cpuid macros.  Use __get_cpu_features
to get cpu_features instead.

	* sysdeps/x86/cacheinfo.c (is_intel): Removed.
	(is_amd): Likewise.
	(max_cpuid): Likewise.
	(__cache_sysconf): Use __get_cpu_features to get cpu_features.
	(init_cacheinfo): Likewise.
---
 sysdeps/x86/cacheinfo.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/sysdeps/x86/cacheinfo.c b/sysdeps/x86/cacheinfo.c
index 1ccbe41..4594a2f 100644
--- a/sysdeps/x86/cacheinfo.c
+++ b/sysdeps/x86/cacheinfo.c
@@ -23,10 +23,6 @@ 
 #include <cpuid.h>
 #include <init-arch.h>
 
-#define is_intel GLRO(dl_x86_cpu_features).kind == arch_kind_intel
-#define is_amd GLRO(dl_x86_cpu_features).kind == arch_kind_amd
-#define max_cpuid GLRO(dl_x86_cpu_features).max_cpuid
-
 static const struct intel_02_cache_info
 {
   unsigned char idx;
@@ -436,10 +432,12 @@  long int
 attribute_hidden
 __cache_sysconf (int name)
 {
-  if (is_intel)
-    return handle_intel (name, max_cpuid);
+  const struct cpu_features *cpu_features = __get_cpu_features ();
+
+  if (cpu_features->kind == arch_kind_intel)
+    return handle_intel (name, cpu_features->max_cpuid);
 
-  if (is_amd)
+  if (cpu_features->kind == arch_kind_amd)
     return handle_amd (name);
 
   // XXX Fill in more vendors.
@@ -489,8 +487,10 @@  init_cacheinfo (void)
   long int shared = -1;
   unsigned int level;
   unsigned int threads = 0;
+  const struct cpu_features *cpu_features = __get_cpu_features ();
+  int max_cpuid = cpu_features->max_cpuid;
 
-  if (is_intel)
+  if (cpu_features->kind == arch_kind_intel)
     {
       data = handle_intel (_SC_LEVEL1_DCACHE_SIZE, max_cpuid);
 
@@ -691,8 +691,7 @@  intel_bug_no_cache_info:
 	  shared += core;
 	}
     }
-  /* This spells out "AuthenticAMD".  */
-  else if (is_amd)
+  else if (cpu_features->kind == arch_kind_amd)
     {
       data   = handle_amd (_SC_LEVEL1_DCACHE_SIZE);
       long int core = handle_amd (_SC_LEVEL2_CACHE_SIZE);
-- 
2.9.4