MFC: Adjust td_locks for non-spin mutexes and sx locks.

This commit is contained in:
jhb 2006-08-11 18:54:10 +00:00
parent 5057cef81c
commit f31ad56d69
2 changed files with 13 additions and 1 deletions

View File

@ -289,6 +289,7 @@ _mtx_lock_flags(struct mtx *m, int opts, const char *file, int line)
LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file,
line);
WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line);
curthread->td_locks++;
#ifdef MUTEX_PROFILING
/* don't reset the timer when/if recursing */
if (m->mtx_acqtime == 0) {
@ -310,6 +311,7 @@ _mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line)
KASSERT(LOCK_CLASS(&m->mtx_object) == &lock_class_mtx_sleep,
("mtx_unlock() of spin mutex %s @ %s:%d", m->mtx_object.lo_name,
file, line));
curthread->td_locks--;
WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line);
LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file,
line);
@ -441,9 +443,11 @@ _mtx_trylock(struct mtx *m, int opts, const char *file, int line)
rval = _obtain_lock(m, (uintptr_t)curthread);
LOCK_LOG_TRY("LOCK", &m->mtx_object, opts, rval, file, line);
if (rval)
if (rval) {
WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE | LOP_TRYLOCK,
file, line);
curthread->td_locks++;
}
return (rval);
}
@ -898,6 +902,8 @@ mtx_destroy(struct mtx *m)
/* Perform the non-mtx related part of mtx_unlock_spin(). */
if (LOCK_CLASS(&m->mtx_object) == &lock_class_mtx_spin)
spinlock_exit();
else
curthread->td_locks--;
/* Tell witness this isn't locked to make it happy. */
WITNESS_UNLOCK(&m->mtx_object, LOP_EXCLUSIVE, __FILE__,

View File

@ -128,6 +128,7 @@ _sx_slock(struct sx *sx, const char *file, int line)
LOCK_LOG_LOCK("SLOCK", &sx->sx_object, 0, 0, file, line);
WITNESS_LOCK(&sx->sx_object, 0, file, line);
curthread->td_locks++;
mtx_unlock(sx->sx_lock);
}
@ -141,6 +142,7 @@ _sx_try_slock(struct sx *sx, const char *file, int line)
sx->sx_cnt++;
LOCK_LOG_TRY("SLOCK", &sx->sx_object, 0, 1, file, line);
WITNESS_LOCK(&sx->sx_object, LOP_TRYLOCK, file, line);
curthread->td_locks++;
mtx_unlock(sx->sx_lock);
return (1);
} else {
@ -184,6 +186,7 @@ _sx_xlock(struct sx *sx, const char *file, int line)
LOCK_LOG_LOCK("XLOCK", &sx->sx_object, 0, 0, file, line);
WITNESS_LOCK(&sx->sx_object, LOP_EXCLUSIVE, file, line);
curthread->td_locks++;
mtx_unlock(sx->sx_lock);
}
@ -199,6 +202,7 @@ _sx_try_xlock(struct sx *sx, const char *file, int line)
LOCK_LOG_TRY("XLOCK", &sx->sx_object, 0, 1, file, line);
WITNESS_LOCK(&sx->sx_object, LOP_EXCLUSIVE | LOP_TRYLOCK, file,
line);
curthread->td_locks++;
mtx_unlock(sx->sx_lock);
return (1);
} else {
@ -215,6 +219,7 @@ _sx_sunlock(struct sx *sx, const char *file, int line)
_sx_assert(sx, SX_SLOCKED, file, line);
mtx_lock(sx->sx_lock);
curthread->td_locks--;
WITNESS_UNLOCK(&sx->sx_object, 0, file, line);
/* Release. */
@ -245,6 +250,7 @@ _sx_xunlock(struct sx *sx, const char *file, int line)
mtx_lock(sx->sx_lock);
MPASS(sx->sx_cnt == -1);
curthread->td_locks--;
WITNESS_UNLOCK(&sx->sx_object, LOP_EXCLUSIVE, file, line);
/* Release. */