git: 67bf33e04652 - stable/12 - rmlock(9): add an RM_DUPOK flag

Mitchell Horne mhorne at FreeBSD.org
Fri Apr 16 14:22:33 UTC 2021


The branch stable/12 has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=67bf33e04652b6dd1a948c8b93bb6bebbb1519d5

commit 67bf33e04652b6dd1a948c8b93bb6bebbb1519d5
Author:     Mitchell Horne <mhorne at FreeBSD.org>
AuthorDate: 2021-04-08 17:41:19 +0000
Commit:     Mitchell Horne <mhorne at FreeBSD.org>
CommitDate: 2021-04-16 14:20:37 +0000

    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)
---
 share/man/man9/rmlock.9 | 5 ++++-
 sys/kern/kern_rmlock.c  | 2 ++
 sys/sys/rmlock.h        | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/share/man/man9/rmlock.9 b/share/man/man9/rmlock.9
index d56d97cef6e1..a1e91b08812c 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 November 11, 2017
+.Dd April 12, 2021
 .Dt RMLOCK 9
 .Os
 .Sh NAME
@@ -167,6 +167,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 de2a5818c5bf..585ccce6d2a4 100644
--- a/sys/kern/kern_rmlock.c
+++ b/sys/kern/kern_rmlock.c
@@ -288,6 +288,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 cdcb6edc3b92..0eed3d3044bd 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);


More information about the dev-commits-src-all mailing list