Skip to contentSkip to conversation

x86/centaur: report correct CPU/cache topology

PATCH Superseded David Wang 2 participants 2 messages Apr 4, 2018 – Apr 17, 2018 x86

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

David Wang

author
#0 lore raw

PATCH 1/1 x86/centaur: report correct CPU/cache topology

This patch is used to support multi-core Centaur CPU. After using this patch, we can get correct CPU topology and correct cache topology.

---
 arch/x86/kernel/cpu/centaur.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/x86/kernel/cpu/centaur.c +20 -0
index e5ec0f1..713e4db 100644
@@ -112,6 +112,19 @@ static void early_init_centaur(struct cpuinfo_x86 *c)
 	}
 }
 
+static int centaur_num_cpu_cores(struct cpuinfo_x86 *c)
+{
+	unsigned int eax, ebx, ecx, edx;
+
+	if (c->cpuid_level < 4)
+		return 1;
+	cpuid_count(4, 0, &eax, &ebx, &ecx, &edx);
+	if (eax & 0x1f)
+		return (eax >> 26) + 1;
+	else
+		return 1;
+}
+
 static void init_centaur(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_X86_32
@@ -128,6 +141,13 @@ static void init_centaur(struct cpuinfo_x86 *c)
 	clear_cpu_cap(c, 0*32+31);
 #endif
 	early_init_centaur(c);
+
+	init_intel_cacheinfo(c);
+	c->x86_max_cores = centaur_num_cpu_cores(c);
+#ifdef CONFIG_X86_32
+	detect_ht(c);
+#endif
+
 	switch (c->x86) {
 #ifdef CONFIG_X86_32
 	case 5:
Signature · 1 line
1.9.1
#1 lore raw
Quoted 2 lines · David Wang

This patch is used to support multi-core Centaur CPU. After using this patch, we can get correct CPU topology and correct cache topology.

David. This changelog is pretty useless. First of all, please do not use 'This patch ..'. We all know already that this is a patch. Documentation/process/submitting-patches.rst has a good explanation about writing changelogs.

The changelog should explain why it does something. Let me give you an example:

Centaur CPUs enumerate the cache topology in the same way as Intel CPUs, but the functionality is unused so far. The Centaur init code also misses to initialize x86_cpuinfo::max_cores so the CPU topology cannot be desribed correctly,

Initialize x86_cpuinfo::max_cores and invoke init_intel_cacheinfo() to make CPU and cache topology information available and correct.

See? I'm neither using 'this patch' nor 'We/I' as I'm not impersonatimg the code. It's all factual instead.

Quoted 14 lines
---
 arch/x86/kernel/cpu/centaur.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/x86/kernel/cpu/centaur.c +1 -0
index e5ec0f1..713e4db 100644
@@ -112,6 +112,19 @@ static void early_init_centaur(struct cpuinfo_x86 *c)
 	}
 }
 
+static int centaur_num_cpu_cores(struct cpuinfo_x86 *c)

arch/x86/kernel/cpu/centaur.c static void early_init_centaur(struct cpuinfo_x86 *c) · line 125

Quoted 10 lines
arch/x86/kernel/cpu/centaur.c +10 -0
+{
+	unsigned int eax, ebx, ecx, edx;
+
+	if (c->cpuid_level < 4)
+		return 1;
+	cpuid_count(4, 0, &eax, &ebx, &ecx, &edx);
+	if (eax & 0x1f)
+		return (eax >> 26) + 1;
+	else
+		return 1;

This is a bad copy of intel_num_cpu_cores(). See for the subtle difference. Please rename the intel function and move it to common.c

arch/x86/kernel/cpu/centaur.c static void init_centaur(struct cpuinfo_x86 *c) · line 149

Quoted 13 lines
arch/x86/kernel/cpu/centaur.c +6 -0
 static void init_centaur(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_X86_32
@@ -128,6 +141,13 @@ static void init_centaur(struct cpuinfo_x86 *c)
 	clear_cpu_cap(c, 0*32+31);
 #endif
 	early_init_centaur(c);
+
+	init_intel_cacheinfo(c);
+	c->x86_max_cores = centaur_num_cpu_cores(c);
+#ifdef CONFIG_X86_32
+	detect_ht(c);
+#endif

Can you please create a stub inline of detect_ht() for the !32bit case and get rid of these #ifdefs in the code. That wants to be a separate patch which also cleans up the existing call sites.

Thanks,

tglx