summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2014-02-01 21:22:30 +0000
committermiod <miod@openbsd.org>2014-02-01 21:22:30 +0000
commit605d31ea31773f55f658da35c4cf8d03d8ab4062 (patch)
tree32f724cd986b3ffcadc4e4242404e4f63289c428
parentpools aren't mp-safe; since the TLB shootdown code will allocate up to 6 job (diff)
downloadwireguard-openbsd-605d31ea31773f55f658da35c4cf8d03d8ab4062.tar.xz
wireguard-openbsd-605d31ea31773f55f658da35c4cf8d03d8ab4062.zip
Simplify try_lock() to avoid one forward branch in the common case.
-rw-r--r--sys/arch/alpha/alpha/mutex.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/arch/alpha/alpha/mutex.c b/sys/arch/alpha/alpha/mutex.c
index 57d07f5ac52..ca309024952 100644
--- a/sys/arch/alpha/alpha/mutex.c
+++ b/sys/arch/alpha/alpha/mutex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.c,v 1.8 2014/01/26 17:40:09 miod Exp $ */
+/* $OpenBSD: mutex.c,v 1.9 2014/02/01 21:22:30 miod Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -46,9 +46,8 @@ try_lock(struct mutex *mtx)
" mb \n"
" bis $31, 1, %1 \n" /* v0 = 1 */
" br 4f \n"
- "2: bis $31, $31, %1 \n" /* v0 = 0 */
- " br 4f \n"
"3: br 1b \n" /* update failed */
+ "2: bis $31, $31, %1 \n" /* v0 = 0 */
"4: \n"
: "=&r" (t0), "=r" (v0), "=m" (mtx->mtx_lock)
: "m" (mtx->mtx_lock)
@@ -67,6 +66,9 @@ mtx_init(struct mutex *mtx, int wantipl)
mtx->mtx_oldipl = IPL_NONE;
mtx->mtx_wantipl = wantipl;
mtx->mtx_lock = 0;
+#ifdef MULTIPROCESSOR
+ mtx->mtx_owner = NULL;
+#endif
}
void