]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Check for preemption after lowering a thread's priority
authorRyan Stone <rstone@FreeBSD.org>
Thu, 16 Feb 2017 19:41:13 +0000 (19:41 +0000)
committerRyan Stone <rstone@FreeBSD.org>
Thu, 16 Feb 2017 19:41:13 +0000 (19:41 +0000)
commit09ae7c48144d6fe6cfdbdad5ce9f051d23f5926b
treee289f1b381666786635e2f417ec971663bb2891b
parentc53cc7187c2345fa029dcfbe7cb4044581334099
Check for preemption after lowering a thread's priority

When a high-priority thread is waiting for a mutex held by a
low-priority thread, it temporarily lends its priority to the
low-priority thread to prevent priority inversion.  When the mutex
is released, the lent priority is revoked and the low-priority
thread goes back to its original priority.

When the priority of that thread is lowered (through a call to
sched_priority()), the schedule was not checking whether
there is now a high-priority thread in the run queue.  This can
cause threads with real-time priority to be starved in the run
queue while the low-priority thread finishes its quantum.

Fix this by explicitly checking whether preemption is necessary
when a thread's priority is lowered.

Sponsored by: Dell EMC Isilon
Obtained from: Sandvine Inc
Differential Revision: https://reviews.freebsd.org/D9518
Reviewed by: Jeff Roberson (ule)
MFC after: 1 month
sys/kern/sched_4bsd.c
sys/kern/sched_ule.c