git: kernel - Rewrite umtx_sleep() and umtx_wakeup()
dillon at crater.dragonflybsd.org
Mon Oct 16 11:30:38 PDT 2017
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date: Mon Oct 16 00:28:11 2017 -0700
kernel - Rewrite umtx_sleep() and umtx_wakeup()
* Rewrite umtx_sleep() and umtx_wakeup() to no longer use
vm_fault_page_quick(). Calling the VM fault code incurs a huge
overhead and creates massive contention when many threads are
using these calls.
The new code uses fuword(), translate to the physical address via
PTmap, and has very low overhead and basically zero contention.
* Instead, impose a mandatory timeout for umtx_sleep() and cap it
at 2 seconds (adjustable via sysctl kern.umtx_timeout_max, set
in microseconds). When the memory mapping underpinning a umtx
changes, userland will not stall for more than 2 seconds.
* The common remapping case caused by fork() is handled by the kernel
by immediately waking up all sleeping umtx_sleep() calls for the
* Any other copy-on-write or remapping cases will stall no more
than the maximum timeout (2 seconds). This might include paging
to/from swap, for example, which can remap the physical page
underpinning the umtx. This could also include user application
snafus or weirdness.
* umtx_sleep() and umtx_wakeup() still translate the user virtual
address to a physical address for the tsleep() and wakeup() operation.
This is done via a fault-protected access to the PTmap (the page-table
Summary of changes:
sys/kern/kern_fork.c | 8 ++-
sys/kern/kern_synch.c | 29 +++++++--
sys/kern/kern_umtx.c | 126 +++++++++++++++----------------------
sys/platform/pc64/x86_64/pmap.c | 23 +++++++
sys/platform/pc64/x86_64/support.s | 24 +++++++
sys/sys/systm.h | 2 +
sys/vm/pmap.h | 1 +
7 files changed, 130 insertions(+), 83 deletions(-)
DragonFly BSD source repository
More information about the Commits