Commit b05a720b authored by Greg Ungerer's avatar Greg Ungerer Committed by Linus Torvalds

[PATCH] m68knommu: fix scheduling and race problems in idle loop

Re-work the m68knommu specific idle code according to suggestions
from Nick Piggin <nickpiggin@yahoo.com.au>.

A couple of rules that we need to follow:

1. Preempt should now disabled over idle routines. Should only be enabled
to call schedule() then disabled again.

3. When cpu_idle finds (need_resched() == 'true'), it should call schedule().
It should not call schedule() otherwise.

Also fix interrupt locking around the need_resched() and cpu stop state
so that there is no race condition.
Signed-off-by: default avatarGreg Ungerer <gerg@snapgear.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f4d340cf
...@@ -45,11 +45,13 @@ asmlinkage void ret_from_fork(void); ...@@ -45,11 +45,13 @@ asmlinkage void ret_from_fork(void);
*/ */
void default_idle(void) void default_idle(void)
{ {
while(1) { local_irq_disable();
if (need_resched()) while (!need_resched()) {
__asm__("stop #0x2000" : : : "cc"); /* This stop will re-enable interrupts */
schedule(); __asm__("stop #0x2000" : : : "cc");
local_irq_disable();
} }
local_irq_enable();
} }
void (*idle)(void) = default_idle; void (*idle)(void) = default_idle;
...@@ -63,7 +65,12 @@ void (*idle)(void) = default_idle; ...@@ -63,7 +65,12 @@ void (*idle)(void) = default_idle;
void cpu_idle(void) void cpu_idle(void)
{ {
/* endless idle loop with no priority at all */ /* endless idle loop with no priority at all */
idle(); while (1) {
idle();
preempt_enable_no_resched();
schedule();
preempt_disable();
}
} }
void machine_restart(char * __unused) void machine_restart(char * __unused)
......
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