diff options
author | jhb <jhb@FreeBSD.org> | 2013-06-25 20:23:08 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2013-06-25 20:23:08 +0000 |
commit | 19d363377edf8cabee817f718377a6bc63ff7feb (patch) | |
tree | 60cbcb3e979ff7a6b8fbdeb319c971bd474cb372 /sys/kern/kern_lock.c | |
parent | 0807c44cdd0226cdd2553f723a00de3d13882321 (diff) | |
download | FreeBSD-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_lock.c')
-rw-r--r-- | sys/kern/kern_lock.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index f0eedd8..87dca63 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -238,8 +238,6 @@ wakeupshlk(struct lock *lk, const char *file, int line) u_int realexslp; int queue, wakeup_swapper; - TD_LOCKS_DEC(curthread); - TD_SLOCKS_DEC(curthread); WITNESS_UNLOCK(&lk->lock_object, 0, file, line); LOCK_LOG_LOCK("SUNLOCK", &lk->lock_object, 0, 0, file, line); @@ -339,6 +337,8 @@ wakeupshlk(struct lock *lk, const char *file, int line) } lock_profile_release_lock(&lk->lock_object); + TD_LOCKS_DEC(curthread); + TD_SLOCKS_DEC(curthread); return (wakeup_swapper); } @@ -397,12 +397,12 @@ lockinit(struct lock *lk, int pri, const char *wmesg, int timo, int flags) iflags |= LO_IS_VNODE; iflags |= flags & (LK_ADAPTIVE | LK_NOSHARE); + lock_init(&lk->lock_object, &lock_class_lockmgr, wmesg, NULL, iflags); lk->lk_lock = LK_UNLOCKED; lk->lk_recurse = 0; lk->lk_exslpfail = 0; lk->lk_timo = timo; lk->lk_pri = pri; - lock_init(&lk->lock_object, &lock_class_lockmgr, wmesg, NULL, iflags); STACK_ZERO(lk); } |