Skip to contentSkip to conversation

ppc64: Fix cpu_up race

PATCH In review Srivatsa Vaddagiri 2 participants 2 messages Jul 30, 2004 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 20040729053011.GC6456@krispykreme

#3 lore raw

PATCH 1/1 ppc64: Fix cpu_up race

Quoted 6 lines · Anton Blanchard
Quoted 4 lines

I think Anton pushed this to ameslab. I presume there should be some mechanism for ameslab stuff to be included mainline. If there is such mechanism, then I dont want to push the patch myself.

It looks good, could you send it directly to akpm, ccing me?

Andrew,
Patch below fixes a cpu_up race in PPC64. Please apply.

---

 linux-2.6.8-rc2-vatsa/arch/ppc64/kernel/smp.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletion(-)
arch/ppc64/kernel/smp.c renamed from arch/ppc64/kernel/smp.c~ppc64_cpu_up_fix +9 -1
diff -puN arch/ppc64/kernel/smp.c~ppc64_cpu_up_fix arch/ppc64/kernel/smp.c
@@ -927,7 +927,11 @@ int __devinit __cpu_up(unsigned int cpu)
 
 	if (smp_ops->give_timebase)
 		smp_ops->give_timebase();
-	cpu_set(cpu, cpu_online_map);
+
+	/* Wait until cpu puts itself in the online map */
+	while (!cpu_online(cpu))
+		cpu_relax();
+
 	return 0;
 }
 
@@ -963,6 +967,10 @@ int __devinit start_secondary(void *unus
 #endif
 #endif
 
+	spin_lock(&call_lock);
+	cpu_set(cpu, cpu_online_map);
+	spin_unlock(&call_lock);
+
 	local_irq_enable();
 
 	return cpu_idle(NULL);

_

Signature · 5 lines
Thanks and Regards,
Srivatsa Vaddagiri,
Linux Technology Center,
IBM Software Labs,
Bangalore, INDIA - 560017
#4 lore raw

I've tested this patch extensively and it does fix the race.

In more detail the race is that the cpu can be running before it is marked in the cpu_online_map. While running it can go idle and the idle loop checks cpu_online_map, sees that it is not set, and assumes that a hotplug remove is in progress and that it should stop itself. By the time the cpu is marked online it is stopped.

Quoted 54 lines · Srivatsa Vaddagiri
Quoted 7 lines · Anton Blanchard
Quoted 5 lines

I think Anton pushed this to ameslab. I presume there should be some mechanism for ameslab stuff to be included mainline. If there is such mechanism, then I dont want to push the patch myself.

It looks good, could you send it directly to akpm, ccing me?

Andrew,
Patch below fixes a cpu_up race in PPC64. Please apply.

---

 linux-2.6.8-rc2-vatsa/arch/ppc64/kernel/smp.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletion(-)

diff -puN arch/ppc64/kernel/smp.c~ppc64_cpu_up_fix arch/ppc64/kernel/smp.c

arch/ppc64/kernel/smp.c renamed from arch/ppc64/kernel/smp.c~ppc64_cpu_up_fix +9 -1
@@ -927,7 +927,11 @@ int __devinit __cpu_up(unsigned int cpu)
 
 	if (smp_ops->give_timebase)
 		smp_ops->give_timebase();
-	cpu_set(cpu, cpu_online_map);
+
+	/* Wait until cpu puts itself in the online map */
+	while (!cpu_online(cpu))
+		cpu_relax();
+
 	return 0;
 }
 
@@ -963,6 +967,10 @@ int __devinit start_secondary(void *unus
 #endif
 #endif
 
+	spin_lock(&call_lock);
+	cpu_set(cpu, cpu_online_map);
+	spin_unlock(&call_lock);
+
 	local_irq_enable();
 
 	return cpu_idle(NULL);

_