summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorkmacy <kmacy@FreeBSD.org>2007-02-27 06:42:05 +0000
committerkmacy <kmacy@FreeBSD.org>2007-02-27 06:42:05 +0000
commitb7672bad26dbe5a50937a2e258fe957b1bc19a8d (patch)
treec7228dd81a9d5cf5855323c889da39c667a4dd5a /sys/kern/kern_mutex.c
parent128ac1d5958eb05b5b0c08882c80a3f90ef76d1b (diff)
downloadFreeBSD-src-b7672bad26dbe5a50937a2e258fe957b1bc19a8d.zip
FreeBSD-src-b7672bad26dbe5a50937a2e258fe957b1bc19a8d.tar.gz
Further improvements to LOCK_PROFILING:
- Fix missing initialization in kern_rwlock.c causing bogus times to be collected - Move updates to the lock hash to after the lock is released for spin mutexes, sleep mutexes, and sx locks - Add new kernel build option LOCK_PROFILE_FAST - only update lock profiling statistics when an acquisition is contended. This reduces the overhead of LOCK_PROFILING to increasing system time by 20%-25% which on "make -j8 kernel-toolchain" on a dual woodcrest is unmeasurable in terms of wall-clock time. Contrast this to enabling lock profiling without LOCK_PROFILE_FAST and I see a 5x-6x slowdown in wall-clock time.
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index b3b652e..00d0353 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -158,6 +158,8 @@ void
_mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line)
{
+ struct lock_object lo;
+
MPASS(curthread != NULL);
KASSERT(m->mtx_lock != MTX_DESTROYED,
("mtx_unlock() of destroyed mutex @ %s:%d", file, line));
@@ -169,9 +171,12 @@ _mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line)
LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file,
line);
mtx_assert(m, MA_OWNED);
-
- lock_profile_release_lock(&m->mtx_object);
+#ifdef LOCK_PROFILING
+ memcpy(&lo, &m->mtx_object, sizeof(lo));
+ m->mtx_object.lo_flags &= ~LO_CONTESTED;
+#endif
_rel_sleep_lock(m, curthread, opts, file, line);
+ lock_profile_release_lock(&lo);
}
void
@@ -196,6 +201,8 @@ void
_mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file, int line)
{
+ struct lock_object lo;
+
MPASS(curthread != NULL);
KASSERT(m->mtx_lock != MTX_DESTROYED,
("mtx_unlock_spin() of destroyed mutex @ %s:%d", file, line));
@@ -206,8 +213,12 @@ _mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file, int line)
LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file,
line);
mtx_assert(m, MA_OWNED);
- lock_profile_release_lock(&m->mtx_object);
+#ifdef LOCK_PROFILING
+ memcpy(&lo, &m->mtx_object, sizeof(lo));
+ m->mtx_object.lo_flags &= ~LO_CONTESTED;
+#endif
_rel_spin_lock(m);
+ lock_profile_release_lock(&lo);
}
/*
OpenPOWER on IntegriCloud