Skip to contentSkip to conversation

x86/centaur: report correct CPU/cache topology

PATCH David Wang 1 participant 1 message Apr 26, 2018

lore
Share & tools
lore

David Wang

author
#0 lore raw
Quoted 31 lines

-----Original Mail-----
Sender: Thomas Gleixner [mailto:[email protected]]
Time: 2018年4月26日 17:12
Receiver: David Wang <[email protected]>
CC: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; brucechang@via- alliance.com; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2] x86/centaur: report correct CPU/cache topology

Quoted 5 lines · David Wang
(quoted diff) +4 -0
+static void early_init_centaur_mc(struct cpuinfo_x86 *c) { #ifdef
+CONFIG_SMP
+	unsigned int eax, ebx, ecx, edx;
+

Review

Quoted 10 lines
(quoted diff) +10 -0
+	if (c->cpuid_level < 4)
+		return;
+
+	cpuid_count(4, 0, &eax, &ebx, &ecx, &edx);
+	if (eax & 0x1f)
+		c->x86_max_cores = (eax >> 26) + 1;
+	else
+		return;
+#endif
+}

My review comment from last time still stands:

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

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

In other words:

Make a patch which moves intel_num_cpu_cores() into common.c. Rename the function into something like detect_num_cpu_cores() and fix up the

call

Quoted 4 lines

site in intel.c.

Then add your patch and use the very same function.

OK. I got it.

Quoted 18 lines
Quoted 18 lines
(quoted diff) +3 -0
+
 static void early_init_centaur(struct cpuinfo_x86 *c)  {
+	early_init_centaur_mc(c);
 	switch (c->x86) {
 #ifdef CONFIG_X86_32
 	case 5:
@@ -146,6 +163,7 @@ static void centaur_detect_vmx_virtcap(struct
 cpuinfo_x86 *c)
 
 static void init_centaur(struct cpuinfo_x86 *c)  {
+	unsigned int l2 = 0;
 #ifdef CONFIG_X86_32
 	char *name;
 	u32  fcr_set = 0;
@@ -161,6 +179,17 @@ static void init_centaur(struct cpuinfo_x86 *c)
 #endif
 	early_init_centaur(c);
 
Quoted 8 lines

Review static void init_centaur(struct cpuinfo_x86 *c) · line 187

Quoted 6 lines
(quoted diff) +6 -0
+	l2 = init_intel_cacheinfo(c);
+
+	/* Detect legacy cache sizes if init_intel_cacheinfo did not */
+	if (l2 == 0) {
+		cpu_detect_cache_sizes(c);
+	}

Aside of the pointless parentheses, this really wants to be cleaned up as

well.

Quoted 2 lines

init_intel_cacheinfo() is called from the intel init code and it does the

same

Quoted 35 lines

silly thing.

So the right thing to do is in a separate patch first

arch/x86/kernel/cpu/intel.c +0 -6
@@ -679,12 +679,6 @@ static void init_intel(struct cpuinfo_x8
 
 	l2 = init_intel_cacheinfo(c);
 
-	/* Detect legacy cache sizes if init_intel_cacheinfo did not */
-	if (l2 == 0) {
-		cpu_detect_cache_sizes(c);
-		l2 = c->x86_cache_size;
-	}
-
 	if (c->cpuid_level > 9) {
 		unsigned eax = cpuid_eax(10);
 		/* Check for version and the number of counters */
arch/x86/kernel/cpu/intel_cacheinfo.c +5 -0
@@ -802,6 +802,11 @@ unsigned int init_intel_cacheinfo(struct
 
 	c->x86_cache_size = l3 ? l3 : (l2 ? l2 : (l1i+l1d));
 
+	/* Detect legacy cache sizes if the above did not work */
+	if (!l2) {
+		cpu_detect_cache_sizes(c);
+		l2 = c->x86_cache_size;
+	}
 	return l2;
 }
 

Hmm?

Quoted 2 lines

tglx

OK. I got it.
Patch v3 will be sent later.
Thank you.
---
David