freebsd-nq/sys
Konstantin Belousov 2a339d9e3d Add implementation of robust mutexes, hopefully close enough to the
intention of the POSIX IEEE Std 1003.1TM-2008/Cor 1-2013.

A robust mutex is guaranteed to be cleared by the system upon either
thread or process owner termination while the mutex is held.  The next
mutex locker is then notified about inconsistent mutex state and can
execute (or abandon) corrective actions.

The patch mostly consists of small changes here and there, adding
neccessary checks for the inconsistent and abandoned conditions into
existing paths.  Additionally, the thread exit handler was extended to
iterate over the userspace-maintained list of owned robust mutexes,
unlocking and marking as terminated each of them.

The list of owned robust mutexes cannot be maintained atomically
synchronous with the mutex lock state (it is possible in kernel, but
is too expensive).  Instead, for the duration of lock or unlock
operation, the current mutex is remembered in a special slot that is
also checked by the kernel at thread termination.

Kernel must be aware about the per-thread location of the heads of
robust mutex lists and the current active mutex slot.  When a thread
touches a robust mutex for the first time, a new umtx op syscall is
issued which informs about location of lists heads.

The umtx sleep queues for PP and PI mutexes are split between
non-robust and robust.

Somewhat unrelated changes in the patch:
1. Style.
2. The fix for proper tdfind() call use in umtxq_sleep_pi() for shared
   pi mutexes.
3. Removal of the userspace struct pthread_mutex m_owner field.
4. The sysctl kern.ipc.umtx_vnode_persistent is added, which controls
   the lifetime of the shared mutex associated with a vnode' page.

Reviewed by:	jilles (previous version, supposedly the objection was fixed)
Discussed with:	brooks, Martin Simmons <martin@lispworks.com> (some aspects)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
2016-05-17 09:56:22 +00:00
..
amd64 atomic: Add testandclear on i386/amd64 2016-05-16 07:19:33 +00:00
arm Add HWPMC_HOOKS to std.armv6 to make them available 2016-05-16 19:07:58 +00:00
arm64 Add intrng support to the GICv3 driver. It lacks ITS support so won't handle 2016-05-16 14:07:43 +00:00
boot Add proper PCIe init for MT7628/MT7688 SoCs 2016-05-17 06:45:25 +00:00
bsm
cam opt_kdtrace.h is not needed for SDT probes as of r258541. 2016-05-15 20:04:43 +00:00
cddl zfs_ioc_rename: fix a reversed condition 2016-05-17 07:56:05 +00:00
compat Add implementation of robust mutexes, hopefully close enough to the 2016-05-17 09:56:22 +00:00
conf [bwn] add in bwn n-phy linking. 2016-05-17 07:15:25 +00:00
contrib Make subsequent code reachable. 2016-05-15 22:35:11 +00:00
crypto aesni(4): Initialize error before use 2016-04-20 03:05:32 +00:00
ddb Add a small set of logical operators to DDB command language. 2016-05-16 19:42:38 +00:00
dev Extend the ICL interface to include the PDU pointer in the task_setup 2016-05-17 08:55:21 +00:00
fs Fix fuse for "cp" of a mode 0444 file to the file system. 2016-05-15 23:15:10 +00:00
gdb
geom Add an EARLY_AP_STARTUP option to start APs earlier during boot. 2016-05-14 18:22:52 +00:00
gnu [bwn] add initial bwn(4) N-PHY code, ported from Linux b43. 2016-05-17 07:09:24 +00:00
i386 atomic: Add testandclear on i386/amd64 2016-05-16 07:19:33 +00:00
isa sys/isa: minor spelling fixes. 2016-05-03 21:51:52 +00:00
kern Add implementation of robust mutexes, hopefully close enough to the 2016-05-17 09:56:22 +00:00
kgssapi kgssapi: insignificant spelling fix. 2016-05-03 22:05:03 +00:00
libkern sys: Make use of our rounddown() macro when sys/param.h is available. 2016-04-30 14:41:18 +00:00
mips Add proper PCIe init for MT7628/MT7688 SoCs 2016-05-17 06:45:25 +00:00
modules [bwn] add in bwn n-phy linking. 2016-05-17 07:15:25 +00:00
net Mark the unused arguments of various SYSINIT functions __unused. 2016-05-17 00:32:36 +00:00
net80211 Revert parts of r299575 in order to make more MIPS kernels build 2016-05-14 08:54:34 +00:00
netgraph sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
netinet This small change adopts the excellent suggestion for using named 2016-05-17 09:53:22 +00:00
netinet6 Use Node Information flag names instead of hard-coding their values. 2016-05-15 03:22:13 +00:00
netipsec netipsec: Fix minor style nit 2016-05-10 20:14:11 +00:00
netnatm kernel: use our nitems() macro when it is available through param.h. 2016-04-19 23:48:27 +00:00
netpfil Make named objects set-aware. Now it is possible to create named 2016-05-17 07:47:23 +00:00
netsmb sys/net*: minor spelling fixes. 2016-05-03 18:05:43 +00:00
nfs NFS: spelling fixes on comments. 2016-04-29 16:07:25 +00:00
nfsclient
nfsserver
nlm Remove slightly used const values that can be replaced with nitems(). 2016-04-21 15:38:28 +00:00
ofed sys/ofed: minor spelling fix. 2016-05-06 15:37:06 +00:00
opencrypto sys/opencrypto: minor spelling fixes. 2016-05-06 23:37:19 +00:00
pc98 Move 'device pci' for the PCI bus driver to the MI NOTES file. 2016-04-29 23:53:55 +00:00
powerpc Use OF_prop_free instead of direct call to free(9) 2016-05-14 20:06:38 +00:00
riscv Eliminate an unused #include. For a brief period of time, _unrhdr.h was 2016-05-13 20:14:41 +00:00
rpc sys/rpc: minor spelling fixes. 2016-05-06 01:49:46 +00:00
security sys/security: minor spelling fixes. 2016-05-06 16:59:04 +00:00
sparc64 sys/sparc64: minor spelling fixes. 2016-05-04 15:52:40 +00:00
sys Add implementation of robust mutexes, hopefully close enough to the 2016-05-17 09:56:22 +00:00
teken
tests
tools
ufs Fix comments. 2016-05-17 08:24:27 +00:00
vm Add implementation of robust mutexes, hopefully close enough to the 2016-05-17 09:56:22 +00:00
x86 Add an EARLY_AP_STARTUP option to start APs earlier during boot. 2016-05-14 18:22:52 +00:00
xdr RPC: for pointers replace 0 with NULL. 2016-04-14 17:06:37 +00:00
xen
Makefile Add riscv to the list of architectures for cscope. 2016-02-29 16:39:27 +00:00