summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2012-09-12 22:10:53 +0000
committerattilio <attilio@FreeBSD.org>2012-09-12 22:10:53 +0000
commita634dfc320608f9955ab0350a7f78ee73064b909 (patch)
tree139a9f57a8c17d9b87a87568fbf9be1819e671f0 /sys/kern/kern_mutex.c
parentac29dac65b70ec7f821f36ac07f086e6a514fe1a (diff)
downloadFreeBSD-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_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index f718ca0..9827a9f 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -201,6 +201,9 @@ _mtx_lock_flags(struct mtx *m, int opts, const char *file, int line)
if (SCHEDULER_STOPPED())
return;
MPASS(curthread != NULL);
+ KASSERT(!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,
("mtx_lock() of destroyed mutex @ %s:%d", file, line));
KASSERT(LOCK_CLASS(&m->lock_object) == &lock_class_mtx_sleep,
@@ -301,6 +304,9 @@ mtx_trylock_flags_(struct mtx *m, int opts, const char *file, int line)
return (1);
MPASS(curthread != NULL);
+ KASSERT(!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,
("mtx_trylock() of destroyed mutex @ %s:%d", file, line));
KASSERT(LOCK_CLASS(&m->lock_object) == &lock_class_mtx_sleep,
OpenPOWER on IntegriCloud