
From: "Andi Kleen" <ak@suse.de>

Scheduler support for AMD CMP

AMD dual core looks like HT but isn't really.  Hide it from the scheduler. 
This works around problems with the domain scheduler.  Also probably gives
slightly better scheduling and disables SMT nice which is harmful on dual
core.

We still display it like HT in /proc/cpuinfo.  This is to make it appear the
same to license managers so that they count dual cores only as a single
physical CPU.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/x86_64/kernel/setup.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff -puN arch/x86_64/kernel/setup.c~x86_64-scheduler-support-for-amd-cmp arch/x86_64/kernel/setup.c
--- 25/arch/x86_64/kernel/setup.c~x86_64-scheduler-support-for-amd-cmp	2004-11-28 01:54:40.113498928 -0800
+++ 25-akpm/arch/x86_64/kernel/setup.c	2004-11-28 01:54:40.117498320 -0800
@@ -771,6 +771,19 @@ static void __init detect_ht(struct cpui
 	}
 #endif
 }
+
+static void __init sched_cmp_hack(struct cpuinfo_x86 *c)
+{
+#ifdef CONFIG_SMP
+	/* AMD dual core looks like HT but isn't really. Hide it from the
+	   scheduler. This works around problems with the domain scheduler.
+	   Also probably gives slightly better scheduling and disables
+	   SMT nice which is harmful on dual core.
+	   TBD tune the domain scheduler for dual core. */
+	if (c->x86_vendor == X86_VENDOR_AMD && cpu_has(c, X86_FEATURE_CMP_LEGACY))
+		smp_num_siblings = 1;
+#endif
+}
 	
 static void __init init_intel(struct cpuinfo_x86 *c)
 {
@@ -914,7 +927,8 @@ void __init identify_cpu(struct cpuinfo_
 
 	select_idle_routine(c);
 	detect_ht(c); 
-		
+	sched_cmp_hack(c);
+
 	/*
 	 * On SMP, boot_cpu_data holds the common feature set between
 	 * all CPUs; so make sure that we indicate which features are
@@ -1038,11 +1052,9 @@ static int show_cpuinfo(struct seq_file 
 	if (c->x86_cache_size >= 0) 
 		seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
 	
-#ifdef CONFIG_X86_HT
-	if (smp_num_siblings > 1) {
-		seq_printf(m, "physical id\t: %d\n", phys_proc_id[c - cpu_data]);
-		seq_printf(m, "siblings\t: %d\n", smp_num_siblings);
-	}
+#ifdef CONFIG_SMP
+	seq_printf(m, "physical id\t: %d\n", phys_proc_id[c - cpu_data]);
+	seq_printf(m, "siblings\t: %d\n", c->x86_num_cores * smp_num_siblings);
 #endif	
 
 	seq_printf(m,
_
