提交 ee6825c8 编写于 作者: P Peter Zijlstra 提交者: Thomas Gleixner

x86/topology: Fix AMD core count

It turns out AMD gets x86_max_cores wrong when there are compute
units.

The issue is that Linux assumes:

	nr_logical_cpus = nr_cores * nr_siblings

But AMD reports its CU unit as 2 cores, but then sets num_smp_siblings
to 2 as well.

Boris: fixup ras/mce_amd_inj.c too, to compute the Node Base Core
properly, according to the new nomenclature.

Fixes: 1f12e32f ("x86/topology: Create logical package id")
Reported-by: NXiong Zhou <jencce.kernel@gmail.com>
Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: NBorislav Petkov <bp@suse.de>
Cc: Andreas Herrmann <aherrmann@suse.com>
Cc: Andy Lutomirski <luto@kernel.org>
Link: http://lkml.kernel.org/r/20160317095220.GO6344@twins.programming.kicks-ass.netSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
上级 f55532a0
...@@ -155,6 +155,7 @@ static inline int wbinvd_on_all_cpus(void) ...@@ -155,6 +155,7 @@ static inline int wbinvd_on_all_cpus(void)
wbinvd(); wbinvd();
return 0; return 0;
} }
#define smp_num_siblings 1
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
extern unsigned disabled_cpus; extern unsigned disabled_cpus;
......
...@@ -312,9 +312,9 @@ static void amd_get_topology(struct cpuinfo_x86 *c) ...@@ -312,9 +312,9 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
node_id = ecx & 7; node_id = ecx & 7;
/* get compute unit information */ /* get compute unit information */
smp_num_siblings = ((ebx >> 8) & 3) + 1; cores_per_cu = smp_num_siblings = ((ebx >> 8) & 3) + 1;
c->x86_max_cores /= smp_num_siblings;
c->compute_unit_id = ebx & 0xff; c->compute_unit_id = ebx & 0xff;
cores_per_cu += ((ebx >> 8) & 3);
} else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) { } else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) {
u64 value; u64 value;
...@@ -329,8 +329,8 @@ static void amd_get_topology(struct cpuinfo_x86 *c) ...@@ -329,8 +329,8 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
u32 cus_per_node; u32 cus_per_node;
set_cpu_cap(c, X86_FEATURE_AMD_DCM); set_cpu_cap(c, X86_FEATURE_AMD_DCM);
cores_per_node = c->x86_max_cores / nodes_per_socket; cus_per_node = c->x86_max_cores / nodes_per_socket;
cus_per_node = cores_per_node / cores_per_cu; cores_per_node = cus_per_node * cores_per_cu;
/* store NodeID, use llc_shared_map to store sibling info */ /* store NodeID, use llc_shared_map to store sibling info */
per_cpu(cpu_llc_id, cpu) = node_id; per_cpu(cpu_llc_id, cpu) = node_id;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <asm/mce.h> #include <asm/mce.h>
#include <asm/smp.h>
#include <asm/amd_nb.h> #include <asm/amd_nb.h>
#include <asm/irq_vectors.h> #include <asm/irq_vectors.h>
...@@ -206,7 +207,7 @@ static u32 get_nbc_for_node(int node_id) ...@@ -206,7 +207,7 @@ static u32 get_nbc_for_node(int node_id)
struct cpuinfo_x86 *c = &boot_cpu_data; struct cpuinfo_x86 *c = &boot_cpu_data;
u32 cores_per_node; u32 cores_per_node;
cores_per_node = c->x86_max_cores / amd_get_nodes_per_socket(); cores_per_node = (c->x86_max_cores * smp_num_siblings) / amd_get_nodes_per_socket();
return cores_per_node * node_id; return cores_per_node * node_id;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册