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:
This commit is contained in:
Mateusz Guzik 2022-08-16 12:22:31 +00:00
parent 9e4e7bcaef
commit 9488262679
2 changed files with 8 additions and 1 deletions

View File

@ -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();

View File

@ -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.