From 773890b9a8cce69dcb5b848766d459fea3faad2b Mon Sep 17 00:00:00 2001 From: Jeff Roberson Date: Wed, 18 Jul 2007 20:38:13 +0000 Subject: [PATCH] - Add the proper lock profiling calls to _thread_lock(). Obtained from: kipmacy Approved by: re --- sys/kern/kern_mutex.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index a36a2ed7c9f..426c1b3c430 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -473,9 +473,12 @@ _thread_lock_flags(struct thread *td, int opts, const char *file, int line) { struct mtx *m; uintptr_t tid; - int i; + int i, contested; + uint64_t waittime; - i = 0; + + contested = i = 0; + waittime = 0; tid = (uintptr_t)curthread; for (;;) { retry: @@ -488,6 +491,7 @@ retry: m->mtx_recurse++; break; } + lock_profile_obtain_lock_failed(&m->lock_object, &contested, &waittime); /* Give interrupts a chance while we spin. */ spinlock_exit(); while (m->mtx_lock != MTX_UNOWNED) { @@ -508,6 +512,8 @@ retry: break; _rel_spin_lock(m); /* does spinlock_exit() */ } + lock_profile_obtain_lock_success(&m->lock_object, contested, + waittime, (file), (line)); WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line); }