x86/CPU/AMD: Fix Zen SMT topology
authorYazen Ghannam <Yazen.Ghannam@amd.com>
Sun, 5 Feb 2017 10:50:22 +0000 (11:50 +0100)
committerIngo Molnar <mingo@kernel.org>
Sun, 5 Feb 2017 11:18:45 +0000 (12:18 +0100)
After:

  a33d331761bc ("x86/CPU/AMD: Fix Bulldozer topology")

our  SMT scheduling topology for Fam17h systems is broken, because
the ThreadId is included in the ApicId when SMT is enabled.

So, without further decoding cpu_core_id is unique for each thread
rather than the same for threads on the same core. This didn't affect
systems with SMT disabled. Make cpu_core_id be what it is defined to be.

Signed-off-by: Yazen Ghannam <Yazen.Ghannam@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org> # 4.9
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170205105022.8705-2-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/cpu/amd.c

index 20dc44d1e6be4e484407a8a4fb46a22fc320b297..2b4cf04239b6c011a9d9a5ef84bdca5ef073a69e 100644 (file)
@@ -319,6 +319,13 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
                if (c->x86 == 0x15)
                        c->cu_id = ebx & 0xff;
 
+               if (c->x86 >= 0x17) {
+                       c->cpu_core_id = ebx & 0xff;
+
+                       if (smp_num_siblings > 1)
+                               c->x86_max_cores /= smp_num_siblings;
+               }
+
                /*
                 * We may have multiple LLCs if L3 caches exist, so check if we
                 * have an L3 cache by looking at the L3 cache CPUID leaf.