[RFC patch] disable the assumption of apic_is_clustered_box for cores >= 6

From: Luming Yu
Date: Mon Jun 29 2009 - 22:53:36 EST


Hello,

We have to disable the assumption of apic_is_clustered_box that assumes high
4bits of 8 bit APIC ID was cluster id, which is just the function's guess.
On a normal 4-socket system with >6cores Processor and HT enabled, we hit the
limitation of the guess and failed. Have to disable the guess on any
cores > 6 system.

Without this patch, we can't use good TSC on any SMP system with 48+ logical CPU

**The patch is enclosed in text attachment*
**Using web client to send the patch* *
**below is for review, please apply attached patch*/

Thanks,
Luming

apic/apic.c | 15 ++++++++++++++-
cpu/intel.c | 2 +-
2 files changed, 15 insertions(+), 2 deletions(-)

--- linux-2.6.30-rc6/arch/x86/kernel/apic/apic.c.0 2009-06-29
19:54:15.000000000 -0600
+++ linux-2.6.30-rc6/arch/x86/kernel/apic/apic.c 2009-06-29
20:14:15.000000000 -0600
@@ -2119,6 +2119,16 @@
#endif /* CONFIG_PM */

#ifdef CONFIG_X86_64
+extern int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c);
+
+__cpuinit int __detect_cores(void)
+{
+ if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
+ boot_cpu_data.x86_max_cores =
+ intel_num_cpu_cores(&boot_cpu_data);
+ return boot_cpu_data.x86_max_cores;
+}
+
/*
* apic_is_clustered_box() -- Check if we can expect good TSC
*
@@ -2190,7 +2200,10 @@
* May have to revisit this when multi-core + hyperthreaded CPUs come
* out, but AFAIK this will work even for them.
*/
- return (clusters > 2);
+ if (clusters > 2)
+ return (__detect_cores() >= 6) ? 0 : 1;
+ else
+ return 0;
}
#endif

--- linux-2.6.30-rc6/arch/x86/kernel/cpu/intel.c.0 2009-06-29
19:53:29.000000000 -0600
+++ linux-2.6.30-rc6/arch/x86/kernel/cpu/intel.c 2009-06-29
08:46:12.000000000 -0600
@@ -250,7 +250,7 @@
/*
* find out the number of processor cores on the die
*/
-static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
+int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
{
unsigned int eax, ebx, ecx, edx;

Attachment: 1.patch
Description: Binary data