]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC 308564: Don't place threads on the run queue after waking up other CPUs.
authorjhb <jhb@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 2 Dec 2016 22:27:54 +0000 (22:27 +0000)
committerjhb <jhb@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 2 Dec 2016 22:27:54 +0000 (22:27 +0000)
commit4e9fa5be54b4eaa212f5d5f645f06ddcad43f58f
treef47ebdf7624f111dae70e0bfb4bd57579703c561
parentddee3cb649981d8618d98a309cfd40fae3e05b29
MFC 308564: 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.

git-svn-id: svn://svn.freebsd.org/base/stable/10@309446 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/kern/sched_4bsd.c