aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sx.c
diff options
context:
space:
mode:
authorKip Macy <kmacy@FreeBSD.org>2007-02-26 08:26:44 +0000
committerKip Macy <kmacy@FreeBSD.org>2007-02-26 08:26:44 +0000
commitfe68a9163151dfb00adbf9de32b482579f46af76 (patch)
tree329dd33524baa0ad9fe43f498498a2d120152d0d /sys/kern/kern_sx.c
parent772ad651bf7af82b57558e5a6268e3961e9c2ad8 (diff)
downloadsrc-fe68a9163151dfb00adbf9de32b482579f46af76.tar.gz
src-fe68a9163151dfb00adbf9de32b482579f46af76.zip
general LOCK_PROFILING cleanup
- only collect timestamps when a lock is contested - this reduces the overhead of collecting profiles from 20x to 5x - remove unused function from subr_lock.c - generalize cnt_hold and cnt_lock statistics to be kept for all locks - NOTE: rwlock profiling generates invalid statistics (and most likely always has) someone familiar with that should review
Notes
Notes: svn path=/head/; revision=167012
Diffstat (limited to 'sys/kern/kern_sx.c')
-rw-r--r--sys/kern/kern_sx.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c
index ecab0e91a599..e0bff421c2d7 100644
--- a/sys/kern/kern_sx.c
+++ b/sys/kern/kern_sx.c
@@ -111,7 +111,7 @@ void
_sx_slock(struct sx *sx, const char *file, int line)
{
uint64_t waittime = 0;
- int contested;
+ int contested = 0;
mtx_lock(sx->sx_lock);
KASSERT(sx->sx_xholder != curthread,
@@ -122,11 +122,9 @@ _sx_slock(struct sx *sx, const char *file, int line)
/*
* Loop in case we lose the race for lock acquisition.
*/
- if (sx->sx_cnt < 0)
- lock_profile_waitstart(&waittime);
while (sx->sx_cnt < 0) {
sx->sx_shrd_wcnt++;
- lock_profile_obtain_lock_failed(&sx->sx_object, &contested);
+ lock_profile_obtain_lock_failed(&sx->sx_object, &contested, &waittime);
cv_wait(&sx->sx_shrd_cv, sx->sx_lock);
sx->sx_shrd_wcnt--;
}
@@ -135,7 +133,7 @@ _sx_slock(struct sx *sx, const char *file, int line)
sx->sx_cnt++;
if (sx->sx_cnt == 1)
- lock_profile_obtain_lock_success(&sx->sx_object, waittime, file, line);
+ lock_profile_obtain_lock_success(&sx->sx_object, contested, waittime, file, line);
LOCK_LOG_LOCK("SLOCK", &sx->sx_object, 0, 0, file, line);
WITNESS_LOCK(&sx->sx_object, 0, file, line);
@@ -166,7 +164,7 @@ _sx_try_slock(struct sx *sx, const char *file, int line)
void
_sx_xlock(struct sx *sx, const char *file, int line)
{
- int contested;
+ int contested = 0;
uint64_t waittime = 0;
mtx_lock(sx->sx_lock);
@@ -184,12 +182,10 @@ _sx_xlock(struct sx *sx, const char *file, int line)
WITNESS_CHECKORDER(&sx->sx_object, LOP_NEWORDER | LOP_EXCLUSIVE, file,
line);
- if (sx->sx_cnt)
- lock_profile_waitstart(&waittime);
/* Loop in case we lose the race for lock acquisition. */
while (sx->sx_cnt != 0) {
sx->sx_excl_wcnt++;
- lock_profile_obtain_lock_failed(&sx->sx_object, &contested);
+ lock_profile_obtain_lock_failed(&sx->sx_object, &contested, &waittime);
cv_wait(&sx->sx_excl_cv, sx->sx_lock);
sx->sx_excl_wcnt--;
}
@@ -200,7 +196,7 @@ _sx_xlock(struct sx *sx, const char *file, int line)
sx->sx_cnt--;
sx->sx_xholder = curthread;
- lock_profile_obtain_lock_success(&sx->sx_object, waittime, file, line);
+ lock_profile_obtain_lock_success(&sx->sx_object, contested, waittime, file, line);
LOCK_LOG_LOCK("XLOCK", &sx->sx_object, 0, 0, file, line);
WITNESS_LOCK(&sx->sx_object, LOP_EXCLUSIVE, file, line);
curthread->td_locks++;