From 2b59d50cfb1a05710d47739a2fa6eecddcac4365 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Tue, 27 Sep 2005 21:02:59 +0000 Subject: [PATCH] In lockstatus(), don't lock and unlock the interlock when testing the sleep lock status while kdb_active, or we risk contending with the mutex on another CPU, resulting in a panic when using "show lockedvnods" while in DDB. MFC after: 3 days Reviewed by: jhb Reported by: kris --- sys/kern/kern_lock.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index c53683cf04c..12c0d9c0238 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -526,8 +526,13 @@ lockstatus(lkp, td) struct thread *td; { int lock_type = 0; + int interlocked; - mtx_lock(lkp->lk_interlock); + if (!kdb_active) { + interlocked = 1; + mtx_lock(lkp->lk_interlock); + } else + interlocked = 0; if (lkp->lk_exclusivecount != 0) { if (td == NULL || lkp->lk_lockholder == td) lock_type = LK_EXCLUSIVE; @@ -535,7 +540,8 @@ lockstatus(lkp, td) lock_type = LK_EXCLOTHER; } else if (lkp->lk_sharecount != 0) lock_type = LK_SHARED; - mtx_unlock(lkp->lk_interlock); + if (interlocked) + mtx_unlock(lkp->lk_interlock); return (lock_type); }