aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2006-07-27 21:45:55 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2006-07-27 21:45:55 +0000
commit764e4d54e9d5ea383b7ef04841155e4fc68f9082 (patch)
tree6aa25b1f8f1ba91bd0c1aa70c6b9d4dae14a8068
parent0c5d1dbd43050e656d207de7a88a390bdda0f41a (diff)
Notes
-rw-r--r--sys/kern/kern_mutex.c8
-rw-r--r--sys/kern/kern_rwlock.c4
-rw-r--r--sys/kern/kern_sx.c6
3 files changed, 17 insertions, 1 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 04368e51708b..6c66537ec084 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -287,6 +287,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) {
@@ -308,6 +309,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);
@@ -439,9 +441,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);
}
@@ -889,6 +893,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__,
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
index 70a5985c797f..424afdc1e6ae 100644
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -119,6 +119,7 @@ _rw_wlock(struct rwlock *rw, const char *file, int line)
__rw_wlock(rw, curthread, file, line);
LOCK_LOG_LOCK("WLOCK", &rw->rw_object, 0, 0, file, line);
WITNESS_LOCK(&rw->rw_object, LOP_EXCLUSIVE, file, line);
+ curthread->td_locks++;
}
void
@@ -127,6 +128,7 @@ _rw_wunlock(struct rwlock *rw, const char *file, int line)
MPASS(curthread != NULL);
_rw_assert(rw, RA_WLOCKED, file, line);
+ curthread->td_locks--;
WITNESS_UNLOCK(&rw->rw_object, LOP_EXCLUSIVE, file, line);
LOCK_LOG_LOCK("WUNLOCK", &rw->rw_object, 0, 0, file, line);
__rw_wunlock(rw, curthread, file, line);
@@ -266,6 +268,7 @@ _rw_rlock(struct rwlock *rw, const char *file, int line)
LOCK_LOG_LOCK("RLOCK", &rw->rw_object, 0, 0, file, line);
WITNESS_LOCK(&rw->rw_object, 0, file, line);
+ curthread->td_locks++;
}
void
@@ -275,6 +278,7 @@ _rw_runlock(struct rwlock *rw, const char *file, int line)
uintptr_t x;
_rw_assert(rw, RA_RLOCKED, file, line);
+ curthread->td_locks--;
WITNESS_UNLOCK(&rw->rw_object, 0, file, line);
LOCK_LOG_LOCK("RUNLOCK", &rw->rw_object, 0, 0, file, line);
diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c
index a3a7da878902..d2158076e596 100644
--- a/sys/kern/kern_sx.c
+++ b/sys/kern/kern_sx.c
@@ -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. */