diff options
author | markj <markj@FreeBSD.org> | 2015-07-21 17:16:37 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2015-07-21 17:16:37 +0000 |
commit | 84c91edd5356f5693f0ecd74d787e98b52fee0b4 (patch) | |
tree | e3d69a4db0089a008c7c2596149b6277d1473fbf /sys/kern/kern_mutex.c | |
parent | 10c80a84dab9d6dfc505ebcda9ca49b6caa78f90 (diff) | |
download | FreeBSD-src-84c91edd5356f5693f0ecd74d787e98b52fee0b4.zip FreeBSD-src-84c91edd5356f5693f0ecd74d787e98b52fee0b4.tar.gz |
MFC r285663, r285664, r285667:
Ensure that locstat_nsecs() has no effect when lockstat probes are not
enabled or when the profiled lock carries the LO_NOPROFILE flag.
PR: 201642, 201517
Approved by: re (gjb)
Tested by: Jason Unovitch
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r-- | sys/kern/kern_mutex.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 7ef02fb..fb0b313 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -420,7 +420,7 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t tid, int opts, "_mtx_lock_sleep: %s contested (lock=%p) at %s:%d", m->lock_object.lo_name, (void *)m->mtx_lock, file, line); #ifdef KDTRACE_HOOKS - all_time -= lockstat_nsecs(); + all_time -= lockstat_nsecs(&m->lock_object); #endif while (!_mtx_obtain_lock(m, tid)) { @@ -517,16 +517,16 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t tid, int opts, * Block on the turnstile. */ #ifdef KDTRACE_HOOKS - sleep_time -= lockstat_nsecs(); + sleep_time -= lockstat_nsecs(&m->lock_object); #endif turnstile_wait(ts, mtx_owner(m), TS_EXCLUSIVE_QUEUE); #ifdef KDTRACE_HOOKS - sleep_time += lockstat_nsecs(); + sleep_time += lockstat_nsecs(&m->lock_object); sleep_cnt++; #endif } #ifdef KDTRACE_HOOKS - all_time += lockstat_nsecs(); + all_time += lockstat_nsecs(&m->lock_object); #endif #ifdef KTR if (cont_logged) { @@ -604,7 +604,7 @@ _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t tid, int opts, #endif lock_profile_obtain_lock_failed(&m->lock_object, &contested, &waittime); #ifdef KDTRACE_HOOKS - spin_time -= lockstat_nsecs(); + spin_time -= lockstat_nsecs(&m->lock_object); #endif while (!_mtx_obtain_lock(m, tid)) { @@ -624,7 +624,7 @@ _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t tid, int opts, spinlock_enter(); } #ifdef KDTRACE_HOOKS - spin_time += lockstat_nsecs(); + spin_time += lockstat_nsecs(&m->lock_object); #endif if (LOCK_LOG_TEST(&m->lock_object, opts)) @@ -634,7 +634,10 @@ _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t tid, int opts, LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, m, contested, waittime, (file), (line)); - LOCKSTAT_RECORD1(LS_MTX_SPIN_LOCK_SPIN, m, spin_time); +#ifdef KDTRACE_HOOKS + if (spin_time != 0) + LOCKSTAT_RECORD1(LS_MTX_SPIN_LOCK_SPIN, m, spin_time); +#endif } #endif /* SMP */ @@ -659,7 +662,7 @@ thread_lock_flags_(struct thread *td, int opts, const char *file, int line) return; #ifdef KDTRACE_HOOKS - spin_time -= lockstat_nsecs(); + spin_time -= lockstat_nsecs(&td->td_lock->lock_object); #endif for (;;) { retry: @@ -707,7 +710,7 @@ retry: __mtx_unlock_spin(m); /* does spinlock_exit() */ } #ifdef KDTRACE_HOOKS - spin_time += lockstat_nsecs(); + spin_time += lockstat_nsecs(&m->lock_object); #endif if (m->mtx_recurse == 0) LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, |