aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Horne <mhorne@FreeBSD.org>2021-04-08 17:41:19 +0000
committerMitchell Horne <mhorne@FreeBSD.org>2021-04-16 13:48:02 +0000
commit6fa1d613a82582e0da87169b994a5c0080258a82 (patch)
tree0c0dd6c1b774250558b507ef1e3ac237ae59a04b
parent17b0a38d96feb77d4b019ab9108b2c5050273823 (diff)
downloadsrc-6fa1d613a82582e0da87169b994a5c0080258a82.tar.gz
src-6fa1d613a82582e0da87169b994a5c0080258a82.zip
rmlock(9): add an RM_DUPOK flag
Allows for duplicate locks to be acquired without witness complaining. Similar flags exists already for rwlock(9) and sx(9). Reviewed by: markj Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. (cherry picked from commit 2816bd8442bc323d50434d0e64cb4b7c10a195e8)
-rw-r--r--share/man/man9/rmlock.95
-rw-r--r--sys/kern/kern_rmlock.c2
-rw-r--r--sys/sys/rmlock.h1
3 files changed, 7 insertions, 1 deletions
diff --git a/share/man/man9/rmlock.9 b/share/man/man9/rmlock.9
index 53de7c73b79a..6d128f986968 100644
--- a/share/man/man9/rmlock.9
+++ b/share/man/man9/rmlock.9
@@ -26,7 +26,7 @@
.\" $FreeBSD$
.\"
.\" Based on rwlock.9 man page
-.Dd December 27, 2019
+.Dd April 12, 2021
.Dt RMLOCK 9
.Os
.Sh NAME
@@ -186,6 +186,9 @@ will assert that the
has not been initialized multiple times without intervening calls to
.Fn rm_destroy
unless this option is specified.
+.It Dv RM_DUPOK
+.Xr witness 4
+should not log messages about duplicate locks being acquired.
.El
.It Fn rm_rlock "struct rmlock *rm" "struct rm_priotracker* tracker"
Lock
diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c
index f661e209b633..7230a00e357b 100644
--- a/sys/kern/kern_rmlock.c
+++ b/sys/kern/kern_rmlock.c
@@ -289,6 +289,8 @@ rm_init_flags(struct rmlock *rm, const char *name, int opts)
liflags |= LO_RECURSABLE;
if (opts & RM_NEW)
liflags |= LO_NEW;
+ if (opts & RM_DUPOK)
+ liflags |= LO_DUPOK;
rm->rm_writecpus = all_cpus;
LIST_INIT(&rm->rm_activeReaders);
if (opts & RM_SLEEPABLE) {
diff --git a/sys/sys/rmlock.h b/sys/sys/rmlock.h
index 3e4db5d853c6..5aaf8f039026 100644
--- a/sys/sys/rmlock.h
+++ b/sys/sys/rmlock.h
@@ -48,6 +48,7 @@
#define RM_RECURSE 0x00000002
#define RM_SLEEPABLE 0x00000004
#define RM_NEW 0x00000008
+#define RM_DUPOK 0x00000010
void rm_init(struct rmlock *rm, const char *name);
void rm_init_flags(struct rmlock *rm, const char *name, int opts);