summaryrefslogtreecommitdiffstats
path: root/sys/sys
diff options
context:
space:
mode:
authormjg <mjg@FreeBSD.org>2017-03-16 06:51:00 +0000
committermjg <mjg@FreeBSD.org>2017-03-16 06:51:00 +0000
commitd975a1ed7e0a13af274dc760127a8bf4b0da6130 (patch)
tree3a0140220b257844885738a3e4ace466d83c38e5 /sys/sys
parentf690d08c057e8a0ec75f68e6a3b2e1d3d68ec977 (diff)
downloadFreeBSD-src-d975a1ed7e0a13af274dc760127a8bf4b0da6130.zip
FreeBSD-src-d975a1ed7e0a13af274dc760127a8bf4b0da6130.tar.gz
MFC r313392,r313784:
rwlock: implement RW_LOCK_WRITER_RECURSED bit This moves recursion handling out of the inlined wunlock path and in particular saves a read and a branch. == rwlock: tidy up r313392 While a new bit was added and thread alignment got shifted to accomodate it, RW_READERS_SHIFT was not modified accordingly and clashed with the new flag. This was surprisingly harmless. If the lock was taken for writing, other flags were tested. If the lock was taken for reading, it would correctly work for readers > 1 and this was the only relevant test performed.
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/rwlock.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/sys/sys/rwlock.h b/sys/sys/rwlock.h
index d6dd4f0..aa4b0cc 100644
--- a/sys/sys/rwlock.h
+++ b/sys/sys/rwlock.h
@@ -58,13 +58,14 @@
#define RW_LOCK_READ_WAITERS 0x02
#define RW_LOCK_WRITE_WAITERS 0x04
#define RW_LOCK_WRITE_SPINNER 0x08
+#define RW_LOCK_WRITER_RECURSED 0x10
#define RW_LOCK_FLAGMASK \
(RW_LOCK_READ | RW_LOCK_READ_WAITERS | RW_LOCK_WRITE_WAITERS | \
- RW_LOCK_WRITE_SPINNER)
+ RW_LOCK_WRITE_SPINNER | RW_LOCK_WRITER_RECURSED)
#define RW_LOCK_WAITERS (RW_LOCK_READ_WAITERS | RW_LOCK_WRITE_WAITERS)
#define RW_OWNER(x) ((x) & ~RW_LOCK_FLAGMASK)
-#define RW_READERS_SHIFT 4
+#define RW_READERS_SHIFT 5
#define RW_READERS(x) (RW_OWNER((x)) >> RW_READERS_SHIFT)
#define RW_READERS_LOCK(x) ((x) << RW_READERS_SHIFT | RW_LOCK_READ)
#define RW_ONE_READER (1 << RW_READERS_SHIFT)
@@ -111,13 +112,9 @@
#define __rw_wunlock(rw, tid, file, line) do { \
uintptr_t _tid = (uintptr_t)(tid); \
\
- if ((rw)->rw_recurse) \
- (rw)->rw_recurse--; \
- else { \
- if (__predict_false(LOCKSTAT_PROFILE_ENABLED(rw__release) ||\
- !_rw_write_unlock((rw), _tid))) \
- _rw_wunlock_hard((rw), _tid, (file), (line)); \
- } \
+ if (__predict_false(LOCKSTAT_PROFILE_ENABLED(rw__release) || \
+ !_rw_write_unlock((rw), _tid))) \
+ _rw_wunlock_hard((rw), _tid, (file), (line)); \
} while (0)
/*
OpenPOWER on IntegriCloud