]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Don't place threads on the run queue after waking up other CPUs.
authorJohn Baldwin <jhb@FreeBSD.org>
Sat, 12 Nov 2016 00:14:13 +0000 (00:14 +0000)
committerJohn Baldwin <jhb@FreeBSD.org>
Sat, 12 Nov 2016 00:14:13 +0000 (00:14 +0000)
commita6b91f0f4577a267241f6c33756b3c5ca4ad0550
tree4d0364a275fa2cc875aa3035dd1ab4495741867e
parent2ed1e385b00d98c25c11d6aa8183a20e44128e3d
Don't place threads on the run queue after waking up other CPUs.

The other CPU might resume and see a still-empty runq and go back to
sleep before sched_add() adds the thread to the runq.  This results
in a lost wakeup and a potential hang if the system is otherwise
completely idle.

The race originated due to a micro-optimization (my fault) in 4BSD in
that it avoided putting a thread on the run queue if the scheduler was
going to preempt to the new thread.  To avoid complexity while fixing
this race, just drop this optimization.  4BSD now always sets the
"owepreempt" flag when a preemption is warranted and defers the actual
preemption to the thread_unlock of the caller the same as ULE.

MFC after: 2 weeks
Sponsored by: Netflix
sys/kern/sched_4bsd.c