diff options
author | John Baldwin <jhb@FreeBSD.org> | 2002-09-03 18:25:16 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2002-09-03 18:25:16 +0000 |
commit | 0d975d6341424d106982194360aef1e8a3ac9711 (patch) | |
tree | 8273a391c85123e4081de6ff13197760440860cd /sys/kern/kern_mutex.c | |
parent | 6d1020dae1edadf2b0d53383dd39d08c90e7565a (diff) | |
download | src-0d975d6341424d106982194360aef1e8a3ac9711.tar.gz src-0d975d6341424d106982194360aef1e8a3ac9711.zip |
Add some KASSERT()'s to ensure that we don't perform spin mutex ops on
sleep mutexes and vice versa. WITNESS normally should catch this but
not everyone uses WITNESS so this is a fallback to catch nasty but easy
to do bugs.
Notes
Notes:
svn path=/head/; revision=102907
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r-- | sys/kern/kern_mutex.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 982b3761c2df..00a789c89d64 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -316,6 +316,9 @@ _mtx_lock_flags(struct mtx *m, int opts, const char *file, int line) { MPASS(curthread != NULL); + KASSERT(m->mtx_object.lo_class == &lock_class_mtx_sleep, + ("mtx_lock() of spin mutex %s @ %s:%d", m->mtx_object.lo_name, + file, line)); _get_sleep_lock(m, curthread, opts, file, line); LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file, line); @@ -336,6 +339,12 @@ _mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line) { MPASS(curthread != NULL); + KASSERT(m->mtx_object.lo_class == &lock_class_mtx_sleep, + ("mtx_unlock() of spin mutex %s @ %s:%d", m->mtx_object.lo_name, + file, line)); + WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); + LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, + line); mtx_assert(m, MA_OWNED); #ifdef MUTEX_PROFILING if (m->mtx_acqtime != 0) { @@ -392,9 +401,6 @@ unlock: } out: #endif - WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); - LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, - line); _rel_sleep_lock(m, curthread, opts, file, line); } @@ -403,6 +409,9 @@ _mtx_lock_spin_flags(struct mtx *m, int opts, const char *file, int line) { MPASS(curthread != NULL); + KASSERT(m->mtx_object.lo_class == &lock_class_mtx_spin, + ("mtx_lock_spin() of sleep mutex %s @ %s:%d", + m->mtx_object.lo_name, file, line)); #if defined(SMP) || LOCK_DEBUG > 0 || 1 _get_spin_lock(m, curthread, opts, file, line); #else @@ -418,10 +427,13 @@ _mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file, int line) { MPASS(curthread != NULL); - mtx_assert(m, MA_OWNED); + KASSERT(m->mtx_object.lo_class == &lock_class_mtx_spin, + ("mtx_unlock_spin() of sleep mutex %s @ %s:%d", + m->mtx_object.lo_name, file, line)); WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, line); + mtx_assert(m, MA_OWNED); #if defined(SMP) || LOCK_DEBUG > 0 || 1 _rel_spin_lock(m); #else |