aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_turnstile.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2002-09-03 18:25:16 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2002-09-03 18:25:16 +0000
commit0d975d6341424d106982194360aef1e8a3ac9711 (patch)
tree8273a391c85123e4081de6ff13197760440860cd /sys/kern/subr_turnstile.c
parent6d1020dae1edadf2b0d53383dd39d08c90e7565a (diff)
downloadsrc-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/subr_turnstile.c')
-rw-r--r--sys/kern/subr_turnstile.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c
index 982b3761c2df..00a789c89d64 100644
--- a/sys/kern/subr_turnstile.c
+++ b/sys/kern/subr_turnstile.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