git: 9488262679d0 - main - rms: add rms_assert_rlock_ok
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 23 Aug 2022 19:15:52 UTC
The branch main has been updated by mjg:
URL: https://cgit.FreeBSD.org/src/commit/?id=9488262679d083ff0de97ff608f6a8a95291b13d
commit 9488262679d083ff0de97ff608f6a8a95291b13d
Author: Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-08-16 12:22:31 +0000
Commit: Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2022-08-23 19:15:48 +0000
rms: add rms_assert_rlock_ok
So that callers which opportunistically elide the lock can still
assert that they can take it.
Reviewed by:
Differential Revision:
---
sys/kern/kern_rmlock.c | 2 +-
sys/sys/rmlock.h | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c
index d7dea8efc40e..8a39c6b0d880 100644
--- a/sys/kern/kern_rmlock.c
+++ b/sys/kern/kern_rmlock.c
@@ -1025,7 +1025,7 @@ rms_rlock(struct rmslock *rms)
{
struct rmslock_pcpu *pcpu;
- WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
+ rms_assert_rlock_ok(rms);
MPASS(atomic_load_ptr(&rms->owner) != curthread);
critical_enter();
diff --git a/sys/sys/rmlock.h b/sys/sys/rmlock.h
index 5aaf8f039026..6ff561c5e4b0 100644
--- a/sys/sys/rmlock.h
+++ b/sys/sys/rmlock.h
@@ -150,6 +150,13 @@ rms_wowned(struct rmslock *rms)
return (rms->owner == curthread);
}
+#ifdef INVARIANTS
+#define rms_assert_rlock_ok(x) \
+ WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
+#else
+#define rms_assert_rlock_ok(x)
+#endif
+
#ifdef INVARIANTS
/*
* For assertion purposes.