summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2013-06-25 20:23:08 +0000
committerjhb <jhb@FreeBSD.org>2013-06-25 20:23:08 +0000
commit19d363377edf8cabee817f718377a6bc63ff7feb (patch)
tree60cbcb3e979ff7a6b8fbdeb319c971bd474cb372 /sys/kern/kern_mutex.c
parent0807c44cdd0226cdd2553f723a00de3d13882321 (diff)
downloadFreeBSD-src-19d363377edf8cabee817f718377a6bc63ff7feb.zip
FreeBSD-src-19d363377edf8cabee817f718377a6bc63ff7feb.tar.gz
A few mostly cosmetic nits to aid in debugging:
- Call lock_init() first before setting any lock_object fields in lock init routines. This way if the machine panics due to a duplicate init the lock's original state is preserved. - Somewhat similarly, don't decrement td_locks and td_slocks until after an unlock operation has completed successfully.
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 39f461e..a613da8 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -243,7 +243,6 @@ __mtx_unlock_flags(volatile uintptr_t *c, int opts, const char *file, int line)
KASSERT(LOCK_CLASS(&m->lock_object) == &lock_class_mtx_sleep,
("mtx_unlock() of spin mutex %s @ %s:%d", m->lock_object.lo_name,
file, line));
- curthread->td_locks--;
WITNESS_UNLOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line);
LOCK_LOG_LOCK("UNLOCK", &m->lock_object, opts, m->mtx_recurse, file,
line);
@@ -252,6 +251,7 @@ __mtx_unlock_flags(volatile uintptr_t *c, int opts, const char *file, int line)
if (m->mtx_recurse == 0)
LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_UNLOCK_RELEASE, m);
__mtx_unlock(m, curthread, opts, file, line);
+ curthread->td_locks--;
}
void
@@ -894,10 +894,10 @@ _mtx_init(volatile uintptr_t *c, const char *name, const char *type, int opts)
flags |= LO_NOPROFILE;
/* Initialize mutex. */
+ lock_init(&m->lock_object, class, name, type, flags);
+
m->mtx_lock = MTX_UNOWNED;
m->mtx_recurse = 0;
-
- lock_init(&m->lock_object, class, name, type, flags);
}
/*
OpenPOWER on IntegriCloud