public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RE: PATCH: Fix race in cpu_down (hotplug cpu)
@ 2005-09-19  4:48 Li, Shaohua
  2005-09-19  5:10 ` Srivatsa Vaddagiri
  2005-09-19  5:23 ` Nigel Cunningham
  0 siblings, 2 replies; 27+ messages in thread
From: Li, Shaohua @ 2005-09-19  4:48 UTC (permalink / raw)
  To: vatsa, Nigel Cunningham
  Cc: Andrew Morton, Linus Torvalds, Zwane Mwaikambo,
	Linux Kernel Mailing List, Rusty Russell

Hi,
>
>On Mon, Sep 19, 2005 at 01:28:38PM +1000, Nigel Cunningham wrote:
>> There is a race condition in taking down a cpu
(kernel/cpu.c::cpu_down).
>> A cpu can already be idling when we clear its online flag, and we do
not
>> force the idle task to reschedule. This results in __cpu_die timing
out.
>
>"when we clear its online flag" - This happens in take_cpu_down in the
>context of stopmachine thread. take_cpu_down also ensures that idle
>thread runs when it returns (sched_idle_next). So when idle thread
runs,
>it should notice that it is offline and invoke play_dead.  So I don't
>understand why __cpu_die should time out.
I guess Nigel's point is cpu_idle is preempted before take_cpu_down. If
the preempt occurs after the cpu_is_offline check, when the cpu (after
sched_idle_next) goes into idle again, nobody can wake it up. Nigel,
isn't it?

Thanks,
Shaohua

^ permalink raw reply	[flat|nested] 27+ messages in thread
* PATCH: Fix race in cpu_down (hotplug cpu)
@ 2005-09-19  3:28 Nigel Cunningham
  2005-09-19  4:22 ` Srivatsa Vaddagiri
  0 siblings, 1 reply; 27+ messages in thread
From: Nigel Cunningham @ 2005-09-19  3:28 UTC (permalink / raw)
  To: Andrew Morton, Linus Torvalds, Zwane Mwaikambo; +Cc: Linux Kernel Mailing List

Hmm... managed to miss a word at the end of the first para and thus not
make sense. Let's try again.

----------

Hi.

There is a race condition in taking down a cpu (kernel/cpu.c::cpu_down).
A cpu can already be idling when we clear its online flag, and we do not
force the idle task to reschedule. This results in __cpu_die timing out.
A simple fix is to force the idle task on the cpu going down to reschedule.

Without the patch below, Suspend2 get into a deadlock at resume time
when this issue occurs. I could not complete 20 cycles without seeing
the issue. With the patch below, I have completed 75 cycles on the trot
without problems.

Please apply.

Signed-off-by: Nigel Cunningham <ncunningham@cyclades.com>

diff -ruNp 9910-hotplug-cpu-race.patch-old/kernel/cpu.c 9910-hotplug-cpu-race.patch-new/kernel/cpu.c
--- 9910-hotplug-cpu-race.patch-old/kernel/cpu.c	2005-08-29 10:29:58.000000000 +1000
+++ 9910-hotplug-cpu-race.patch-new/kernel/cpu.c	2005-09-19 12:15:08.000000000 +1000
@@ -126,6 +126,9 @@ int cpu_down(unsigned int cpu)
 	while (!idle_cpu(cpu))
 		yield();
 
+	/* CPU may have idled before we set its offline flag. */
+	set_tsk_need_resched(idle_task(cpu));
+
 	/* This actually kills the CPU. */
 	__cpu_die(cpu);
 




^ permalink raw reply	[flat|nested] 27+ messages in thread
* PATCH: Fix race in cpu_down (hotplug cpu)
@ 2005-09-19  3:15 Nigel Cunningham
  0 siblings, 0 replies; 27+ messages in thread
From: Nigel Cunningham @ 2005-09-19  3:15 UTC (permalink / raw)
  To: Andrew Morton, Linus Torvalds, Zwane Mwaikambo; +Cc: Linux Kernel Mailing List

Hi.

There is a race condition in taking down a cpu (kernel/cpu.c::cpu_down).
A cpu can already be idling when we clear its online flag, and we do not
force the idle task to reschedule. This results in __cpu_die timing out.
A simple fix is to force the idle task on the cpu going to reschedule.

Without the patch below, Suspend2 get into a deadlock at resume time
when this issue occurs. I could not complete 20 cycles without seeing
the issue. With the patch below, I have completed 75 cycles on the trot
without problems.

Please apply.

Signed-off-by: Nigel Cunningham <ncunningham@cyclades.com>

diff -ruNp 9910-hotplug-cpu-race.patch-old/kernel/cpu.c 9910-hotplug-cpu-race.patch-new/kernel/cpu.c
--- 9910-hotplug-cpu-race.patch-old/kernel/cpu.c	2005-08-29 10:29:58.000000000 +1000
+++ 9910-hotplug-cpu-race.patch-new/kernel/cpu.c	2005-09-19 12:15:08.000000000 +1000
@@ -126,6 +126,9 @@ int cpu_down(unsigned int cpu)
 	while (!idle_cpu(cpu))
 		yield();
 
+	/* CPU may have idled before we set its offline flag. */
+	set_tsk_need_resched(idle_task(cpu));
+
 	/* This actually kills the CPU. */
 	__cpu_die(cpu);
 




^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2005-09-20  4:42 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-19  4:48 PATCH: Fix race in cpu_down (hotplug cpu) Li, Shaohua
2005-09-19  5:10 ` Srivatsa Vaddagiri
2005-09-19  5:31   ` Shaohua Li
2005-09-19  5:57     ` Srivatsa Vaddagiri
2005-09-19  6:11       ` Nigel Cunningham
2005-09-19  6:23         ` Srivatsa Vaddagiri
2005-09-19  6:29           ` Nick Piggin
2005-09-19  7:00             ` Srivatsa Vaddagiri
2005-09-19  6:31           ` Nigel Cunningham
2005-09-19  7:09             ` Srivatsa Vaddagiri
2005-09-19  6:37           ` Shaohua Li
2005-09-19  6:36             ` Nick Piggin
2005-09-19  6:54               ` Nigel Cunningham
2005-09-19  7:12               ` Shaohua Li
2005-09-19  7:22                 ` Nick Piggin
2005-09-19  7:28                   ` Ingo Molnar
2005-09-19  7:37                     ` Nick Piggin
2005-09-19 22:55                       ` Nigel Cunningham
2005-09-20  4:41                         ` Srivatsa Vaddagiri
2005-09-19  7:07             ` Srivatsa Vaddagiri
2005-09-19  5:23 ` Nigel Cunningham
2005-09-19  5:28   ` Srivatsa Vaddagiri
2005-09-19  5:35     ` Nigel Cunningham
2005-09-19  7:43       ` Where do packets sent to 255.255.255.255 go? Wei-Che, Hsu
  -- strict thread matches above, loose matches on Subject: below --
2005-09-19  3:28 PATCH: Fix race in cpu_down (hotplug cpu) Nigel Cunningham
2005-09-19  4:22 ` Srivatsa Vaddagiri
2005-09-19  3:15 Nigel Cunningham

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