Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern mutex(9): Convert to membar_acquire/release.



details:   https://anonhg.NetBSD.org/src/rev/a57361d0fbec
branches:  trunk
changeset: 365169:a57361d0fbec
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Apr 09 23:46:10 2022 +0000

description:
mutex(9): Convert to membar_acquire/release.

Except for setting the waiters bit -- not sure if this is actually
required to be store-before-load/store.  Seems unlikely -- surely
we'd have seen some serious bug by now if not, because membar_enter
has failed to guarantee that on x86! -- but I'm leaving it for now
until I have time to think enough about it to be sure one way or
another.

diffstat:

 sys/kern/kern_mutex.c |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (51 lines):

diff -r b8af0509e482 -r a57361d0fbec sys/kern/kern_mutex.c
--- a/sys/kern/kern_mutex.c     Sat Apr 09 23:45:45 2022 +0000
+++ b/sys/kern/kern_mutex.c     Sat Apr 09 23:46:10 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_mutex.c,v 1.98 2021/08/25 04:13:42 thorpej Exp $  */
+/*     $NetBSD: kern_mutex.c,v 1.99 2022/04/09 23:46:10 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #define        __MUTEX_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.98 2021/08/25 04:13:42 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.99 2022/04/09 23:46:10 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -169,10 +169,12 @@
  */
 #ifdef __HAVE_ATOMIC_AS_MEMBAR
 #define        MUTEX_MEMBAR_ENTER()
-#define        MUTEX_MEMBAR_EXIT()
+#define        MUTEX_MEMBAR_ACQUIRE()
+#define        MUTEX_MEMBAR_RELEASE()
 #else
 #define        MUTEX_MEMBAR_ENTER()            membar_enter()
-#define        MUTEX_MEMBAR_EXIT()             membar_exit()
+#define        MUTEX_MEMBAR_ACQUIRE()          membar_acquire()
+#define        MUTEX_MEMBAR_RELEASE()          membar_release()
 #endif
 
 /*
@@ -238,7 +240,7 @@
        MUTEX_INHERITDEBUG(oldown, mtx->mtx_owner);
        MUTEX_INHERITDEBUG(newown, oldown);
        rv = MUTEX_CAS(&mtx->mtx_owner, oldown, newown);
-       MUTEX_MEMBAR_ENTER();
+       MUTEX_MEMBAR_ACQUIRE();
        return rv;
 }
 
@@ -256,7 +258,7 @@
 {
        uintptr_t newown;
 
-       MUTEX_MEMBAR_EXIT();
+       MUTEX_MEMBAR_RELEASE();
        newown = 0;
        MUTEX_INHERITDEBUG(newown, mtx->mtx_owner);
        mtx->mtx_owner = newown;



Home | Main Index | Thread Index | Old Index