public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] set cpu_state for CPU hotplug
@ 2005-06-15  6:36 Shaohua Li
  0 siblings, 0 replies; only message in thread
From: Shaohua Li @ 2005-06-15  6:36 UTC (permalink / raw)
  To: lkml; +Cc: akpm, Zwane Mwaikambo, ak, Ashok Raj

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<shaohua.li@intel.com>
Acked-by: Ashok Raj<ashok.raj@intel.com>
---

 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)
_



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-06-15  6:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-15  6:36 [PATCH] set cpu_state for CPU hotplug Shaohua Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox