freebsd-skq/share
attilio b1c6888d87 In current code, threads performing an interruptible sleep (on both
sxlock, via the sx_{s, x}lock_sig() interface, or plain lockmgr), will
leave the waiters flag on forcing the owner to do a wakeup even when if
the waiter queue is empty.
That operation may lead to a deadlock in the case of doing a fake wakeup
on the "preferred" (based on the wakeup algorithm) queue while the other
queue has real waiters on it, because nobody is going to wakeup the 2nd
queue waiters and they will sleep indefinitively.

A similar bug, is present, for lockmgr in the case the waiters are
sleeping with LK_SLEEPFAIL on.  In this case, even if the waiters queue
is not empty, the waiters won't progress after being awake but they will
just fail, still not taking care of the 2nd queue waiters (as instead the
lock owned doing the wakeup would expect).

In order to fix this bug in a cheap way (without adding too much locking
and complicating too much the semantic) add a sleepqueue interface which
does report the actual number of waiters on a specified queue of a
waitchannel (sleepq_sleepcnt()) and use it in order to determine if the
exclusive waiters (or shared waiters) are actually present on the lockmgr
(or sx) before to give them precedence in the wakeup algorithm.
This fix alone, however doesn't solve the LK_SLEEPFAIL bug. In order to
cope with it, add the tracking of how many exclusive LK_SLEEPFAIL waiters
a lockmgr has and if all the waiters on the exclusive waiters queue are
LK_SLEEPFAIL just wake both queues.

The sleepq_sleepcnt() introduction and ABI breakage require
__FreeBSD_version bumping.

Reported by:	avg, kib, pho
Reviewed by:	kib
Tested by:	pho
2009-12-12 21:31:07 +00:00
..
colldef Add lv_LV, move lt_LT to common part 2009-09-03 16:53:11 +00:00
dict
doc Add the KNOWN-DEFECTS file back in for the 9.6.1 release. 2009-06-25 20:09:53 +00:00
examples Install firmware(9) examples. 2009-12-12 17:04:36 +00:00
info
man In current code, threads performing an interruptible sleep (on both 2009-12-12 21:31:07 +00:00
me
misc Record part of history I participated in. 2009-12-10 14:41:47 +00:00
mk Make `make cleanilinks' work in /sys/modules. 2009-12-06 08:59:19 +00:00
mklocale Add lv_LV, move lt_LT to common part 2009-09-03 17:12:45 +00:00
monetdef Last character is a space for the international currency symbol. 2009-09-13 22:17:23 +00:00
msgdef Add lv_LV 2009-09-04 06:19:37 +00:00
numericdef Add lv_LV 2009-09-03 17:37:23 +00:00
security
sendmail Dont install .svn metadata with the sendmail install. 2008-05-31 19:15:15 +00:00
skel Switch the default terminal emulation style to xterm for most platforms. 2009-11-13 05:54:55 +00:00
snmp
syscons Add various new keymaps: 2009-06-12 22:53:49 +00:00
tabset
termcap Update termcap entries for xterm. 2009-12-10 22:25:53 +00:00
timedef Since %b contains unit, %b is not suitable for c_fmt, now. Use %_m 2009-11-14 15:56:23 +00:00
zoneinfo Catch up with r130332 which changed the default timezone from GMT to UTC. 2009-11-17 16:29:39 +00:00
Makefile Whitespace nit 2008-10-08 13:20:02 +00:00
Makefile.inc