1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-24 11:29:10 +00:00
freebsd/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
check_internal_locks.d sys/compat/linux*: spelling fixes. 2016-04-30 00:53:10 +00:00
linux_common.c
linux_dtrace.h Fix style issues around existing SDT probes. 2015-12-16 23:39:27 +00:00
linux_emul.c
linux_emul.h
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
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
linux_getcwd.c
linux_ioctl.c compat/linux: for pointers replace 0 with NULL. 2016-04-15 16:21:13 +00:00
linux_ioctl.h
linux_ipc.c
linux_ipc.h
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
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
linux_signal.h
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
linux_sysproto.h
linux_time.c
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
linux_uid16.c
linux_util.c
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
linux_vdso.h
linux_videodev2_compat.h
linux_videodev_compat.h
linux.c
linux.h
stats_timing.d
trace_futexes.d sys/compat/linux*: spelling fixes. 2016-04-30 00:53:10 +00:00