Module Name: src Committed By: riastradh Date: Fri Feb 24 11:11:10 UTC 2023
Modified Files: src/sys/kern: kern_rwlock.c Log Message: rwlock(9): Omit needless macro indirection for membars. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/kern/kern_rwlock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_rwlock.c diff -u src/sys/kern/kern_rwlock.c:1.69 src/sys/kern/kern_rwlock.c:1.70 --- src/sys/kern/kern_rwlock.c:1.69 Fri Feb 24 11:02:27 2023 +++ src/sys/kern/kern_rwlock.c Fri Feb 24 11:11:10 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_rwlock.c,v 1.69 2023/02/24 11:02:27 riastradh Exp $ */ +/* $NetBSD: kern_rwlock.c,v 1.70 2023/02/24 11:11:10 riastradh Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2019, 2020 @@ -45,7 +45,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.69 2023/02/24 11:02:27 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.70 2023/02/24 11:11:10 riastradh Exp $"); #include "opt_lockdebug.h" @@ -98,12 +98,6 @@ do { \ #endif /* DIAGNOSTIC */ /* - * Memory barriers. - */ -#define RW_MEMBAR_ACQUIRE() membar_acquire() -#define RW_MEMBAR_RELEASE() membar_release() - -/* * For platforms that do not provide stubs, or for the LOCKDEBUG case. */ #ifdef LOCKDEBUG @@ -337,7 +331,7 @@ rw_vector_enter(krwlock_t *rw, const krw ~RW_WRITE_WANTED); if (__predict_true(next == owner)) { /* Got it! */ - RW_MEMBAR_ACQUIRE(); + membar_acquire(); break; } @@ -465,7 +459,7 @@ rw_vector_exit(krwlock_t *rw) * proceed to do direct handoff if there are waiters, and if the * lock would become unowned. */ - RW_MEMBAR_RELEASE(); + membar_release(); for (;;) { newown = (owner - decr); if ((newown & (RW_THREAD | RW_HAS_WAITERS)) == RW_HAS_WAITERS) @@ -579,7 +573,7 @@ rw_vector_tryenter(krwlock_t *rw, const RW_ASSERT(rw, (op != RW_READER && RW_OWNER(rw) == curthread) || (op == RW_READER && RW_COUNT(rw) != 0)); - RW_MEMBAR_ACQUIRE(); + membar_acquire(); return 1; } @@ -606,8 +600,7 @@ rw_downgrade(krwlock_t *rw) __USE(curthread); #endif - RW_MEMBAR_RELEASE(); - + membar_release(); for (owner = rw->rw_owner;; owner = next) { /* * If there are no waiters we can do this the easy way. Try @@ -705,7 +698,7 @@ rw_tryupgrade(krwlock_t *rw) newown = curthread | RW_WRITE_LOCKED | (owner & ~RW_THREAD); next = rw_cas(rw, owner, newown); if (__predict_true(next == owner)) { - RW_MEMBAR_ACQUIRE(); + membar_acquire(); break; } RW_ASSERT(rw, (next & RW_WRITE_LOCKED) == 0);