Check for preemption after lowering a thread's priority
authorrstone <rstone@FreeBSD.org>
Thu, 16 Feb 2017 19:41:13 +0000 (19:41 +0000)
committerrstone <rstone@FreeBSD.org>
Thu, 16 Feb 2017 19:41:13 +0000 (19:41 +0000)
commit943126a914ee992b0f1411039c57101b739ace6c
treee289f1b381666786635e2f417ec971663bb2891b
parent32882dfcac6060432cf154fd67964e336f5a877f
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