Commit 49487a3d authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] cpu_idle() startup race fix

Diagnosis from Christian Vogel <vogel@skunk.physik.uni-erlangen.de>

cpu_idle() tests pm_idle() just once then falls into the

	while (!need_resched())
		idle();

loop.

Problem is, that loop never terminates (need_resched() always returns false
on preemptive kernels).

The other problem is that ACPI updates pm_idle _after_ cpu_idle() has taken a
local copy.  So we always call default_idle(), even when pm_idle is pointing
at a new idle handler.

So fix it to pick up changed values of pm_idle() each time around the inner
loop.
parent 1dfe1754
...@@ -138,12 +138,15 @@ void cpu_idle (void) ...@@ -138,12 +138,15 @@ void cpu_idle (void)
{ {
/* endless idle loop with no priority at all */ /* endless idle loop with no priority at all */
while (1) { while (1) {
void (*idle)(void) = pm_idle; while (!need_resched()) {
if (!idle) void (*idle)(void) = pm_idle;
idle = default_idle;
irq_stat[smp_processor_id()].idle_timestamp = jiffies; if (!idle)
while (!need_resched()) idle = default_idle;
irq_stat[smp_processor_id()].idle_timestamp = jiffies;
idle(); idle();
}
schedule(); schedule();
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment