freebsd-dev/sys
Attilio Rao 2028867def 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
..
amd64 For ia32 syscall(), call cpu_set_syscall_retval(). Update comment inside 2009-12-12 20:11:31 +00:00
arm Fix the build. 2009-12-08 21:42:04 +00:00
boot Cleanups the boot2 for pc98. There is no functional change. 2009-12-11 12:36:59 +00:00
bsm Add audit events for process descriptor system calls, which will appear in 2009-09-29 21:25:59 +00:00
cam Clear result before requesting XPT_PATH_INQ. 2009-12-09 14:21:21 +00:00
cddl Change VOP_FSYNC for zfs vnode from VOP_PANIC to zfs_freebsd_fsync(), 2009-12-05 20:36:42 +00:00
compat Regenerate. 2009-12-04 21:53:20 +00:00
conf MFp4: 2009-12-06 00:10:13 +00:00
contrib Merge ACPICA 20091112. 2009-11-16 21:47:12 +00:00
crypto
ddb Among signal generation syscalls, only sigqueue(2) is allowed by POSIX 2009-11-17 11:39:15 +00:00
dev Remove driver lock assertion in MII register access. This change 2009-12-12 00:06:43 +00:00
fs Allow using IPv6 in nfsrvd_sentcache() callback. 2009-12-08 23:43:50 +00:00
gdb
geom Change 'load' balancing mode algorithm: 2009-12-03 21:47:51 +00:00
gnu Remove unused code. 2009-12-03 18:16:14 +00:00
i386 for PV XEN translate page table entries from machine (real) to physical (logical) addresses so that kgdb can 2009-12-10 07:48:47 +00:00
ia64 In exception_save, write-back ar.rnat after switching the backing- 2009-12-08 00:44:23 +00:00
isa - Partially revert hackish r198964 and r199002. 2009-11-12 17:56:56 +00:00
kern In current code, threads performing an interruptible sleep (on both 2009-12-12 21:31:07 +00:00
kgssapi When the KOBJMETHOD() macro was updated, it resulted in the 2009-06-14 17:33:46 +00:00
libkern Move inet_aton() (specular to inet_ntoa(), already present in libkern) 2009-11-12 00:46:28 +00:00
mips Simplify the invocation of vm_fault(). Specifically, eliminate the flag 2009-11-27 20:24:11 +00:00
modules amdsbwd: new driver for AMD SB600/SB7xx watchdog timer 2009-11-30 11:44:03 +00:00
net Make the code buildable in userland so it is easier to test it: 2009-12-12 15:49:28 +00:00
net80211 Fix typo in comment 2009-12-08 00:54:08 +00:00
netatalk Reverse misordered unlock and lock in at_control for netatalk phase I 2009-08-12 10:44:13 +00:00
netgraph Take a step towards removing if_watchdog/if_timer. Don't explicitly set 2009-11-06 14:55:01 +00:00
netinet use div64 when converting back the burst value for userland 2009-12-10 18:37:14 +00:00
netinet6 Adapt r197136 to IPv6 stack: 2009-11-19 13:39:07 +00:00
netipsec Enable IPcomp by default. 2009-11-29 20:47:43 +00:00
netipx Use queue(9) instead of hand-crafted link lists for the global IPX 2009-06-24 20:57:50 +00:00
netnatm
netncp
netsmb Don't print out a message on loading a module. 'kldload -v' and 'kldstat 2009-09-10 18:33:08 +00:00
nfs Revert rev 192323 (nfs_common.c only): 2009-07-12 03:53:52 +00:00
nfsclient Close a race with caching of -ve name lookups in the NFS client. 2009-10-16 19:30:48 +00:00
nfsserver Properly return an error reply if an NFS remove or link operation fails. 2009-12-03 20:59:28 +00:00
nlm Handle GRANTED_RES messages more gracefully: Send along a grant cookie 2009-10-07 19:50:14 +00:00
opencrypto In case the compression result is the same size as the orignal version, 2009-11-29 17:53:57 +00:00
pc98 Fix cut'n paste on the AR9280 entry. 2009-12-02 21:22:10 +00:00
pci intpm/sb700: force polling mode if configured interrupt is SMI 2009-09-19 08:56:28 +00:00
powerpc Unbreak build. 2009-12-06 17:26:43 +00:00
rpc Add a check for the connection being shut down to the krpc 2009-11-08 19:02:13 +00:00
security Having thrown the cat out of the house, add a necessary include. 2009-09-08 13:24:36 +00:00
sparc64 Add additional checks of the kernel stack addresses in order to 2009-12-08 20:18:54 +00:00
sun4v Add additional checks of the kernel stack addresses in order to 2009-12-08 20:18:54 +00:00
sys In current code, threads performing an interruptible sleep (on both 2009-12-12 21:31:07 +00:00
teken Place home and end before insert and delete. 2009-11-11 09:43:26 +00:00
tools Output a comment on top of each generated file explaining where it came 2009-10-25 09:48:21 +00:00
ufs Don't build ufs_gjournal.c at all if UFS_GJOURNAL option is not given 2009-09-22 16:22:05 +00:00
vm Remove trailing ";" in UMA_HASH_INSERT and UMA_HASH_REMOVE macros. 2009-12-05 17:45:56 +00:00
xdr Add a check for a NULL mbuf ptr at the beginning of xdrmbuf_inline() 2009-08-12 16:27:51 +00:00
xen Temporarily revert the new-bus locking for 8.0 release. It will be 2009-08-20 19:17:53 +00:00
Makefile