From 9488262679d083ff0de97ff608f6a8a95291b13d Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Tue, 16 Aug 2022 12:22:31 +0000 Subject: [PATCH] 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.