Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[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: Greg Ungerer <gerg@snapgear.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Greg Ungerer and committed by
Linus Torvalds
b05a720b f4d340cf

+12 -5
+12 -5
arch/m68knommu/kernel/process.c
··· 45 45 */ 46 46 void default_idle(void) 47 47 { 48 - while(1) { 49 - if (need_resched()) 50 - __asm__("stop #0x2000" : : : "cc"); 51 - schedule(); 48 + local_irq_disable(); 49 + while (!need_resched()) { 50 + /* This stop will re-enable interrupts */ 51 + __asm__("stop #0x2000" : : : "cc"); 52 + local_irq_disable(); 52 53 } 54 + local_irq_enable(); 53 55 } 54 56 55 57 void (*idle)(void) = default_idle; ··· 65 63 void cpu_idle(void) 66 64 { 67 65 /* endless idle loop with no priority at all */ 68 - idle(); 66 + while (1) { 67 + idle(); 68 + preempt_enable_no_resched(); 69 + schedule(); 70 + preempt_disable(); 71 + } 69 72 } 70 73 71 74 void machine_restart(char * __unused)