diff options
author | attilio <attilio@FreeBSD.org> | 2012-09-12 22:10:53 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2012-09-12 22:10:53 +0000 |
commit | a634dfc320608f9955ab0350a7f78ee73064b909 (patch) | |
tree | 139a9f57a8c17d9b87a87568fbf9be1819e671f0 /sys/kern/kern_rwlock.c | |
parent | ac29dac65b70ec7f821f36ac07f086e6a514fe1a (diff) | |
download | FreeBSD-src-a634dfc320608f9955ab0350a7f78ee73064b909.zip FreeBSD-src-a634dfc320608f9955ab0350a7f78ee73064b909.tar.gz |
Improve check coverage about idle threads.
Idle threads are not allowed to acquire any lock but spinlocks.
Deny any attempt to do so by panicing at the locking operation
when INVARIANTS is on. Then, remove the check on blocking on a
turnstile.
The check in sleepqueues is left because they are not allowed to use
tsleep() either which could happen still.
Reviewed by: bde, jhb, kib
MFC after: 1 week
Diffstat (limited to 'sys/kern/kern_rwlock.c')
-rw-r--r-- | sys/kern/kern_rwlock.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index c337041..e0be154 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -242,6 +242,9 @@ _rw_wlock(struct rwlock *rw, const char *file, int line) if (SCHEDULER_STOPPED()) return; MPASS(curthread != NULL); + KASSERT(!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, ("rw_wlock() of destroyed rwlock @ %s:%d", file, line)); WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER | LOP_EXCLUSIVE, file, @@ -260,6 +263,9 @@ _rw_try_wlock(struct rwlock *rw, const char *file, int line) if (SCHEDULER_STOPPED()) return (1); + KASSERT(!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, ("rw_try_wlock() of destroyed rwlock @ %s:%d", file, line)); @@ -333,6 +339,9 @@ _rw_rlock(struct rwlock *rw, const char *file, int line) if (SCHEDULER_STOPPED()) return; + KASSERT(!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, ("rw_rlock() of destroyed rwlock @ %s:%d", file, line)); KASSERT(rw_wowner(rw) != curthread, @@ -521,6 +530,10 @@ _rw_try_rlock(struct rwlock *rw, const char *file, int line) if (SCHEDULER_STOPPED()) return (1); + KASSERT(!TD_IS_IDLETHREAD(curthread), + ("rw_try_rlock() by idle thread %p on rwlock %s @ %s:%d", + curthread, rw->lock_object.lo_name, file, line)); + for (;;) { x = rw->rw_lock; KASSERT(rw->rw_lock != RW_DESTROYED, |