Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern hppa has custom adaptive mutexes. Allow it to buil...
details: https://anonhg.NetBSD.org/src/rev/a52571839aa6
branches: trunk
changeset: 968226:a52571839aa6
user: ad <ad%NetBSD.org@localhost>
date: Tue Jan 07 13:44:23 2020 +0000
description:
hppa has custom adaptive mutexes. Allow it to build again while not
reintroducing the main read of mtx_owner that I wanted to eliminate.
diffstat:
sys/arch/hppa/include/mutex.h | 10 +++++-----
sys/kern/kern_mutex.c | 18 +++++++++---------
2 files changed, 14 insertions(+), 14 deletions(-)
diffs (97 lines):
diff -r fc869dc83f5d -r a52571839aa6 sys/arch/hppa/include/mutex.h
--- a/sys/arch/hppa/include/mutex.h Tue Jan 07 13:20:18 2020 +0000
+++ b/sys/arch/hppa/include/mutex.h Tue Jan 07 13:44:23 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mutex.h,v 1.14 2019/11/29 20:05:29 riastradh Exp $ */
+/* $NetBSD: mutex.h,v 1.15 2020/01/07 13:44:23 ad Exp $ */
/*-
* Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -141,15 +141,15 @@
}
static inline int
-MUTEX_SPIN_P(const volatile struct kmutex *mtx)
+MUTEX_SPIN_P(const uintptr_t owner)
{
- return mtx->mtx_owner == MUTEX_SPIN_FLAG;
+ return owner == MUTEX_SPIN_FLAG;
}
static inline int
-MUTEX_ADAPTIVE_P(const volatile struct kmutex *mtx)
+MUTEX_ADAPTIVE_P(const uintptr_t owner)
{
- return mtx->mtx_owner != MUTEX_SPIN_FLAG;
+ return owner != MUTEX_SPIN_FLAG;
}
/* Acquire an adaptive mutex */
diff -r fc869dc83f5d -r a52571839aa6 sys/kern/kern_mutex.c
--- a/sys/kern/kern_mutex.c Tue Jan 07 13:20:18 2020 +0000
+++ b/sys/kern/kern_mutex.c Tue Jan 07 13:44:23 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_mutex.c,v 1.87 2020/01/06 11:12:55 ad Exp $ */
+/* $NetBSD: kern_mutex.c,v 1.88 2020/01/07 13:44:23 ad 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.87 2020/01/06 11:12:55 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.88 2020/01/07 13:44:23 ad Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -186,8 +186,8 @@
#define MUTEX_OWNER(owner) \
(owner & MUTEX_THREAD)
-#define MUTEX_HAS_WAITERS(owner) \
- ((owner & MUTEX_BIT_WAITERS) != 0)
+#define MUTEX_HAS_WAITERS(mtx) \
+ (((int)(mtx)->mtx_owner & MUTEX_BIT_WAITERS) != 0)
#define MUTEX_INITIALIZE_ADAPTIVE(mtx, dodebug) \
do { \
@@ -313,7 +313,7 @@
uintptr_t owner = mtx->mtx_owner;
pr("owner field : %#018lx wait/spin: %16d/%d\n",
- (long)MUTEX_OWNER(owner), MUTEX_HAS_WAITERS(owner),
+ (long)MUTEX_OWNER(owner), MUTEX_HAS_WAITERS(mtx),
MUTEX_SPIN_P(owner));
}
@@ -385,7 +385,7 @@
if (MUTEX_ADAPTIVE_P(owner)) {
MUTEX_ASSERT(mtx, !MUTEX_OWNED(owner) &&
- !MUTEX_HAS_WAITERS(owner));
+ !MUTEX_HAS_WAITERS(mtx));
} else {
MUTEX_ASSERT(mtx, !MUTEX_SPINBIT_LOCKED_P(mtx));
}
@@ -677,9 +677,9 @@
continue;
}
membar_consumer();
- owner = mtx->mtx_owner;
- if (!MUTEX_HAS_WAITERS(owner)) {
+ if (!MUTEX_HAS_WAITERS(mtx)) {
turnstile_exit(mtx);
+ owner = mtx->mtx_owner;
continue;
}
#endif /* MULTIPROCESSOR */
@@ -757,7 +757,7 @@
*/
{
int s = splhigh();
- if (!MUTEX_HAS_WAITERS(mtx->mtx_owner)) {
+ if (!MUTEX_HAS_WAITERS(mtx)) {
MUTEX_RELEASE(mtx);
splx(s);
return;
Home |
Main Index |
Thread Index |
Old Index