aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKip Macy <kmacy@FreeBSD.org>2006-11-13 05:41:46 +0000
committerKip Macy <kmacy@FreeBSD.org>2006-11-13 05:41:46 +0000
commit61bd5e21b3b5311e0fd3bc37ff730b5f17f1c924 (patch)
treefaa5c9764e0735ad055fed3a6440173e14455120
parent430e6e77f090d8673277249d5e27df67e5fb9b61 (diff)
downloadsrc-61bd5e21b3b5311e0fd3bc37ff730b5f17f1c924.tar.gz
src-61bd5e21b3b5311e0fd3bc37ff730b5f17f1c924.zip
track lock class name in a way that doesn't break WITNESS
Notes
Notes: svn path=/head/; revision=164246
-rw-r--r--sys/kern/kern_lock.c22
-rw-r--r--sys/kern/kern_mutex.c2
-rw-r--r--sys/kern/kern_rwlock.c2
-rw-r--r--sys/kern/kern_sx.c2
-rw-r--r--sys/kern/subr_lock.c7
-rw-r--r--sys/sys/_lock.h11
-rw-r--r--sys/sys/lock.h1
-rw-r--r--sys/sys/lock_profile.h5
8 files changed, 32 insertions, 20 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index 952167aeea8f..2e010b7df899 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -62,8 +62,19 @@ __FBSDID("$FreeBSD$");
#ifdef DDB
#include <ddb/ddb.h>
+static void db_show_lockmgr(struct lock_object *lock);
#endif
+
+struct lock_class lock_class_lockmgr = {
+ "lockmgr",
+ LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE,
+#ifdef DDB
+ db_show_lockmgr
+#endif
+};
+
+
/*
* Locking primitives implementation.
* Locks provide shared/exclusive sychronization.
@@ -166,8 +177,6 @@ _lockmgr(struct lock *lkp, int flags, struct mtx *interlkp,
thr = td;
lock_profile_waitstart(&waitstart);
-
- lkp->lk_object.lo_type = "lockmgr";
if ((flags & LK_INTERNAL) == 0)
mtx_lock(lkp->lk_interlock);
CTR6(KTR_LOCK,
@@ -523,7 +532,7 @@ lockinit(lkp, prio, wmesg, timo, flags)
#ifdef DEBUG_LOCKS
stack_zero(&lkp->lk_stack);
#endif
- lock_profile_object_init(&lkp->lk_object, wmesg);
+ lock_profile_object_init(&lkp->lk_object, &lock_class_lockmgr, wmesg);
}
/*
@@ -648,14 +657,13 @@ lockmgr_chain(struct thread *td, struct thread **ownerp)
return (1);
}
-DB_SHOW_COMMAND(lockmgr, db_show_lockmgr)
+void
+db_show_lockmgr(struct lock_object *lock)
{
struct thread *td;
struct lock *lkp;
- if (!have_addr)
- return;
- lkp = (struct lock *)addr;
+ lkp = (struct lock *)lock;
db_printf("lock type: %s\n", lkp->lk_wmesg);
db_printf("state: ");
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index b4ec84390950..ef8b5f331184 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -656,7 +656,7 @@ mtx_init(struct mtx *m, const char *name, const char *type, int opts)
m->mtx_lock = MTX_UNOWNED;
m->mtx_recurse = 0;
- lock_profile_object_init(&m->mtx_object, name);
+ lock_profile_object_init(&m->mtx_object, class, name);
lock_init(&m->mtx_object, class, name, type, flags);
}
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
index 96ed3f0aaeb8..82535fe56d12 100644
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -86,7 +86,7 @@ rw_init(struct rwlock *rw, const char *name)
rw->rw_lock = RW_UNLOCKED;
- lock_profile_object_init(&rw->rw_object, name);
+ lock_profile_object_init(&rw->rw_object, &lock_class_rw, name);
lock_init(&rw->rw_object, &lock_class_rw, name, NULL, LO_WITNESS |
LO_RECURSABLE | LO_UPGRADABLE);
}
diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c
index 23fdb72455e7..ecab0e91a599 100644
--- a/sys/kern/kern_sx.c
+++ b/sys/kern/kern_sx.c
@@ -86,7 +86,7 @@ sx_init(struct sx *sx, const char *description)
cv_init(&sx->sx_excl_cv, description);
sx->sx_excl_wcnt = 0;
sx->sx_xholder = NULL;
- lock_profile_object_init(&sx->sx_object, description);
+ lock_profile_object_init(&sx->sx_object, &lock_class_sx, description);
lock_init(&sx->sx_object, &lock_class_sx, description, NULL,
LO_WITNESS | LO_RECURSABLE | LO_SLEEPABLE | LO_UPGRADABLE);
}
diff --git a/sys/kern/subr_lock.c b/sys/kern/subr_lock.c
index 94e7d8819a33..adf5e594ba1a 100644
--- a/sys/kern/subr_lock.c
+++ b/sys/kern/subr_lock.c
@@ -58,6 +58,7 @@ struct lock_class *lock_classes[LOCK_CLASS_MAX + 1] = {
&lock_class_mtx_sleep,
&lock_class_sx,
&lock_class_rw,
+ &lock_class_lockmgr,
};
#ifdef LOCK_PROFILING
@@ -305,9 +306,9 @@ void _lock_profile_update_wait(struct lock_object *lo, uint64_t waitstart)
}
mpp->file = p;
mpp->line = l->lpo_lineno;
- mpp->name = lo->lo_name;
- mpp->type = lo->lo_type;
mpp->namehash = l->lpo_namehash;
+ mpp->type = l->lpo_type;
+ mpp->name = lo->lo_name;
if (collision)
++lock_prof_collisions;
/* We might have raced someone else but who cares, they'll try again next time */
@@ -368,7 +369,7 @@ void _lock_profile_release_lock(struct lock_object *lo)
mpp->file = p;
mpp->line = l->lpo_lineno;
mpp->namehash = l->lpo_namehash;
- mpp->type = lo->lo_type;
+ mpp->type = l->lpo_type;
mpp->name = lo->lo_name;
if (collision)
diff --git a/sys/sys/_lock.h b/sys/sys/_lock.h
index 22553498fd5e..cc1ea0ab80d8 100644
--- a/sys/sys/_lock.h
+++ b/sys/sys/_lock.h
@@ -36,11 +36,12 @@ struct lock_profile_object {
* This does not result in variant structure sizes because
* MUTEX_PROFILING is in opt_global.h
*/
- u_int64_t lpo_acqtime;
- u_int64_t lpo_waittime;
- const char *lpo_filename;
- u_int lpo_namehash;
- int lpo_lineno;
+ u_int64_t lpo_acqtime;
+ u_int64_t lpo_waittime;
+ const char *lpo_filename;
+ u_int lpo_namehash;
+ int lpo_lineno;
+ const char *lpo_type;
/*
* Fields relating to measuring contention on mutexes.
* holding must be accessed atomically since it's
diff --git a/sys/sys/lock.h b/sys/sys/lock.h
index 9ca937612cff..29cdc76bbc05 100644
--- a/sys/sys/lock.h
+++ b/sys/sys/lock.h
@@ -213,6 +213,7 @@ extern struct lock_class lock_class_mtx_sleep;
extern struct lock_class lock_class_mtx_spin;
extern struct lock_class lock_class_sx;
extern struct lock_class lock_class_rw;
+extern struct lock_class lock_class_lockmgr;
extern struct lock_class *lock_classes[];
diff --git a/sys/sys/lock_profile.h b/sys/sys/lock_profile.h
index c3a38a489d2c..5a6465c9296e 100644
--- a/sys/sys/lock_profile.h
+++ b/sys/sys/lock_profile.h
@@ -91,7 +91,7 @@ static inline void lock_profile_init(void)
}
}
-static inline void lock_profile_object_init(struct lock_object *lo, const char *name) {
+static inline void lock_profile_object_init(struct lock_object *lo, struct lock_class *class, const char *name) {
const char *p;
u_int hash = 0;
struct lock_profile_object *l = &lo->lo_profile_obj;
@@ -104,6 +104,7 @@ static inline void lock_profile_object_init(struct lock_object *lo, const char *
l->lpo_lineno = 0;
l->lpo_contest_holding = 0;
l->lpo_contest_locking = 0;
+ l->lpo_type = class->lc_name;
/* Hash the mutex name to an int so we don't have to strcmp() it repeatedly */
for (p = name; *p != '\0'; p++)
@@ -170,7 +171,7 @@ static inline void lock_profile_obtain_lock_failed(struct lock_object *lo, int *
static inline void lock_profile_obtain_lock_success(struct lock_object *lo, uint64_t waittime,
const char *file, int line) {;}
static inline void lock_profile_object_destroy(struct lock_object *lo) {;}
-static inline void lock_profile_object_init(struct lock_object *lo, const char *name) {;}
+static inline void lock_profile_object_init(struct lock_object *lo, struct lock_class *class, const char *name) {;}
#endif /* !LOCK_PROFILING */