
From: Andi Kleen <ak@muc.de>

From: Suresh B. Siddha

Convert sibling map on x86-64 to cpumasks.

This is needed for the SMT patches.


---

 25-akpm/arch/x86_64/kernel/smpboot.c |   41 +++++++++++++++++++----------------
 25-akpm/include/asm-x86_64/smp.h     |    2 -
 2 files changed, 24 insertions(+), 19 deletions(-)

diff -puN arch/x86_64/kernel/smpboot.c~x86_64-convert-sibling-map-to-masks arch/x86_64/kernel/smpboot.c
--- 25/arch/x86_64/kernel/smpboot.c~x86_64-convert-sibling-map-to-masks	2004-05-10 01:11:27.134585064 -0700
+++ 25-akpm/arch/x86_64/kernel/smpboot.c	2004-05-10 01:11:27.139584304 -0700
@@ -73,7 +73,7 @@ struct cpuinfo_x86 cpu_data[NR_CPUS] __c
 /* Set when the idlers are all forked */
 int smp_threads_ready;
 
-char cpu_sibling_map[NR_CPUS] __cacheline_aligned;
+cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned;
 
 /*
  * Trampoline 80x86 program as an array.
@@ -874,31 +874,36 @@ static void __init smp_boot_cpus(unsigne
 	}
 
 	/*
-	 * If Hyper-Threading is avaialble, construct cpu_sibling_map[], so
-	 * that we can tell the sibling CPU efficiently.
+	 * Construct cpu_sibling_map[], so that we can tell the
+	 * sibling CPU efficiently.
 	 */
-	if (cpu_has_ht && smp_num_siblings > 1) {
-		for (cpu = 0; cpu < NR_CPUS; cpu++)
-			cpu_sibling_map[cpu] = NO_PROC_ID;
-		
-		for (cpu = 0; cpu < NR_CPUS; cpu++) {
-			int 	i;
-			if (!cpu_isset(cpu, cpu_callout_map))
-				continue;
+	for (cpu = 0; cpu < NR_CPUS; cpu++)
+		cpus_clear(cpu_sibling_map[cpu]);
+
+	for (cpu = 0; cpu < NR_CPUS; cpu++) {
+		int siblings = 0;
+		int i;
+		if (!cpu_isset(cpu, cpu_callout_map))
+			continue;
 
+		if (smp_num_siblings > 1) {
 			for (i = 0; i < NR_CPUS; i++) {
-				if (i == cpu || !cpu_isset(i, cpu_callout_map))
+				if (!cpu_isset(i, cpu_callout_map))
 					continue;
 				if (phys_proc_id[cpu] == phys_proc_id[i]) {
-					cpu_sibling_map[cpu] = i;
-					break;
+					siblings++;
+					cpu_set(i, cpu_sibling_map[cpu]);
 				}
 			}
-			if (cpu_sibling_map[cpu] == (char)NO_PROC_ID) {
-				smp_num_siblings = 1;
-				printk(KERN_WARNING "WARNING: No sibling found for CPU %d.\n", cpu);
-			}
+		} else {
+			siblings++;
+			cpu_set(cpu, cpu_sibling_map[cpu]);
 		}
+
+		if (siblings != smp_num_siblings)
+			printk(KERN_WARNING
+	       "WARNING: %d siblings found for CPU%d, should be %d\n",
+			       siblings, cpu, smp_num_siblings);
 	}
 
 	Dprintk("Boot done.\n");
diff -puN include/asm-x86_64/smp.h~x86_64-convert-sibling-map-to-masks include/asm-x86_64/smp.h
--- 25/include/asm-x86_64/smp.h~x86_64-convert-sibling-map-to-masks	2004-05-10 01:11:27.135584912 -0700
+++ 25-akpm/include/asm-x86_64/smp.h	2004-05-10 01:11:27.138584456 -0700
@@ -47,7 +47,7 @@ extern void smp_invalidate_rcv(void);		/
 extern void (*mtrr_hook) (void);
 extern void zap_low_mappings(void);
 void smp_stop_cpu(void);
-extern char cpu_sibling_map[];
+extern cpumask_t cpu_sibling_map[NR_CPUS];
 extern char phys_proc_id[NR_CPUS];
 
 #define SMP_TRAMPOLINE_BASE 0x6000

_
