Commit-ID:  8dfeae0d73bf803be1a533e147b3b0ea69375596
Gitweb:     http://git.kernel.org/tip/8dfeae0d73bf803be1a533e147b3b0ea69375596
Author:     Huang Rui <[email protected]>
AuthorDate: Thu, 14 Jan 2016 10:50:04 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 21 Mar 2016 09:08:22 +0100

perf/x86/amd: Move nodes_per_socket into bsp_init_amd()

nodes_per_socket is static and it needn't be initialized many
times during every CPU core init. So move its initialization into
bsp_init_amd().

Signed-off-by: Huang Rui <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Cc: Aaron Lu <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andreas Herrmann <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Aravind Gopalakrishnan <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: Fengguang Wu <[email protected]>
Cc: Frédéric Weisbecker <[email protected]>
Cc: Guenter Roeck <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Hector Marco-Gisbert <[email protected]>
Cc: Jacob Shin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: John Stultz <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Robert Richter <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vince Weaver <[email protected]>
Cc: [email protected]
Link: 
http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
 arch/x86/kernel/cpu/amd.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index b39338c..d4b06e8 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -306,7 +306,6 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
                u32 eax, ebx, ecx, edx;
 
                cpuid(0x8000001e, &eax, &ebx, &ecx, &edx);
-               nodes_per_socket = ((ecx >> 8) & 7) + 1;
                node_id = ecx & 7;
 
                /* get compute unit information */
@@ -317,7 +316,6 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
                u64 value;
 
                rdmsrl(MSR_FAM10H_NODE_ID, value);
-               nodes_per_socket = ((value >> 3) & 7) + 1;
                node_id = value & 7;
        } else
                return;
@@ -519,6 +517,18 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)
 
        if (cpu_has(c, X86_FEATURE_MWAITX))
                use_mwaitx_delay();
+
+       if (boot_cpu_has(X86_FEATURE_TOPOEXT)) {
+               u32 ecx;
+
+               ecx = cpuid_ecx(0x8000001e);
+               nodes_per_socket = ((ecx >> 8) & 7) + 1;
+       } else if (boot_cpu_has(X86_FEATURE_NODEID_MSR)) {
+               u64 value;
+
+               rdmsrl(MSR_FAM10H_NODE_ID, value);
+               nodes_per_socket = ((value >> 3) & 7) + 1;
+       }
 }
 
 static void early_init_amd(struct cpuinfo_x86 *c)

Reply via email to