freebsd-dev/sys
Mateusz Guzik 9feec7ef69 rw: decrease writer starvation
Writers waiting on readers to finish can set the RW_LOCK_WRITE_SPINNER
bit. This prevents most new readers from coming on. However, the last
reader to unlock also clears the bit which means new readers can sneak
in and the cycle starts over.

Change the code to keep the bit after last unlock.

Note that starvation potential is still there: no matter how many write
spinners are there, there is one bit. After the writer unlocks, the lock
is free to get raided by readers again. It is good enough for the time
being.

The real fix would include counting writers.

This runs into a caveat: the writer which set the bit may now be preempted.
In order to get rid of the problem all attempts to set the bit are preceeded
with critical_enter.

The bit gets cleared when the thread which set it goes to sleep. This way
an invariant holds that if the bit is set, someone is actively spinning and
will grab the lock soon. In particular this means that readers which find
the lock in this transient state can safely spin until the lock finds itself
an owner (i.e. they don't need to block nor speculate how long to spin
speculatively).

Tested by:	pho
2018-05-22 07:16:39 +00:00
..
amd64 Cleanups related to debug exceptions on x86. 2018-05-22 00:45:00 +00:00
arm aw_mmc: Correctly reset the mmc controller 2018-05-21 21:15:46 +00:00
arm64 Restrict the faulting addresses we call pmap_fault from to just those that 2018-05-21 16:14:53 +00:00
bsm
cam Hold the reference count until the CCB is released 2018-05-15 22:22:10 +00:00
cddl Fix 'zpool create -t <tempname>' 2018-05-15 13:27:29 +00:00
compat ifnet: Replace if_addr_lock rwlock with epoch + mutex 2018-05-18 20:13:34 +00:00
conf Add an IPMI attachment for PowerNV systems 2018-05-22 03:57:32 +00:00
contrib ifnet: Replace if_addr_lock rwlock with epoch + mutex 2018-05-18 20:13:34 +00:00
crypto disable printing value of SKEIN_LOOP during standard out, 2018-05-19 18:27:14 +00:00
ddb Fix PPC symbol resolution 2018-05-10 03:59:48 +00:00
dev Add Intel Spec Store Bypass Disable control. 2018-05-21 21:08:19 +00:00
dts arm: overlays: Update to new path-based sugar format 2018-05-04 14:38:48 +00:00
fs nfsclient: warnings cleanups 2018-05-20 06:14:12 +00:00
gdb
geom Introduce the 'n' flag for the geli attach command. 2018-05-09 20:53:38 +00:00
gnu gnu/dts: Update our copy of arm dts from Linux 4.16 2018-04-20 19:37:08 +00:00
i386 fix i386 builds after r334005 and r334009 2018-05-22 05:09:33 +00:00
isa
kern rw: decrease writer starvation 2018-05-22 07:16:39 +00:00
kgssapi
libkern Remove "All rights reserved" from my files. 2018-05-10 06:41:08 +00:00
mips Include kernel modules for MALTA kernels. 2018-05-16 17:54:40 +00:00
modules disable set but not used on code that can't be changed 2018-05-19 04:46:34 +00:00
net ck: simplify interface with libkvm consumers by defining ck_queue types 2018-05-21 01:53:23 +00:00
net80211 Use an accessor function to access ifr_data. 2018-03-30 18:50:13 +00:00
netgraph ifnet: Replace if_addr_lock rwlock with epoch + mutex 2018-05-18 20:13:34 +00:00
netinet inpcb: revert deferred inpcb free pending further review 2018-05-21 16:13:43 +00:00
netinet6 Pair CURVNET_SET and CURVNET_RESTORE in a block 2018-05-21 13:08:44 +00:00
netipsec Merge r1.22-1.23 from NetBSD: 2018-04-26 12:23:31 +00:00
netpfil Remove check for matching the rulenum, ruleid and rule pointer from 2018-05-21 16:19:00 +00:00
netsmb Eliminate the overhead of gratuitous repeated reinitialization of cap_rights 2018-05-09 18:47:24 +00:00
nfs ifnet: Replace if_addr_lock rwlock with epoch + mutex 2018-05-18 20:13:34 +00:00
nfsclient
nfsserver
nlm
ofed ifnet: Replace if_addr_lock rwlock with epoch + mutex 2018-05-18 20:13:34 +00:00
opencrypto cryptosoft: Do not exceed crd_len around *crypt_multi 2018-04-19 15:24:21 +00:00
powerpc Add an IPMI attachment for PowerNV systems 2018-05-22 03:57:32 +00:00
riscv Export a breakpoint() function to userland for riscv. 2018-05-16 16:56:35 +00:00
rpc
security Use an accessor function to access ifr_data. 2018-03-30 18:50:13 +00:00
sparc64 Enable kernel dump features in GENERIC for most platforms. 2018-05-19 19:53:23 +00:00
sys pmc: annotate locking for po_ssnext in pmc_owner 2018-05-22 05:49:40 +00:00
teken teken: Rename the "Set Cursor Style" sequence to match vt100.net docs 2018-05-21 20:35:16 +00:00
tests epoch(9): Make epochs non-preemptible by default 2018-05-18 17:29:43 +00:00
tools Add dtb overlays support 2018-03-24 21:30:24 +00:00
ufs ufs: remove cgbno variable where unused 2018-05-19 19:30:42 +00:00
vm Use the canonical check for reservation support. 2018-05-19 23:49:13 +00:00
x86 Cleanups related to debug exceptions on x86. 2018-05-22 00:45:00 +00:00
xdr
xen xen: fix gntdev 2018-05-02 10:19:17 +00:00
Makefile