summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2019-10-21 10:06:31 +0000
committermpi <mpi@openbsd.org>2019-10-21 10:06:31 +0000
commitb29f95ed91510d6e57d96025ff793fcba62ce631 (patch)
treef11cc0475d62132c5f49d1a23a7e9acd24f6056c /lib
parentKill unused _wait() function. (diff)
downloadwireguard-openbsd-b29f95ed91510d6e57d96025ff793fcba62ce631.tar.xz
wireguard-openbsd-b29f95ed91510d6e57d96025ff793fcba62ce631.zip
Use process-private futexes to avoid the uvm_map lookup overhead.
While here kill unused _wait() function. ok visa@
Diffstat (limited to 'lib')
-rw-r--r--lib/librthread/synch.h17
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/librthread/synch.h b/lib/librthread/synch.h
index 2cec188e265..eee41d78e8b 100644
--- a/lib/librthread/synch.h
+++ b/lib/librthread/synch.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: synch.h,v 1.4 2018/06/08 13:53:01 pirofti Exp $ */
+/* $OpenBSD: synch.h,v 1.5 2019/10/21 10:06:31 mpi Exp $ */
/*
* Copyright (c) 2017 Martin Pieuchot
*
@@ -22,14 +22,7 @@
static inline int
_wake(volatile uint32_t *p, int n)
{
- return futex(p, FUTEX_WAKE, n, NULL, NULL);
-}
-
-static inline void
-_wait(volatile uint32_t *p, int val)
-{
- while (*p != (uint32_t)val)
- futex(p, FUTEX_WAIT, val, NULL, NULL);
+ return futex(p, FUTEX_WAKE_PRIVATE, n, NULL, NULL);
}
static inline int
@@ -38,7 +31,7 @@ _twait(volatile uint32_t *p, int val, clockid_t clockid, const struct timespec *
struct timespec rel;
if (abs == NULL)
- return futex(p, FUTEX_WAIT, val, NULL, NULL);
+ return futex(p, FUTEX_WAIT_PRIVATE, val, NULL, NULL);
if (abs->tv_nsec >= 1000000000 || clock_gettime(clockid, &rel))
return (EINVAL);
@@ -51,11 +44,11 @@ _twait(volatile uint32_t *p, int val, clockid_t clockid, const struct timespec *
if (rel.tv_sec < 0)
return (ETIMEDOUT);
- return futex(p, FUTEX_WAIT, val, &rel, NULL);
+ return futex(p, FUTEX_WAIT_PRIVATE, val, &rel, NULL);
}
static inline int
_requeue(volatile uint32_t *p, int n, int m, volatile uint32_t *q)
{
- return futex(p, FUTEX_REQUEUE, n, (void *)(long)m, q);
+ return futex(p, FUTEX_REQUEUE_PRIVATE, n, (void *)(long)m, q);
}