
From: William Lee Irwin III <wli@holomorphy.com>

To handle sparse physical APIC ID's properly the phys_cpu_present_map must
be scanned beyond bit NR_CPUS while ensuring no more than NR_CPUS are woken
in order not to attempt to wake non-addressible cpus.

The following patch adds that logic to smp_boot_cpus() and corrects the
failure to wake secondaries reported by dhowells, with successful wakeup,
runtime, reboot, and halting reported after it was applied.



 arch/i386/kernel/smpboot.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff -puN arch/i386/kernel/smpboot.c~handle-sparse-physical-apid-ids arch/i386/kernel/smpboot.c
--- 25/arch/i386/kernel/smpboot.c~handle-sparse-physical-apid-ids	2003-05-15 03:19:20.000000000 -0700
+++ 25-akpm/arch/i386/kernel/smpboot.c	2003-05-15 03:19:20.000000000 -0700
@@ -946,7 +946,7 @@ __setup("test_ht", ht_setup);
 
 static void __init smp_boot_cpus(unsigned int max_cpus)
 {
-	int apicid, cpu, bit;
+	int apicid, cpu, bit, kicked;
 
 	/*
 	 * Setup boot CPU information
@@ -1029,7 +1029,8 @@ static void __init smp_boot_cpus(unsigne
 	 */
 	Dprintk("CPU present map: %lx\n", phys_cpu_present_map);
 
-	for (bit = 0; bit < NR_CPUS; bit++) {
+	kicked = 1;
+	for (bit = 0; kicked < NR_CPUS && bit < BITS_PER_LONG; bit++) {
 		apicid = cpu_present_to_apicid(bit);
 		/*
 		 * Don't even attempt to start the boot CPU!
@@ -1045,6 +1046,8 @@ static void __init smp_boot_cpus(unsigne
 		if (do_boot_cpu(apicid))
 			printk("CPU #%d not responding - cannot use it.\n",
 								apicid);
+		else
+			++kicked;
 	}
 
 	/*

_
