svn commit: r320124 - head/sys/kern
Mark Johnston
markj at FreeBSD.org
Mon Jun 19 21:09:52 UTC 2017
Author: markj
Date: Mon Jun 19 21:09:50 2017
New Revision: 320124
URL: https://svnweb.freebsd.org/changeset/base/320124
Log:
Fix the !TD_IS_IDLETHREAD(curthread) locking assertions.
Most of the lock slowpaths assert that the calling thread isn't an idle
thread. However, this may not be true if the system has panicked, and in
some cases the assertion appears before a SCHEDULER_STOPPED() check.
MFC after: 3 days
Sponsored by: Dell EMC Isilon
Modified:
head/sys/kern/kern_mutex.c
head/sys/kern/kern_rwlock.c
head/sys/kern/kern_sx.c
Modified: head/sys/kern/kern_mutex.c
==============================================================================
--- head/sys/kern/kern_mutex.c Mon Jun 19 20:48:00 2017 (r320123)
+++ head/sys/kern/kern_mutex.c Mon Jun 19 21:09:50 2017 (r320124)
@@ -233,7 +233,8 @@ __mtx_lock_flags(volatile uintptr_t *c, int opts, cons
m = mtxlock2mtx(c);
- KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
+ KASSERT(kdb_active != 0 || SCHEDULER_STOPPED() ||
+ !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,
@@ -390,7 +391,7 @@ _mtx_trylock_flags_(volatile uintptr_t *c, int opts, c
m = mtxlock2mtx(c);
- KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
+ KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td),
("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_rwlock.c
==============================================================================
--- head/sys/kern/kern_rwlock.c Mon Jun 19 20:48:00 2017 (r320123)
+++ head/sys/kern/kern_rwlock.c Mon Jun 19 21:09:50 2017 (r320124)
@@ -269,7 +269,8 @@ _rw_wlock_cookie(volatile uintptr_t *c, const char *fi
rw = rwlock2rw(c);
- KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
+ KASSERT(kdb_active != 0 || SCHEDULER_STOPPED() ||
+ !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,
@@ -305,7 +306,7 @@ __rw_try_wlock(volatile uintptr_t *c, const char *file
rw = rwlock2rw(c);
- KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
+ KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td),
("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,
@@ -615,7 +616,8 @@ __rw_rlock(volatile uintptr_t *c, const char *file, in
td = curthread;
rw = rwlock2rw(c);
- KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td),
+ KASSERT(kdb_active != 0 || SCHEDULER_STOPPED_TD(td) ||
+ !TD_IS_IDLETHREAD(td),
("rw_rlock() by idle thread %p on rwlock %s @ %s:%d",
td, rw->lock_object.lo_name, file, line));
KASSERT(rw->rw_lock != RW_DESTROYED,
@@ -815,7 +817,6 @@ _rw_runlock_cookie(volatile uintptr_t *c, const char *
TD_LOCKS_DEC(curthread);
}
-
/*
* This function is called when we are unable to obtain a write lock on the
Modified: head/sys/kern/kern_sx.c
==============================================================================
--- head/sys/kern/kern_sx.c Mon Jun 19 20:48:00 2017 (r320123)
+++ head/sys/kern/kern_sx.c Mon Jun 19 21:09:50 2017 (r320124)
@@ -295,7 +295,8 @@ _sx_xlock(struct sx *sx, int opts, const char *file, i
uintptr_t tid, x;
int error = 0;
- KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
+ KASSERT(kdb_active != 0 || SCHEDULER_STOPPED() ||
+ !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,
@@ -332,7 +333,7 @@ sx_try_xlock_(struct sx *sx, const char *file, int lin
if (SCHEDULER_STOPPED_TD(td))
return (1);
- KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
+ KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td),
("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,
@@ -1030,7 +1031,8 @@ _sx_slock(struct sx *sx, int opts, const char *file, i
uintptr_t x;
int error;
- KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
+ KASSERT(kdb_active != 0 || SCHEDULER_STOPPED() ||
+ !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,
More information about the svn-src-all
mailing list