]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
x86/topology: Fix AMD core count
authorPeter Zijlstra <peterz@infradead.org>
Fri, 25 Mar 2016 14:52:34 +0000 (15:52 +0100)
committerBrian Maly <brian.maly@oracle.com>
Tue, 13 Nov 2018 19:08:53 +0000 (14:08 -0500)
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: 1f12e32f4cd5 ("x86/topology: Create logical package id")
Reported-by: Xiong Zhou <jencce.kernel@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav 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.net
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
(cherry picked from commit ee6825c80e870fff1a370c718ec77022ade0889b)

Orabug: 28783929

Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Conflicts:
arch/x86/kernel/cpu/amd.c
arch/x86/ras/mce_amd_inj.c
amd.c: contextual
mce_amd_inj.c: does not exists

Signed-off-by: Brian Maly <brian.maly@oracle.com>
arch/x86/include/asm/smp.h
arch/x86/kernel/cpu/amd.c

index a11cbde4967240e6deb6301487e2ca28f4e4cffd..631dd58b81f40e958da6995ef3af854dc5bfd7b1 100644 (file)
@@ -180,6 +180,7 @@ static inline int wbinvd_on_all_cpus(void)
        wbinvd();
        return 0;
 }
+#define smp_num_siblings       1
 #endif /* CONFIG_SMP */
 
 extern unsigned disabled_cpus;
index d632cc2be8373f5b1e4dfa20cd273e1c4c732ed3..d4376ac8b988150dfbfbfa3c44cd404843a3ad5f 100644 (file)
@@ -317,8 +317,9 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
                node_id = ecx & 7;
 
                /* get compute unit information */
+               cores_per_cu = ((ebx >> 8) & 3) + 1;
+               c->x86_max_cores /= cores_per_cu;
                c->compute_unit_id = ebx & 0xff;
-               cores_per_cu += ((ebx >> 8) & 3);
        } else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) {
                u64 value;
 
@@ -333,8 +334,8 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
                u32 cus_per_node;
 
                set_cpu_cap(c, X86_FEATURE_AMD_DCM);
-               cores_per_node = c->x86_max_cores / nodes_per_socket;
-               cus_per_node = cores_per_node / cores_per_cu;
+               cus_per_node = c->x86_max_cores / nodes_per_socket;
+               cores_per_node = cus_per_node * cores_per_cu;
 
                /* store NodeID, use llc_shared_map to store sibling info */
                per_cpu(cpu_llc_id, cpu) = node_id;