freebsd-dev/sys/compat/linux
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
..
check_error.d Switch linuxulator to use the native 1:1 threads. 2015-05-24 14:53:16 +00:00
check_internal_locks.d sys/compat/linux*: spelling fixes. 2016-04-30 00:53:10 +00:00
linux_common.c Move FEATURE macros for v4l and v4l2 to the common module. 2015-05-24 16:00:01 +00:00
linux_dtrace.h Fix style issues around existing SDT probes. 2015-12-16 23:39:27 +00:00
linux_emul.c Finish r283544. In exec case properly detach threads from user space 2015-06-06 06:12:14 +00:00
linux_emul.h Print out unsupported futex operation message only once for the process. 2015-05-24 17:25:57 +00:00
linux_event.c When write(2) on eventfd object fails with the error EAGAIN do not return 2016-03-26 19:16:53 +00:00
linux_event.h Add EPOLLRDHUP support. 2015-06-20 05:40:35 +00:00
linux_file.c Cleanup redundant parenthesis from existing howmany()/roundup() macro uses. 2016-04-22 16:57:42 +00:00
linux_file.h Add several fcntl flags. 2015-05-24 16:32:52 +00:00
linux_fork.c Add implementation of robust mutexes, hopefully close enough to the 2016-05-17 09:56:22 +00:00
linux_futex.c Change linux get_robust_list system call to match actual linux one. 2016-01-14 10:13:58 +00:00
linux_futex.h Switch linuxulator to use the native 1:1 threads. 2015-05-24 14:53:16 +00:00
linux_getcwd.c Where possible we will use M_LINUX malloc(9) type. 2015-05-24 16:14:41 +00:00
linux_ioctl.c compat/linux: for pointers replace 0 with NULL. 2016-04-15 16:21:13 +00:00
linux_ioctl.h The latest cp tool is trying to use the btrfs clone operation that is 2015-05-24 18:12:04 +00:00
linux_ipc.c x86_64 Linux do not use multiplexing on ipc system calls. 2015-05-24 15:44:41 +00:00
linux_ipc.h x86_64 Linux do not use multiplexing on ipc system calls. 2015-05-24 15:44:41 +00:00
linux_mib.c osd(9): Change array pointer to array pointer type from void* 2016-04-26 19:57:35 +00:00
linux_mib.h Update Linux compat revision to 32. 2015-05-24 16:55:32 +00:00
linux_misc.c sys/compat/linux*: spelling fixes. 2016-04-30 00:53:10 +00:00
linux_misc.h More complete implementation of /proc/self/limits. 2016-04-10 07:11:29 +00:00
linux_signal.c Rework signal code to allow using it by other modules, like linprocfs: 2015-05-24 17:47:20 +00:00
linux_signal.h Rework signal code to allow using it by other modules, like linprocfs: 2015-05-24 17:47:20 +00:00
linux_socket.c kernel: use our nitems() macro when it is available through param.h. 2016-04-19 23:48:27 +00:00
linux_socket.h sys/compat/linux*: spelling fixes. 2016-04-30 00:53:10 +00:00
linux_stats.c Check bsd_to_linux_statfs() return value. Forgotten in r297070. 2016-03-20 19:06:21 +00:00
linux_sysctl.c Where possible we will use M_LINUX malloc(9) type. 2015-05-24 16:14:41 +00:00
linux_sysproto.h
linux_time.c Linux nanosleep() and clock_nanosleep() system calls always 2015-05-24 18:14:38 +00:00
linux_timer.c Return EINVAL in case of incorrect sigev_signo value specified instead of panicing. 2015-12-26 09:09:49 +00:00
linux_timer.h Delete the duplicate of linux_to_native_clockid() function. 2015-05-24 17:30:31 +00:00
linux_uid16.c Where possible we will use M_LINUX malloc(9) type. 2015-05-24 16:14:41 +00:00
linux_util.c Implement epoll family system calls. This is a tiny wrapper 2015-05-24 16:41:39 +00:00
linux_util.h As <machine/vmparam.h> is included from <vm/vm_param.h>, there is no 2016-02-22 09:08:04 +00:00
linux_vdso.c Add 64 bit support to the vdso. 2015-05-24 15:45:36 +00:00
linux_vdso.h Add 64 bit support to the vdso. 2015-05-24 15:45:36 +00:00
linux_videodev2_compat.h
linux_videodev_compat.h
linux.c Rework signal code to allow using it by other modules, like linprocfs: 2015-05-24 17:47:20 +00:00
linux.h Rework signal code to allow using it by other modules, like linprocfs: 2015-05-24 17:47:20 +00:00
stats_timing.d Switch linuxulator to use the native 1:1 threads. 2015-05-24 14:53:16 +00:00
trace_futexes.d sys/compat/linux*: spelling fixes. 2016-04-30 00:53:10 +00:00