git: 43a15a22c623 - main - mtx: Include the mutex pointer in the panic message for destroyed locks

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 12 Mar 2025 14:47:39 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=43a15a22c62345091fc4a2ea2bec529acda7c61f

commit 43a15a22c62345091fc4a2ea2bec529acda7c61f
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-03-12 14:26:50 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-03-12 14:39:26 +0000

    mtx: Include the mutex pointer in the panic message for destroyed locks
    
    Reviewed by:    olce, kib, markj
    Sponsored by:   AFRL, DARPA
    Differential Revision:  https://reviews.freebsd.org/D49315
---
 sys/kern/kern_mutex.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 0a873cf139c4..d52f7e1eebd1 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -287,7 +287,7 @@ __mtx_lock_flags(volatile uintptr_t *c, int opts, const char *file, int line)
 	    ("mtx_lock() by idle thread %p on mutex %p @ %s:%d",
 	    curthread, m, file, line));
 	KASSERT(m->mtx_lock != MTX_DESTROYED,
-	    ("mtx_lock() of destroyed mutex @ %s:%d", file, line));
+	    ("mtx_lock() of destroyed mutex %p @ %s:%d", m, file, line));
 	KASSERT(LOCK_CLASS(&m->lock_object) != &lock_class_mtx_spin,
 	    ("mtx_lock() of spin mutex %s @ %s:%d", m->lock_object.lo_name,
 	    file, line));
@@ -316,7 +316,7 @@ __mtx_unlock_flags(volatile uintptr_t *c, int opts, const char *file, int line)
 	m = mtxlock2mtx(c);
 
 	KASSERT(m->mtx_lock != MTX_DESTROYED,
-	    ("mtx_unlock() of destroyed mutex @ %s:%d", file, line));
+	    ("mtx_unlock() of destroyed mutex %p @ %s:%d", m, file, line));
 	KASSERT(LOCK_CLASS(&m->lock_object) != &lock_class_mtx_spin,
 	    ("mtx_unlock() of spin mutex %s @ %s:%d", m->lock_object.lo_name,
 	    file, line));
@@ -345,7 +345,7 @@ __mtx_lock_spin_flags(volatile uintptr_t *c, int opts, const char *file,
 	m = mtxlock2mtx(c);
 
 	KASSERT(m->mtx_lock != MTX_DESTROYED,
-	    ("mtx_lock_spin() of destroyed mutex @ %s:%d", file, line));
+	    ("mtx_lock_spin() of destroyed mutex %p @ %s:%d", m, file, line));
 	KASSERT(LOCK_CLASS(&m->lock_object) != &lock_class_mtx_sleep,
 	    ("mtx_lock_spin() of sleep mutex %s @ %s:%d",
 	    m->lock_object.lo_name, file, line));
@@ -386,7 +386,8 @@ __mtx_trylock_spin_flags(volatile uintptr_t *c, int opts, const char *file,
 	m = mtxlock2mtx(c);
 
 	KASSERT(m->mtx_lock != MTX_DESTROYED,
-	    ("mtx_trylock_spin() of destroyed mutex @ %s:%d", file, line));
+	    ("mtx_trylock_spin() of destroyed mutex %p @ %s:%d", m, file,
+	    line));
 	KASSERT(LOCK_CLASS(&m->lock_object) != &lock_class_mtx_sleep,
 	    ("mtx_trylock_spin() of sleep mutex %s @ %s:%d",
 	    m->lock_object.lo_name, file, line));
@@ -411,7 +412,8 @@ __mtx_unlock_spin_flags(volatile uintptr_t *c, int opts, const char *file,
 	m = mtxlock2mtx(c);
 
 	KASSERT(m->mtx_lock != MTX_DESTROYED,
-	    ("mtx_unlock_spin() of destroyed mutex @ %s:%d", file, line));
+	    ("mtx_unlock_spin() of destroyed mutex %p @ %s:%d", m, file,
+	    line));
 	KASSERT(LOCK_CLASS(&m->lock_object) != &lock_class_mtx_sleep,
 	    ("mtx_unlock_spin() of sleep mutex %s @ %s:%d",
 	    m->lock_object.lo_name, file, line));
@@ -449,7 +451,7 @@ _mtx_trylock_flags_int(struct mtx *m, int opts LOCK_FILE_LINE_ARG_DEF)
 	    ("mtx_trylock() by idle thread %p on mutex %p @ %s:%d",
 	    curthread, m, file, line));
 	KASSERT(m->mtx_lock != MTX_DESTROYED,
-	    ("mtx_trylock() of destroyed mutex @ %s:%d", file, line));
+	    ("mtx_trylock() of destroyed mutex %p @ %s:%d", m, file, line));
 	KASSERT(LOCK_CLASS(&m->lock_object) != &lock_class_mtx_spin,
 	    ("mtx_trylock() of spin mutex %s @ %s:%d", m->lock_object.lo_name,
 	    file, line));
@@ -826,7 +828,7 @@ thread_lock_validate(struct mtx *m, int opts, const char *file, int line)
 {
 
 	KASSERT(m->mtx_lock != MTX_DESTROYED,
-	    ("thread_lock() of destroyed mutex @ %s:%d", file, line));
+	    ("thread_lock() of destroyed mutex %p @ %s:%d", m, file, line));
 	KASSERT(LOCK_CLASS(&m->lock_object) != &lock_class_mtx_sleep,
 	    ("thread_lock() of sleep mutex %s @ %s:%d",
 	    m->lock_object.lo_name, file, line));