Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern rwlock(9): Fix membars.
details: https://anonhg.NetBSD.org/src/rev/b249a07fcd6e
branches: trunk
changeset: 373677:b249a07fcd6e
user: riastradh <riastradh%NetBSD.org@localhost>
date: Fri Feb 24 11:01:43 2023 +0000
description:
rwlock(9): Fix membars.
rw_downgrade must be a release operation, and rw_tryupgrade must be
an acquire operation. membar_producer is not enough -- need to use
membar_release and membar_acquire.
Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/02/22/msg028726.html
XXX pullup-8
XXX pullup-9
XXX pullup-10
diffstat:
sys/kern/kern_rwlock.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diffs (48 lines):
diff -r 893a09c791ac -r b249a07fcd6e sys/kern/kern_rwlock.c
--- a/sys/kern/kern_rwlock.c Thu Feb 23 14:57:29 2023 +0000
+++ b/sys/kern/kern_rwlock.c Fri Feb 24 11:01:43 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_rwlock.c,v 1.67 2023/01/27 09:28:41 ozaki-r Exp $ */
+/* $NetBSD: kern_rwlock.c,v 1.68 2023/02/24 11:01:43 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.67 2023/01/27 09:28:41 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.68 2023/02/24 11:01:43 riastradh Exp $");
#include "opt_lockdebug.h"
@@ -103,11 +103,9 @@
#ifdef __HAVE_ATOMIC_AS_MEMBAR
#define RW_MEMBAR_ACQUIRE()
#define RW_MEMBAR_RELEASE()
-#define RW_MEMBAR_PRODUCER()
#else
#define RW_MEMBAR_ACQUIRE() membar_acquire()
#define RW_MEMBAR_RELEASE() membar_release()
-#define RW_MEMBAR_PRODUCER() membar_producer()
#endif
/*
@@ -613,7 +611,7 @@
__USE(curthread);
#endif
- RW_MEMBAR_PRODUCER();
+ RW_MEMBAR_RELEASE();
for (owner = rw->rw_owner;; owner = next) {
/*
@@ -712,7 +710,7 @@
newown = curthread | RW_WRITE_LOCKED | (owner & ~RW_THREAD);
next = rw_cas(rw, owner, newown);
if (__predict_true(next == owner)) {
- RW_MEMBAR_PRODUCER();
+ RW_MEMBAR_ACQUIRE();
break;
}
RW_ASSERT(rw, (next & RW_WRITE_LOCKED) == 0);
Home |
Main Index |
Thread Index |
Old Index