diff options
author | jhb <jhb@FreeBSD.org> | 2008-02-13 23:39:05 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2008-02-13 23:39:05 +0000 |
commit | fd8332efc0afba46de3a399b5eab52ffebe88bdf (patch) | |
tree | b023ff7be54e1fe5d6e5780e207c8e01cd99a370 /sys/kern/kern_mutex.c | |
parent | b518019544ad4128ba0fc46197fe4c0898d13516 (diff) | |
download | FreeBSD-src-fd8332efc0afba46de3a399b5eab52ffebe88bdf.zip FreeBSD-src-fd8332efc0afba46de3a399b5eab52ffebe88bdf.tar.gz |
Add KASSERT()'s to catch attempts to recurse on spin mutexes that aren't
marked recursable either via mtx_lock_spin() or thread_lock().
MFC after: 1 week
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r-- | sys/kern/kern_mutex.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index b770165..527adff 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -209,13 +209,17 @@ _mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line) void _mtx_lock_spin_flags(struct mtx *m, int opts, const char *file, int line) { - + MPASS(curthread != NULL); KASSERT(m->mtx_lock != MTX_DESTROYED, ("mtx_lock_spin() of destroyed mutex @ %s:%d", file, line)); KASSERT(LOCK_CLASS(&m->lock_object) == &lock_class_mtx_spin, ("mtx_lock_spin() of sleep mutex %s @ %s:%d", m->lock_object.lo_name, file, line)); + if (mtx_owned(m)) + KASSERT((m->lock_object.lo_flags & LO_RECURSABLE) != 0, + ("mtx_lock_spin: recursed on non-recursive mutex %s @ %s:%d\n", + m->lock_object.lo_name, file, line)); WITNESS_CHECKORDER(&m->lock_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, file, line); _get_spin_lock(m, curthread, opts, file, line); @@ -497,6 +501,10 @@ retry: KASSERT(LOCK_CLASS(&m->lock_object) == &lock_class_mtx_spin, ("thread_lock() of sleep mutex %s @ %s:%d", m->lock_object.lo_name, file, line)); + if (mtx_owned(m)) + KASSERT((m->lock_object.lo_flags & LO_RECURSABLE) != 0, + ("thread_lock: recursed on non-recursive mutex %s @ %s:%d\n", + m->lock_object.lo_name, file, line)); WITNESS_CHECKORDER(&m->lock_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, file, line); while (!_obtain_lock(m, tid)) { |