diff options
author | attilio <attilio@FreeBSD.org> | 2012-12-22 09:37:34 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2012-12-22 09:37:34 +0000 |
commit | d2861e92958113d0e11a6d2708af91daa4ed0125 (patch) | |
tree | 223c35655c8b163024a006c82d65f305e5d2126d /sys/kern | |
parent | 32527711e11108602452789b89ff5efdbdc3fef2 (diff) | |
download | FreeBSD-src-d2861e92958113d0e11a6d2708af91daa4ed0125.zip FreeBSD-src-d2861e92958113d0e11a6d2708af91daa4ed0125.tar.gz |
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
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_lock.c | 3 | ||||
-rw-r--r-- | sys/kern/kern_mutex.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_rmlock.c | 5 | ||||
-rw-r--r-- | sys/kern/kern_rwlock.c | 9 | ||||
-rw-r--r-- | sys/kern/kern_sx.c | 9 |
5 files changed, 17 insertions, 13 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index cc276db..98f0156 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -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 flags, struct lock_object *ilk, 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)); diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 2f13863..39f461e 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -210,7 +210,7 @@ __mtx_lock_flags(volatile uintptr_t *c, int opts, const char *file, int line) 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 *c, int opts, const char *file, int line) 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, diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c index 30400b1..ebf0f76 100644 --- a/sys/kern/kern_rmlock.c +++ b/sys/kern/kern_rmlock.c @@ -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, const char *file, int line) 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, struct rm_priotracker *tracker, 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)) diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index 60a7faa..38d0654 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -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, const char *file, int line) 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, const char *file, int line) 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 char *file, int line) 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, const char *file, int line) 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)); diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c index af2391f..e469b1a 100644 --- a/sys/kern/kern_sx.c +++ b/sys/kern/kern_sx.c @@ -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 char *file, int line) 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 *file, int line) 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 char *file, int line) 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 *file, int line) 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, |