Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Apr 2025 18:30:46 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 6fb471682aa9 - stable/14 - rwmlock/rwlock/sx: Print the pointer of destroyed locks in panic messages
Message-ID:  <202504291830.53TIUk79022835@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=6fb471682aa9198fb187f2718dd291f09d96cf2b

commit 6fb471682aa9198fb187f2718dd291f09d96cf2b
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-03-13 16:54:40 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-04-29 14:44:08 +0000

    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 00d78c500783fc91512b3c0d231029ac75a131d9)
---
 sys/kern/kern_rmlock.c |  8 ++++----
 sys/kern/kern_rwlock.c | 18 ++++++++++--------
 sys/kern/kern_sx.c     | 17 +++++++++--------
 3 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c
index bdee79e2cf1a..0867e9e14fee 100644
--- a/sys/kern/kern_rmlock.c
+++ b/sys/kern/kern_rmlock.c
@@ -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);
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
index d6fab5ba35bb..dc2b9892cecd 100644
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -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))
diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c
index ecac40217738..0422e6804459 100644
--- a/sys/kern/kern_sx.c
+++ b/sys/kern/kern_sx.c
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202504291830.53TIUk79022835>