rwmlock/rwlock/sx: Print the pointer of destroyed locks in panic messages

Suggested by:	markj
Reviewed by:	kib, markj
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D49332

(cherry picked from commit 00d78c5007)
This commit is contained in:
John Baldwin 2025-03-13 12:54:40 -04:00
parent 33bf58fbd8
commit 6fb471682a
3 changed files with 23 additions and 20 deletions

View file

@ -601,7 +601,7 @@ _rm_wlock_debug(struct rmlock *rm, const char *file, int line)
("rm_wlock() by idle thread %p on rmlock %p @ %s:%d",
curthread, rm, file, line));
KASSERT(!rm_destroyed(rm),
("rm_wlock() of destroyed rmlock @ %s:%d", file, line));
("rm_wlock() of destroyed rmlock %p @ %s:%d", rm, file, line));
_rm_assert(rm, RA_UNLOCKED, file, line);
WITNESS_CHECKORDER(&rm->lock_object, LOP_NEWORDER | LOP_EXCLUSIVE,
@ -622,7 +622,7 @@ _rm_wunlock_debug(struct rmlock *rm, const char *file, int line)
return;
KASSERT(!rm_destroyed(rm),
("rm_wunlock() of destroyed rmlock @ %s:%d", file, line));
("rm_wunlock() of destroyed rmlock %p @ %s:%d", rm, file, line));
_rm_assert(rm, RA_WLOCKED, file, line);
WITNESS_UNLOCK(&rm->lock_object, LOP_EXCLUSIVE, file, line);
LOCK_LOG_LOCK("RMWUNLOCK", &rm->lock_object, 0, 0, file, line);
@ -652,7 +652,7 @@ _rm_rlock_debug(struct rmlock *rm, struct rm_priotracker *tracker,
("rm_rlock() by idle thread %p on rmlock %p @ %s:%d",
curthread, rm, file, line));
KASSERT(!rm_destroyed(rm),
("rm_rlock() of destroyed rmlock @ %s:%d", file, line));
("rm_rlock() of destroyed rmlock %p @ %s:%d", rm, file, line));
if (!trylock) {
KASSERT(!rm_wowned(rm),
("rm_rlock: wlock already held for %s @ %s:%d",
@ -686,7 +686,7 @@ _rm_runlock_debug(struct rmlock *rm, struct rm_priotracker *tracker,
return;
KASSERT(!rm_destroyed(rm),
("rm_runlock() of destroyed rmlock @ %s:%d", file, line));
("rm_runlock() of destroyed rmlock %p @ %s:%d", rm, file, line));
_rm_assert(rm, RA_RLOCKED, file, line);
WITNESS_UNLOCK(&rm->lock_object, 0, file, line);
LOCK_LOG_LOCK("RMRUNLOCK", &rm->lock_object, 0, 0, file, line);

View file

@ -281,7 +281,7 @@ _rw_wlock_cookie(volatile uintptr_t *c, const char *file, int line)
("rw_wlock() by idle thread %p on rwlock %p @ %s:%d",
curthread, rw, file, line));
KASSERT(rw->rw_lock != RW_DESTROYED,
("rw_wlock() of destroyed rwlock @ %s:%d", file, line));
("rw_wlock() of destroyed rwlock %p @ %s:%d", rw, file, line));
WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER | LOP_EXCLUSIVE, file,
line, NULL);
tid = (uintptr_t)curthread;
@ -314,7 +314,7 @@ __rw_try_wlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF)
("rw_try_wlock() by idle thread %p on rwlock %p @ %s:%d",
curthread, rw, file, line));
KASSERT(rw->rw_lock != RW_DESTROYED,
("rw_try_wlock() of destroyed rwlock @ %s:%d", file, line));
("rw_try_wlock() of destroyed rwlock %p @ %s:%d", rw, file, line));
rval = 1;
recursed = false;
@ -362,7 +362,7 @@ _rw_wunlock_cookie(volatile uintptr_t *c, const char *file, int line)
rw = rwlock2rw(c);
KASSERT(rw->rw_lock != RW_DESTROYED,
("rw_wunlock() of destroyed rwlock @ %s:%d", file, line));
("rw_wunlock() of destroyed rwlock %p @ %s:%d", rw, file, line));
__rw_assert(c, RA_WLOCKED, file, line);
WITNESS_UNLOCK(&rw->lock_object, LOP_EXCLUSIVE, file, line);
LOCK_LOG_LOCK("WUNLOCK", &rw->lock_object, 0, rw->rw_recurse, file,
@ -668,7 +668,7 @@ __rw_rlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF)
("rw_rlock() by idle thread %p on rwlock %p @ %s:%d",
td, rw, file, line));
KASSERT(rw->rw_lock != RW_DESTROYED,
("rw_rlock() of destroyed rwlock @ %s:%d", file, line));
("rw_rlock() of destroyed rwlock %p @ %s:%d", rw, file, line));
KASSERT(rw_wowner(rw) != td,
("rw_rlock: wlock already held for %p @ %s:%d",
rw, file, line));
@ -711,7 +711,8 @@ __rw_try_rlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF)
x = rw->rw_lock;
for (;;) {
KASSERT(rw->rw_lock != RW_DESTROYED,
("rw_try_rlock() of destroyed rwlock @ %s:%d", file, line));
("rw_try_rlock() of destroyed rwlock %p @ %s:%d", rw, file,
line));
if (!(x & RW_LOCK_READ))
break;
if (atomic_fcmpset_acq_ptr(&rw->rw_lock, &x, x + RW_ONE_READER)) {
@ -842,7 +843,7 @@ _rw_runlock_cookie_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF)
uintptr_t v;
KASSERT(rw->rw_lock != RW_DESTROYED,
("rw_runlock() of destroyed rwlock @ %s:%d", file, line));
("rw_runlock() of destroyed rwlock %p @ %s:%d", rw, file, line));
__rw_assert(&rw->rw_lock, RA_RLOCKED, file, line);
WITNESS_UNLOCK(&rw->lock_object, 0, file, line);
LOCK_LOG_LOCK("RUNLOCK", &rw->lock_object, 0, 0, file, line);
@ -1284,7 +1285,8 @@ __rw_try_upgrade_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF)
return (1);
KASSERT(rw->rw_lock != RW_DESTROYED,
("rw_try_upgrade() of destroyed rwlock @ %s:%d", file, line));
("rw_try_upgrade() of destroyed rwlock %p @ %s:%d", rw, file,
line));
__rw_assert(&rw->rw_lock, RA_RLOCKED, file, line);
/*
@ -1367,7 +1369,7 @@ __rw_downgrade_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF)
return;
KASSERT(rw->rw_lock != RW_DESTROYED,
("rw_downgrade() of destroyed rwlock @ %s:%d", file, line));
("rw_downgrade() of destroyed rwlock %p @ %s:%d", rw, file, line));
__rw_assert(&rw->rw_lock, RA_WLOCKED | RA_NOTRECURSED, file, line);
#ifndef INVARIANTS
if (rw_recursed(rw))

View file

@ -285,7 +285,8 @@ sx_try_slock_int(struct sx *sx LOCK_FILE_LINE_ARG_DEF)
x = sx->sx_lock;
for (;;) {
KASSERT(x != SX_LOCK_DESTROYED,
("sx_try_slock() of destroyed sx @ %s:%d", file, line));
("sx_try_slock() of destroyed sx %p @ %s:%d", sx, file,
line));
if (!(x & SX_LOCK_SHARED))
break;
if (atomic_fcmpset_acq_ptr(&sx->sx_lock, &x, x + SX_ONE_SHARER)) {
@ -321,7 +322,7 @@ _sx_xlock(struct sx *sx, int opts, const char *file, int line)
("sx_xlock() by idle thread %p on sx %p @ %s:%d",
curthread, sx, file, line));
KASSERT(sx->sx_lock != SX_LOCK_DESTROYED,
("sx_xlock() of destroyed sx @ %s:%d", file, line));
("sx_xlock() of destroyed sx %p @ %s:%d", sx, file, line));
WITNESS_CHECKORDER(&sx->lock_object, LOP_NEWORDER | LOP_EXCLUSIVE, file,
line, NULL);
tid = (uintptr_t)curthread;
@ -358,7 +359,7 @@ sx_try_xlock_int(struct sx *sx LOCK_FILE_LINE_ARG_DEF)
("sx_try_xlock() by idle thread %p on sx %p @ %s:%d",
curthread, sx, file, line));
KASSERT(sx->sx_lock != SX_LOCK_DESTROYED,
("sx_try_xlock() of destroyed sx @ %s:%d", file, line));
("sx_try_xlock() of destroyed sx %p @ %s:%d", sx, file, line));
rval = 1;
recursed = false;
@ -402,7 +403,7 @@ _sx_xunlock(struct sx *sx, const char *file, int line)
{
KASSERT(sx->sx_lock != SX_LOCK_DESTROYED,
("sx_xunlock() of destroyed sx @ %s:%d", file, line));
("sx_xunlock() of destroyed sx %p @ %s:%d", sx, file, line));
_sx_assert(sx, SA_XLOCKED, file, line);
WITNESS_UNLOCK(&sx->lock_object, LOP_EXCLUSIVE, file, line);
LOCK_LOG_LOCK("XUNLOCK", &sx->lock_object, 0, sx->sx_recurse, file,
@ -431,7 +432,7 @@ sx_try_upgrade_int(struct sx *sx LOCK_FILE_LINE_ARG_DEF)
return (1);
KASSERT(sx->sx_lock != SX_LOCK_DESTROYED,
("sx_try_upgrade() of destroyed sx @ %s:%d", file, line));
("sx_try_upgrade() of destroyed sx %p @ %s:%d", sx, file, line));
_sx_assert(sx, SA_SLOCKED, file, line);
/*
@ -481,7 +482,7 @@ sx_downgrade_int(struct sx *sx LOCK_FILE_LINE_ARG_DEF)
return;
KASSERT(sx->sx_lock != SX_LOCK_DESTROYED,
("sx_downgrade() of destroyed sx @ %s:%d", file, line));
("sx_downgrade() of destroyed sx %p @ %s:%d", sx, file, line));
_sx_assert(sx, SA_XLOCKED | SA_NOTRECURSED, file, line);
#ifndef INVARIANTS
if (sx_recursed(sx))
@ -1260,7 +1261,7 @@ _sx_slock_int(struct sx *sx, int opts LOCK_FILE_LINE_ARG_DEF)
("sx_slock() by idle thread %p on sx %p @ %s:%d",
curthread, sx, file, line));
KASSERT(sx->sx_lock != SX_LOCK_DESTROYED,
("sx_slock() of destroyed sx @ %s:%d", file, line));
("sx_slock() of destroyed sx %p @ %s:%d", sx, file, line));
WITNESS_CHECKORDER(&sx->lock_object, LOP_NEWORDER, file, line, NULL);
error = 0;
@ -1366,7 +1367,7 @@ _sx_sunlock_int(struct sx *sx LOCK_FILE_LINE_ARG_DEF)
uintptr_t x;
KASSERT(sx->sx_lock != SX_LOCK_DESTROYED,
("sx_sunlock() of destroyed sx @ %s:%d", file, line));
("sx_sunlock() of destroyed sx %p @ %s:%d", sx, file, line));
_sx_assert(sx, SA_SLOCKED, file, line);
WITNESS_UNLOCK(&sx->lock_object, 0, file, line);
LOCK_LOG_LOCK("SUNLOCK", &sx->lock_object, 0, 0, file, line);