Hi,

I've faced recently couple of panics like:

panic: mtx 0xffffffff8211ed38: locking against myself

and modified messages as with the below diff. I guess you may consider
that with the nature of this type of panic, function name don't help
much to norrow down the problem, nonetheless would following diff be
okay to commit?

See https://marc.info/?l=openbsd-bugs&m=159553956423219&w=2 for the
reference of the panic.

I've compile and runtime tested this only on amd64.


Index: arch/hppa/hppa/mutex.c
===================================================================
RCS file: /cvs/src/sys/arch/hppa/hppa/mutex.c,v
retrieving revision 1.17
diff -u -p -u -r1.17 mutex.c
--- arch/hppa/hppa/mutex.c      23 Apr 2019 13:35:12 -0000      1.17
+++ arch/hppa/hppa/mutex.c      17 Jul 2020 07:08:54 -0000
@@ -74,7 +74,7 @@ mtx_enter_try(struct mutex *mtx)
 
 #ifdef DIAGNOSTIC
        if (__predict_false(mtx->mtx_owner == ci))
-               panic("mtx %p: locking against myself", mtx);
+               panic("%s: mtx %p: locking against myself", __func__, mtx);
 #endif
 
        asm volatile (
@@ -108,7 +108,7 @@ mtx_enter(struct mutex *mtx)
 
 #ifdef DIAGNOSTIC
        if (__predict_false(mtx->mtx_owner == ci))
-               panic("mtx %p: locking against myself", mtx);
+               panic("%s: mtx %p: locking against myself", __func__, mtx);
 #endif
 
        if (mtx->mtx_wantipl != IPL_NONE)
Index: arch/m88k/m88k/mutex.c
===================================================================
RCS file: /cvs/src/sys/arch/m88k/m88k/mutex.c,v
retrieving revision 1.1
diff -u -p -u -r1.1 mutex.c
--- arch/m88k/m88k/mutex.c      26 May 2020 11:55:10 -0000      1.1
+++ arch/m88k/m88k/mutex.c      17 Jul 2020 07:08:55 -0000
@@ -104,7 +104,7 @@ mtx_enter_try(struct mutex *mtx)
 
 #ifdef DIAGNOSTIC
        if (__predict_false(mtx->mtx_owner == ci))
-               panic("mtx %p: locking against myself", mtx);
+               panic("%s: mtx %p: locking against myself", __func__, mtx);
 #endif
        if (mtx->mtx_wantipl != IPL_NONE)
                splx(s);
@@ -126,7 +126,7 @@ mtx_enter(struct mutex *mtx)
 
 #ifdef DIAGNOSTIC
        if (__predict_false(mtx->mtx_owner == ci))
-               panic("mtx %p: locking against myself", mtx);
+               panic("%s: mtx %p: locking against myself", __func__, mtx);
 #endif
 
        if (mtx->mtx_wantipl != IPL_NONE)
Index: kern/kern_lock.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_lock.c,v
retrieving revision 1.71
diff -u -p -u -r1.71 kern_lock.c
--- kern/kern_lock.c    5 Mar 2020 09:28:31 -0000       1.71
+++ kern/kern_lock.c    17 Jul 2020 07:08:55 -0000
@@ -293,7 +293,7 @@ mtx_enter_try(struct mutex *mtx)
        owner = atomic_cas_ptr(&mtx->mtx_owner, NULL, ci);
 #ifdef DIAGNOSTIC
        if (__predict_false(owner == ci))
-               panic("mtx %p: locking against myself", mtx);
+               panic("%s: mtx %p: locking against myself", __func__, mtx);
 #endif
        if (owner == NULL) {
                membar_enter_after_atomic();
@@ -326,7 +326,7 @@ mtx_enter(struct mutex *mtx)
 
 #ifdef DIAGNOSTIC
        if (__predict_false(mtx->mtx_owner == ci))
-               panic("mtx %p: locking against myself", mtx);
+               panic("%s: mtx %p: locking against myself", __func__, mtx);
 #endif
 
        if (mtx->mtx_wantipl != IPL_NONE)
Index: kern/kern_rwlock.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_rwlock.c,v
retrieving revision 1.45
diff -u -p -u -r1.45 kern_rwlock.c
--- kern/kern_rwlock.c  2 Mar 2020 17:07:49 -0000       1.45
+++ kern/kern_rwlock.c  17 Jul 2020 07:08:55 -0000
@@ -170,8 +170,8 @@ rw_enter_diag(struct rwlock *rwl, int fl
        case RW_WRITE:
        case RW_READ:
                if (RW_PROC(curproc) == RW_PROC(rwl->rwl_owner))
-                       panic("rw_enter: %s locking against myself",
-                           rwl->rwl_name);
+                       panic("%s: %s locking against myself",
+                           __func__, rwl->rwl_name);
                break;
        case RW_DOWNGRADE:
                /*


-- 
Regards,
 Mikolaj

Reply via email to