diff options
author | Nick Piggin <nickpiggin@yahoo.com.au> | 2005-11-09 00:39:01 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 10:56:33 -0500 |
commit | 5bfb5d690f36d316a5f3b4f7775fda996faa6b12 (patch) | |
tree | ea53f15293d1ddb49c316eb65df85e939a4f6e5e /arch/i386/kernel | |
parent | ede3d0fba99520f268067917b50858d788bc41da (diff) |
[PATCH] sched: disable preempt in idle tasks
Run idle threads with preempt disabled.
Also corrected a bugs in arm26's cpu_idle (make it actually call schedule()).
How did it ever work before?
Might fix the CPU hotplugging hang which Nigel Cunningham noted.
We think the bug hits if the idle thread is preempted after checking
need_resched() and before going to sleep, then the CPU offlined.
After calling stop_machine_run, the CPU eventually returns from preemption and
into the idle thread and goes to sleep. The CPU will continue executing
previous idle and have no chance to call play_dead.
By disabling preemption until we are ready to explicitly schedule, this bug is
fixed and the idle threads generally become more robust.
From: alexs <ashepard@u.washington.edu>
PPC build fix
From: Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
MIPS build fix
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/i386/kernel')
-rw-r--r-- | arch/i386/kernel/process.c | 4 | ||||
-rw-r--r-- | arch/i386/kernel/smpboot.c | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c index 7a14fdfd3af9..5296e284ea36 100644 --- a/arch/i386/kernel/process.c +++ b/arch/i386/kernel/process.c | |||
@@ -179,7 +179,7 @@ static inline void play_dead(void) | |||
179 | */ | 179 | */ |
180 | void cpu_idle(void) | 180 | void cpu_idle(void) |
181 | { | 181 | { |
182 | int cpu = raw_smp_processor_id(); | 182 | int cpu = smp_processor_id(); |
183 | 183 | ||
184 | /* endless idle loop with no priority at all */ | 184 | /* endless idle loop with no priority at all */ |
185 | while (1) { | 185 | while (1) { |
@@ -201,7 +201,9 @@ void cpu_idle(void) | |||
201 | __get_cpu_var(irq_stat).idle_timestamp = jiffies; | 201 | __get_cpu_var(irq_stat).idle_timestamp = jiffies; |
202 | idle(); | 202 | idle(); |
203 | } | 203 | } |
204 | preempt_enable_no_resched(); | ||
204 | schedule(); | 205 | schedule(); |
206 | preempt_disable(); | ||
205 | } | 207 | } |
206 | } | 208 | } |
207 | 209 | ||
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c index 47ec76794d02..bc5a9d97466b 100644 --- a/arch/i386/kernel/smpboot.c +++ b/arch/i386/kernel/smpboot.c | |||
@@ -485,6 +485,7 @@ static void __devinit start_secondary(void *unused) | |||
485 | * things done here to the most necessary things. | 485 | * things done here to the most necessary things. |
486 | */ | 486 | */ |
487 | cpu_init(); | 487 | cpu_init(); |
488 | preempt_disable(); | ||
488 | smp_callin(); | 489 | smp_callin(); |
489 | while (!cpu_isset(smp_processor_id(), smp_commenced_mask)) | 490 | while (!cpu_isset(smp_processor_id(), smp_commenced_mask)) |
490 | rep_nop(); | 491 | rep_nop(); |