summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-09-21 05:38:59 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-09-21 05:38:59 +0000
commitce51284456df2cb8865dd86335df820b9343a1ee (patch)
tree946ee77ec76f3aeced30556b0963c41b670278d8 /sys/arch
parentee30ec5e8ba8e2b607c372529c4523d860f31c25 (diff)
Fix membar positioning in mtx_enter_try() and (critically!) mtx_leave()
Problem noticed and initial diff by kettenis@ ok kettenis@ visa@ dlg@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/alpha/alpha/mutex.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/arch/alpha/alpha/mutex.c b/sys/arch/alpha/alpha/mutex.c
index 345b94853bc..90eeb4d6f17 100644
--- a/sys/arch/alpha/alpha/mutex.c
+++ b/sys/arch/alpha/alpha/mutex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.c,v 1.14 2015/04/17 12:38:54 dlg Exp $ */
+/* $OpenBSD: mutex.c,v 1.15 2015/09/21 05:38:58 guenther Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -66,12 +66,12 @@ mtx_enter_try(struct mutex *mtx)
panic("mtx %p: locking against myself", mtx);
#endif
if (owner == NULL) {
+ membar_enter();
if (mtx->mtx_wantipl != IPL_NONE)
mtx->mtx_oldipl = s;
#ifdef DIAGNOSTIC
ci->ci_mutex_level++;
#endif
- membar_enter();
return (1);
}
@@ -115,14 +115,14 @@ mtx_leave(struct mutex *mtx)
MUTEX_ASSERT_LOCKED(mtx);
-#ifdef MULTIPROCESSOR
- membar_exit();
-#endif
#ifdef DIAGNOSTIC
curcpu()->ci_mutex_level--;
#endif
s = mtx->mtx_oldipl;
+#ifdef MULTIPROCESSOR
+ membar_exit();
+#endif
mtx->mtx_owner = NULL;
if (mtx->mtx_wantipl != IPL_NONE)
splx(s);