[patch] scheduler bugfix, SMP, 2.4.0-test7

From: Ingo Molnar (mingo@elte.hu)
Date: Mon Aug 28 2000 - 08:19:56 EST


the attached sched-2.4.0-test7-C1 patch fixes a 'missed wakeup'
SMP-scheduler bug. If an IRQ wakes up a process that has just been
scheduled away, the next process is executing __schedule_tail(), is past
the 'prev->state == TASK_RUNNING' test but prev->has_cpu is not yet set to
0, then we miss to reconsider scheduler state and often miss the wakeup if
the next process is the idle process.

reschedule_idle() will not consider this process for preemption, because
can_schedule() is 0. I've seen this bug in test7-final, during TUX
testruns.

the 'prev->state == TASK_RUNNING' test and the 'prev->has_cpu = 0' write
has to happen atomically wrt. interrupts, because 'has_cpu == 0' prevents
the process from being considered by the scheduler.

i've also added a test to schedule() itself to restart the schedule if
current->need_resched is 1. While this is not strictly necessery (if we
return to user-space then we re-check need_resched anyway), but it helps
latencies if schedule() is called by kernel-space, and is more consistent
because reschedule_idle() might have preempted the current process.

the patch is tested on test7, it runs just fine, fixes the bug and all
aspects of the scheduler appear to work here just fine.

        Ingo



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 31 2000 - 21:00:21 EST