track lock class name in a way that doesn't break WITNESS
This commit is contained in:
parent
3434de5c13
commit
ec9503cd04
@ -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: ");
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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[];
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user