freebsd-skq/lib/libc
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
..
aarch64 arm64 libc: hide .cerror, .curbrk, .minbrk for WITHOUT_SYMVER 2016-04-14 16:32:27 +00:00
amd64 libc: spelling fixes. 2016-04-30 01:24:24 +00:00
arm Revert a change that sneeked with 297619 2016-04-06 16:50:18 +00:00
capability use .Mt to mark up email addresses consistently (part4) 2014-06-23 08:25:03 +00:00
compat-43 Use ANSI C prototypes. Eliminates -Wold-style-definition warnings. 2015-09-20 20:53:24 +00:00
db libc: make more use of the howmany() macro when available. 2016-04-26 01:17:05 +00:00
gdtoa META MODE: Don't create .meta files when symlinking sources into the obj directory. 2015-11-25 19:44:43 +00:00
gen Add implementation of robust mutexes, hopefully close enough to the 2016-05-17 09:56:22 +00:00
gmon Replace the last non-optional use of sbrk() in the tree with mmap(). 2016-01-21 18:17:19 +00:00
i386 libc: stop exporting curbrk and minbrk in the private namespace 2016-03-24 18:47:19 +00:00
iconv iconvctl(3): remove superfluous NULL pointer tests 2016-05-14 00:35:35 +00:00
include Add implementation of robust mutexes, hopefully close enough to the 2016-05-17 09:56:22 +00:00
inet libc: do not include <sys/types.h> where <sys/param.h> was already included 2016-04-18 21:05:15 +00:00
isc libc: do not include <sys/types.h> where <sys/param.h> was already included 2016-04-18 21:05:15 +00:00
locale libc: spelling fixes. 2016-04-30 01:24:24 +00:00
md Bring the md5 functions into libc for internal use only. 2014-08-12 12:25:56 +00:00
mips libc: stop exporting cerror 2016-03-30 14:42:09 +00:00
nameser libc: spelling fixes. 2016-04-30 01:24:24 +00:00
net Don't call free_addrselectpolicy(&policyhead) before policyhead has been 2016-05-16 08:13:30 +00:00
nls Move logic to destroy a struct catentry to its own function. 2016-02-02 23:33:58 +00:00
posix1e libc: spelling fixes. 2016-04-30 01:24:24 +00:00
powerpc libc: make some more use of the nitems() macro. 2016-04-16 17:52:00 +00:00
powerpc64 libc: make some more use of the nitems() macro. 2016-04-16 17:52:00 +00:00
quad Remove MK_ARM_EABI, the armeb issues have been fixed. The code to support 2014-10-01 08:26:51 +00:00
regex libc: spelling fixes. 2016-04-30 01:24:24 +00:00
resolv Since rdata is only used as an argument to the immediately following 2016-05-16 01:38:24 +00:00
riscv libc: stop exporting curbrk and minbrk in the private namespace 2016-03-24 18:47:19 +00:00
rpc libc: spelling fixes. 2016-04-30 01:24:24 +00:00
secure libc: do not include <sys/types.h> where <sys/param.h> was already included 2016-04-18 21:05:15 +00:00
softfloat libc: replace 0 with NULL for pointers. 2016-04-10 19:33:58 +00:00
sparc64 libc: spelling fixes. 2016-04-30 01:24:24 +00:00
stdio libc: Actually export fopencookie(3) 2016-05-12 21:30:22 +00:00
stdlib Update jemalloc to 4.2.0. 2016-05-13 04:03:20 +00:00
stdtime Implement (ACFLAGS|CFLAGS|CXXFLAGS).SRC globally. 2016-03-26 03:46:12 +00:00
string libc: spelling fixes. 2016-04-30 01:24:24 +00:00
sys Add thr*.2 and _umtx_op.2 manpages to the build. 2016-05-14 09:43:28 +00:00
tests iconvctl(3): remove superfluous NULL pointer tests 2016-05-14 00:35:35 +00:00
uuid libc: replace 0 with NULL for pointers. 2016-04-10 19:33:58 +00:00
xdr libc/xdr: unsign some loop indexes. 2016-05-06 16:03:40 +00:00
yp libc: do not include <sys/types.h> where <sys/param.h> was already included 2016-04-18 21:05:15 +00:00
libc.ldscript Attempt to move the POSIX iconv* symbols out of runtime linker space. 2013-11-17 22:52:17 +00:00
Makefile MFH 2016-04-04 23:55:32 +00:00
Makefile.depend DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
Versions.def Fix the inheritance of the FBSDprivate_1.0 namespace. 2014-04-03 17:31:38 +00:00