summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorkmacy <kmacy@FreeBSD.org>2006-12-16 02:37:58 +0000
committerkmacy <kmacy@FreeBSD.org>2006-12-16 02:37:58 +0000
commitad3abace0cb8e4401b0dd5b68b63f1c8405baeef (patch)
treef0bcef7d4d608e41f61c1ec11703db59af89df11 /sys/kern/kern_mutex.c
parent1d3d170d84fa1e6127bdf989319a5d7a91f81745 (diff)
downloadFreeBSD-src-ad3abace0cb8e4401b0dd5b68b63f1c8405baeef.zip
FreeBSD-src-ad3abace0cb8e4401b0dd5b68b63f1c8405baeef.tar.gz
- Fix some gcc warnings in lock_profile.h
- add cnt_hold cnt_lock support for spin mutexes - make sure contested is initialized to zero to only bump contested when appropriate - move initialization function to kern_mutex.c to avoid cyclic dependency between mutex.h and lock_profile.h
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index ef8b5f3..55ae0f3 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -116,6 +116,20 @@ struct lock_class lock_class_mtx_spin = {
struct mtx sched_lock;
struct mtx Giant;
+#ifdef LOCK_PROFILING
+static inline void lock_profile_init(void)
+{
+ int i;
+ /* Initialize the mutex profiling locks */
+ for (i = 0; i < LPROF_LOCK_SIZE; i++) {
+ mtx_init(&lprof_locks[i], "mprof lock",
+ NULL, MTX_SPIN|MTX_QUIET|MTX_NOPROFILE);
+ }
+}
+#else
+static inline void lock_profile_init(void) {;}
+#endif
+
/*
* Function versions of the inlined __mtx_* macros. These are used by
* modules and can also be called from assembly language if needed.
@@ -257,7 +271,7 @@ _mtx_lock_sleep(struct mtx *m, uintptr_t tid, int opts, const char *file,
int cont_logged = 0;
#endif
uintptr_t v;
- int contested;
+ int contested = 0;
if (mtx_owned(m)) {
KASSERT((m->mtx_object.lo_flags & LO_RECURSABLE) != 0,
@@ -325,10 +339,11 @@ _mtx_lock_sleep(struct mtx *m, uintptr_t tid, int opts, const char *file,
*/
owner = (struct thread *)(v & ~MTX_FLAGMASK);
#ifdef ADAPTIVE_GIANT
- if (TD_IS_RUNNING(owner)) {
+ if (TD_IS_RUNNING(owner))
#else
- if (m != &Giant && TD_IS_RUNNING(owner)) {
+ if (m != &Giant && TD_IS_RUNNING(owner))
#endif
+ {
turnstile_release(&m->mtx_object);
while (mtx_owner(m) == owner && TD_IS_RUNNING(owner)) {
cpu_spinwait();
@@ -359,7 +374,6 @@ _mtx_lock_sleep(struct mtx *m, uintptr_t tid, int opts, const char *file,
turnstile_wait(&m->mtx_object, mtx_owner(m),
TS_EXCLUSIVE_QUEUE);
}
-
#ifdef KTR
if (cont_logged) {
CTR4(KTR_CONTENTION,
@@ -368,9 +382,9 @@ _mtx_lock_sleep(struct mtx *m, uintptr_t tid, int opts, const char *file,
}
#endif
#ifdef LOCK_PROFILING
+ m->mtx_object.lo_profile_obj.lpo_contest_holding = 0;
if (contested)
m->mtx_object.lo_profile_obj.lpo_contest_locking++;
- m->mtx_object.lo_profile_obj.lpo_contest_holding = 0;
#endif
return;
}
@@ -387,7 +401,7 @@ _mtx_lock_spin(struct mtx *m, uintptr_t tid, int opts, const char *file,
int line)
{
struct thread *td;
- int contested, i = 0;
+ int contested = 0, i = 0;
if (LOCK_LOG_TEST(&m->mtx_object, opts))
CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m);
OpenPOWER on IntegriCloud