aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_rwlock.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2013-06-25 20:23:08 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2013-06-25 20:23:08 +0000
commitb5fb43e5727b6307531d8df908ca32882ce60f6d (patch)
tree60cbcb3e979ff7a6b8fbdeb319c971bd474cb372 /sys/kern/kern_rwlock.c
parentcd32bd7ad19a39a19789ffcc4d70dca646c3914b (diff)
downloadsrc-b5fb43e5727b6307531d8df908ca32882ce60f6d.tar.gz
src-b5fb43e5727b6307531d8df908ca32882ce60f6d.zip
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.
Notes
Notes: svn path=/head/; revision=252212
Diffstat (limited to 'sys/kern/kern_rwlock.c')
-rw-r--r--sys/kern/kern_rwlock.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
index ecb530862b5c..bd4070484a15 100644
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -207,9 +207,9 @@ _rw_init_flags(volatile uintptr_t *c, const char *name, int opts)
if (opts & RW_QUIET)
flags |= LO_QUIET;
+ lock_init(&rw->lock_object, &lock_class_rw, name, NULL, flags);
rw->rw_lock = RW_UNLOCKED;
rw->rw_recurse = 0;
- lock_init(&rw->lock_object, &lock_class_rw, name, NULL, flags);
}
void
@@ -319,13 +319,13 @@ _rw_wunlock_cookie(volatile uintptr_t *c, const char *file, int line)
KASSERT(rw->rw_lock != RW_DESTROYED,
("rw_wunlock() of destroyed rwlock @ %s:%d", file, line));
__rw_assert(c, RA_WLOCKED, file, line);
- curthread->td_locks--;
WITNESS_UNLOCK(&rw->lock_object, LOP_EXCLUSIVE, file, line);
LOCK_LOG_LOCK("WUNLOCK", &rw->lock_object, 0, rw->rw_recurse, file,
line);
if (!rw_recursed(rw))
LOCKSTAT_PROFILE_RELEASE_LOCK(LS_RW_WUNLOCK_RELEASE, rw);
__rw_wunlock(rw, curthread, file, line);
+ curthread->td_locks--;
}
/*
* Determines whether a new reader can acquire a lock. Succeeds if the
@@ -598,8 +598,6 @@ _rw_runlock_cookie(volatile uintptr_t *c, const char *file, int line)
KASSERT(rw->rw_lock != RW_DESTROYED,
("rw_runlock() of destroyed rwlock @ %s:%d", file, line));
__rw_assert(c, RA_RLOCKED, file, line);
- curthread->td_locks--;
- curthread->td_rw_rlocks--;
WITNESS_UNLOCK(&rw->lock_object, 0, file, line);
LOCK_LOG_LOCK("RUNLOCK", &rw->lock_object, 0, 0, file, line);
@@ -693,6 +691,8 @@ _rw_runlock_cookie(volatile uintptr_t *c, const char *file, int line)
break;
}
LOCKSTAT_PROFILE_RELEASE_LOCK(LS_RW_RUNLOCK_RELEASE, rw);
+ curthread->td_locks--;
+ curthread->td_rw_rlocks--;
}
/*