Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Dec 2012 09:37:34 +0000 (UTC)
From:      Attilio Rao <attilio@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r244582 - head/sys/kern
Message-ID:  <201212220937.qBM9bYQK050680@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: attilio
Date: Sat Dec 22 09:37:34 2012
New Revision: 244582
URL: http://svnweb.freebsd.org/changeset/base/244582

Log:
  Fixup r240424: On entering KDB backends, the hijacked thread to run
  interrupt context can still be idlethread. At that point, without the
  panic condition, it can still happen that idlethread then will try to
  acquire some locks to carry on some operations.
  
  Skip the idlethread check on block/sleep lock operations when KDB is
  active.
  
  Reported by:	jh
  Tested by:	jh
  MFC after:	1 week

Modified:
  head/sys/kern/kern_lock.c
  head/sys/kern/kern_mutex.c
  head/sys/kern/kern_rmlock.c
  head/sys/kern/kern_rwlock.c
  head/sys/kern/kern_sx.c

Modified: head/sys/kern/kern_lock.c
==============================================================================
--- head/sys/kern/kern_lock.c	Sat Dec 22 07:48:09 2012	(r244581)
+++ head/sys/kern/kern_lock.c	Sat Dec 22 09:37:34 2012	(r244582)
@@ -35,6 +35,7 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <sys/kdb.h>
 #include <sys/ktr.h>
 #include <sys/lock.h>
 #include <sys/lock_profile.h>
@@ -477,7 +478,7 @@ __lockmgr_args(struct lock *lk, u_int fl
 	KASSERT((flags & LK_INTERLOCK) == 0 || ilk != NULL,
 	    ("%s: LK_INTERLOCK passed without valid interlock @ %s:%d",
 	    __func__, file, line));
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("%s: idle thread %p on lockmgr %s @ %s:%d", __func__, curthread,
 	    lk->lock_object.lo_name, file, line));
 

Modified: head/sys/kern/kern_mutex.c
==============================================================================
--- head/sys/kern/kern_mutex.c	Sat Dec 22 07:48:09 2012	(r244581)
+++ head/sys/kern/kern_mutex.c	Sat Dec 22 09:37:34 2012	(r244582)
@@ -210,7 +210,7 @@ __mtx_lock_flags(volatile uintptr_t *c, 
 
 	m = mtxlock2mtx(c);
 
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("mtx_lock() by idle thread %p on sleep mutex %s @ %s:%d",
 	    curthread, m->lock_object.lo_name, file, line));
 	KASSERT(m->mtx_lock != MTX_DESTROYED,
@@ -326,7 +326,7 @@ _mtx_trylock_flags_(volatile uintptr_t *
 
 	m = mtxlock2mtx(c);
 
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("mtx_trylock() by idle thread %p on sleep mutex %s @ %s:%d",
 	    curthread, m->lock_object.lo_name, file, line));
 	KASSERT(m->mtx_lock != MTX_DESTROYED,

Modified: head/sys/kern/kern_rmlock.c
==============================================================================
--- head/sys/kern/kern_rmlock.c	Sat Dec 22 07:48:09 2012	(r244581)
+++ head/sys/kern/kern_rmlock.c	Sat Dec 22 09:37:34 2012	(r244582)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 
 #include <sys/kernel.h>
+#include <sys/kdb.h>
 #include <sys/ktr.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
@@ -494,7 +495,7 @@ void _rm_wlock_debug(struct rmlock *rm, 
 	if (SCHEDULER_STOPPED())
 		return;
 
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("rm_wlock() by idle thread %p on rmlock %s @ %s:%d",
 	    curthread, rm->lock_object.lo_name, file, line));
 	WITNESS_CHECKORDER(&rm->lock_object, LOP_NEWORDER | LOP_EXCLUSIVE,
@@ -539,7 +540,7 @@ _rm_rlock_debug(struct rmlock *rm, struc
 	if (SCHEDULER_STOPPED())
 		return (1);
 
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("rm_rlock() by idle thread %p on rmlock %s @ %s:%d",
 	    curthread, rm->lock_object.lo_name, file, line));
 	if (!trylock && (rm->lock_object.lo_flags & RM_SLEEPABLE))

Modified: head/sys/kern/kern_rwlock.c
==============================================================================
--- head/sys/kern/kern_rwlock.c	Sat Dec 22 07:48:09 2012	(r244581)
+++ head/sys/kern/kern_rwlock.c	Sat Dec 22 09:37:34 2012	(r244582)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include "opt_no_adaptive_rwlocks.h"
 
 #include <sys/param.h>
+#include <sys/kdb.h>
 #include <sys/ktr.h>
 #include <sys/kernel.h>
 #include <sys/lock.h>
@@ -258,7 +259,7 @@ _rw_wlock_cookie(volatile uintptr_t *c, 
 
 	rw = rwlock2rw(c);
 
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("rw_wlock() by idle thread %p on rwlock %s @ %s:%d",
 	    curthread, rw->lock_object.lo_name, file, line));
 	KASSERT(rw->rw_lock != RW_DESTROYED,
@@ -282,7 +283,7 @@ __rw_try_wlock(volatile uintptr_t *c, co
 
 	rw = rwlock2rw(c);
 
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("rw_try_wlock() by idle thread %p on rwlock %s @ %s:%d",
 	    curthread, rw->lock_object.lo_name, file, line));
 	KASSERT(rw->rw_lock != RW_DESTROYED,
@@ -364,7 +365,7 @@ __rw_rlock(volatile uintptr_t *c, const 
 
 	rw = rwlock2rw(c);
 
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("rw_rlock() by idle thread %p on rwlock %s @ %s:%d",
 	    curthread, rw->lock_object.lo_name, file, line));
 	KASSERT(rw->rw_lock != RW_DESTROYED,
@@ -558,7 +559,7 @@ __rw_try_rlock(volatile uintptr_t *c, co
 
 	rw = rwlock2rw(c);
 
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("rw_try_rlock() by idle thread %p on rwlock %s @ %s:%d",
 	    curthread, rw->lock_object.lo_name, file, line));
 

Modified: head/sys/kern/kern_sx.c
==============================================================================
--- head/sys/kern/kern_sx.c	Sat Dec 22 07:48:09 2012	(r244581)
+++ head/sys/kern/kern_sx.c	Sat Dec 22 09:37:34 2012	(r244582)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/kdb.h>
 #include <sys/ktr.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
@@ -249,7 +250,7 @@ _sx_slock(struct sx *sx, int opts, const
 
 	if (SCHEDULER_STOPPED())
 		return (0);
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("sx_slock() by idle thread %p on sx %s @ %s:%d",
 	    curthread, sx->lock_object.lo_name, file, line));
 	KASSERT(sx->sx_lock != SX_LOCK_DESTROYED,
@@ -273,7 +274,7 @@ sx_try_slock_(struct sx *sx, const char 
 	if (SCHEDULER_STOPPED())
 		return (1);
 
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("sx_try_slock() by idle thread %p on sx %s @ %s:%d",
 	    curthread, sx->lock_object.lo_name, file, line));
 
@@ -302,7 +303,7 @@ _sx_xlock(struct sx *sx, int opts, const
 
 	if (SCHEDULER_STOPPED())
 		return (0);
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("sx_xlock() by idle thread %p on sx %s @ %s:%d",
 	    curthread, sx->lock_object.lo_name, file, line));
 	KASSERT(sx->sx_lock != SX_LOCK_DESTROYED,
@@ -328,7 +329,7 @@ sx_try_xlock_(struct sx *sx, const char 
 	if (SCHEDULER_STOPPED())
 		return (1);
 
-	KASSERT(!TD_IS_IDLETHREAD(curthread),
+	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("sx_try_xlock() by idle thread %p on sx %s @ %s:%d",
 	    curthread, sx->lock_object.lo_name, file, line));
 	KASSERT(sx->sx_lock != SX_LOCK_DESTROYED,



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