[PATCH] set cpu_state for CPU hotplug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
Dead CPU notify online CPU it's dead using cpu_state variable. After
switching to physical cpu hotplug, we forgot setting the variable. This
patch fixes it. Currently only __cpu_die uses it. We changed other
locations for consistency in case others use it.

Thanks,
Shaohua

Signed-off-by: Shaohua Li<[email protected]>
Acked-by: Ashok Raj<[email protected]>
---

 linux-2.6.12-rc6-mm1-root/arch/i386/kernel/smpboot.c   |    7 ++++++-
 linux-2.6.12-rc6-mm1-root/arch/ia64/kernel/smpboot.c   |    3 +++
 linux-2.6.12-rc6-mm1-root/arch/x86_64/kernel/smpboot.c |    7 ++++++-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff -puN arch/i386/kernel/smpboot.c~cpu_state_fix arch/i386/kernel/smpboot.c
--- linux-2.6.12-rc6-mm1/arch/i386/kernel/smpboot.c~cpu_state_fix	2005-06-14 11:23:31.000000000 +0800
+++ linux-2.6.12-rc6-mm1-root/arch/i386/kernel/smpboot.c	2005-06-15 08:50:54.122672032 +0800
@@ -514,6 +514,7 @@ static void __devinit start_secondary(vo
 	lock_ipi_call_lock();
 	cpu_set(smp_processor_id(), cpu_online_map);
 	unlock_ipi_call_lock();
+	per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
 
 	/* We can take interrupts now: we're officially "up". */
 	local_irq_enable();
@@ -1270,6 +1271,7 @@ void __devinit smp_prepare_boot_cpu(void
 	cpu_set(smp_processor_id(), cpu_online_map);
 	cpu_set(smp_processor_id(), cpu_callout_map);
 	cpu_set(smp_processor_id(), cpu_present_map);
+	per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
@@ -1327,8 +1329,10 @@ void __cpu_die(unsigned int cpu)
 
 	for (i = 0; i < 10; i++) {
 		/* They ack this in play_dead by setting CPU_DEAD */
-		if (per_cpu(cpu_state, cpu) == CPU_DEAD)
+		if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
+			printk ("CPU %d is now offline\n", cpu);
 			return;
+		}
 		current->state = TASK_UNINTERRUPTIBLE;
 		schedule_timeout(HZ/10);
 	}
@@ -1357,6 +1361,7 @@ int __devinit __cpu_up(unsigned int cpu)
 	}
 
 	local_irq_enable();
+	per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
 	/* Unleash the CPU! */
 	cpu_set(cpu, smp_commenced_mask);
 	while (!cpu_isset(cpu, cpu_online_map))
diff -puN arch/x86_64/kernel/smpboot.c~cpu_state_fix arch/x86_64/kernel/smpboot.c
--- linux-2.6.12-rc6-mm1/arch/x86_64/kernel/smpboot.c~cpu_state_fix	2005-06-14 11:25:04.000000000 +0800
+++ linux-2.6.12-rc6-mm1-root/arch/x86_64/kernel/smpboot.c	2005-06-15 08:51:17.743081184 +0800
@@ -511,6 +511,7 @@ void __cpuinit start_secondary(void)
 	 * Allow the master to continue.
 	 */
 	cpu_set(smp_processor_id(), cpu_online_map);
+	per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
 	mb();
 
 	/* Wait for TSC sync to not schedule things before.
@@ -1038,6 +1039,7 @@ void __init smp_prepare_boot_cpu(void)
 	cpu_set(me, cpu_callout_map);
 	cpu_set(0, cpu_sibling_map[0]);
 	cpu_set(0, cpu_core_map[0]);
+	per_cpu(cpu_state, me) = CPU_ONLINE;
 }
 
 /*
@@ -1066,6 +1068,7 @@ int __cpuinit __cpu_up(unsigned int cpu)
  		return -ENOSYS;
 	}
 
+	per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
 	/* Boot it! */
 	err = do_boot_cpu(cpu, apicid);
 	if (err < 0) {
@@ -1170,8 +1173,10 @@ void __cpu_die(unsigned int cpu)
 
 	for (i = 0; i < 10; i++) {
 		/* They ack this in play_dead by setting CPU_DEAD */
-		if (per_cpu(cpu_state, cpu) == CPU_DEAD)
+		if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
+			printk ("CPU %d is now offline\n", cpu);
 			return;
+		}
 		current->state = TASK_UNINTERRUPTIBLE;
 		schedule_timeout(HZ/10);
 	}
diff -puN arch/ia64/kernel/smpboot.c~cpu_state_fix arch/ia64/kernel/smpboot.c
--- linux-2.6.12-rc6-mm1/arch/ia64/kernel/smpboot.c~cpu_state_fix	2005-06-14 11:25:53.000000000 +0800
+++ linux-2.6.12-rc6-mm1-root/arch/ia64/kernel/smpboot.c	2005-06-15 08:51:37.199123416 +0800
@@ -346,6 +346,7 @@ smp_callin (void)
 	lock_ipi_calllock();
 	cpu_set(cpuid, cpu_online_map);
 	unlock_ipi_calllock();
+	per_cpu(cpu_state, cpuid) = CPU_ONLINE;
 
 	smp_setup_percpu_timer();
 
@@ -611,6 +612,7 @@ void __devinit smp_prepare_boot_cpu(void
 {
 	cpu_set(smp_processor_id(), cpu_online_map);
 	cpu_set(smp_processor_id(), cpu_callin_map);
+	per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
 }
 
 /*
@@ -775,6 +777,7 @@ __cpu_up (unsigned int cpu)
 	if (cpu_isset(cpu, cpu_callin_map))
 		return -EINVAL;
 
+	per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
 	/* Processor goes to start_secondary(), sets online flag */
 	ret = do_boot_cpu(sapicid, cpu);
 	if (ret < 0)
_


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux