diff options
author | Dimitri Sivanich <sivanich@sgi.com> | 2007-08-07 09:49:32 -0400 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2007-08-13 13:17:23 -0400 |
commit | 71416bea5afa9e5a6c76c1509ab69c46c857a2bb (patch) | |
tree | 24e411bb388bcc00289aca20d9aa88722f8b5cd2 /arch/ia64 | |
parent | 39d3520c92cf7a28c07229ca00cc35a1e8026c77 (diff) |
[IA64] disable irq's and check need_resched before safe_halt
While sending interrupts to a cpu to repeatedly wake a thread, on occasion
that thread will take a full timer tick cycle (4002 usec in my case)
to wakeup.
The problem concerns a race condition in the code around the safe_halt()
call in the default_idle() routine. Setting 'nohalt' on the kernel
command line causes the long wakeups to disappear.
void
default_idle (void)
{
local_irq_enable();
while (!need_resched()) {
--> if (can_do_pal_halt)
--> safe_halt();
else
A timer tick could arrive between the check for !need_resched and the
actual call to safe_halt() (which does a pal call to PAL_HALT_LIGHT).
By the time the timer tick completes, a thread that might now need to run
could get held up for as long as a timer tick waiting for the halted cpu.
I'm proposing that we disable irq's and check need_resched again before
calling safe_halt(). Does anyone see any problem with this approach?
Signed-off-by: Dimitri Sivanich <sivanich@sgi.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch/ia64')
-rw-r--r-- | arch/ia64/kernel/process.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c index 4158906c45aa..c613fc0e91cc 100644 --- a/arch/ia64/kernel/process.c +++ b/arch/ia64/kernel/process.c | |||
@@ -198,9 +198,13 @@ default_idle (void) | |||
198 | { | 198 | { |
199 | local_irq_enable(); | 199 | local_irq_enable(); |
200 | while (!need_resched()) { | 200 | while (!need_resched()) { |
201 | if (can_do_pal_halt) | 201 | if (can_do_pal_halt) { |
202 | safe_halt(); | 202 | local_irq_disable(); |
203 | else | 203 | if (!need_resched()) { |
204 | safe_halt(); | ||
205 | } | ||
206 | local_irq_enable(); | ||
207 | } else | ||
204 | cpu_relax(); | 208 | cpu_relax(); |
205 | } | 209 | } |
206 | } | 210 | } |