summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sx.c
diff options
context:
space:
mode:
authorkmacy <kmacy@FreeBSD.org>2007-02-26 08:26:44 +0000
committerkmacy <kmacy@FreeBSD.org>2007-02-26 08:26:44 +0000
commit6508c4f27bec4ddc3e098c59b24d6760e5db774d (patch)
tree329dd33524baa0ad9fe43f498498a2d120152d0d /sys/kern/kern_sx.c
parent01ee9020b350e550aa823f81efbe79cba3e5cb58 (diff)
downloadFreeBSD-src-6508c4f27bec4ddc3e098c59b24d6760e5db774d.zip
FreeBSD-src-6508c4f27bec4ddc3e098c59b24d6760e5db774d.tar.gz
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
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 ecab0e9..e0bff42 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++;
OpenPOWER on IntegriCloud