diff options
author | jhb <jhb@FreeBSD.org> | 2002-04-04 20:45:21 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2002-04-04 20:45:21 +0000 |
commit | 8143d2b80ef3f3c7c569be2745611d6255aefe96 (patch) | |
tree | d6b22c9acfe929382de38062c3e94c37953539b4 /sys | |
parent | 38f498fe43ea5f40a284797ebdbe58e525227a99 (diff) | |
download | FreeBSD-src-8143d2b80ef3f3c7c569be2745611d6255aefe96.zip FreeBSD-src-8143d2b80ef3f3c7c569be2745611d6255aefe96.tar.gz |
Add a new char * pointer lo_type to struct lock_object that is used to
point to a more generic name for a lock that is more suitable for use by
witness when grouping locks. For example, although network driver locks
use the interface name for the name of each lock, they should all use the
same witness and be treated the same as witness. Another example is that
all UMA zone locks should be treated the same. The witness code has also
been updated to print out the lock type in addition to the lock name in a
few places where it is relevant.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_witness.c | 47 | ||||
-rw-r--r-- | sys/sys/_lock.h | 3 |
2 files changed, 30 insertions, 20 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 9c393f2..74b49fa 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -244,6 +244,7 @@ STAILQ_HEAD(, lock_object) all_locks = STAILQ_HEAD_INITIALIZER(all_locks); static struct mtx all_mtx = { { &lock_class_mtx_sleep, /* mtx_object.lo_class */ "All locks list", /* mtx_object.lo_name */ + "All locks list", /* mtx_object.lo_type */ LO_INITIALIZED, /* mtx_object.lo_flags */ { NULL }, /* mtx_object.lo_list */ NULL }, /* mtx_object.lo_witness */ @@ -283,7 +284,8 @@ witness_initialize(void *dummy __unused) CTR1(KTR_WITNESS, "%s: initializing witness", __func__); STAILQ_INSERT_HEAD(&all_locks, &all_mtx.mtx_object, lo_list); - mtx_init(&w_mtx, "witness lock", MTX_SPIN | MTX_QUIET | MTX_NOWITNESS); + mtx_init(&w_mtx, "witness lock", NULL, MTX_SPIN | MTX_QUIET | + MTX_NOWITNESS); for (i = 0; i < WITNESS_COUNT; i++) witness_free(&w_data[i]); for (i = 0; i < WITNESS_CHILDCOUNT; i++) @@ -311,7 +313,7 @@ witness_initialize(void *dummy __unused) mtx_lock(&all_mtx); STAILQ_FOREACH(lock, &all_locks, lo_list) { if (lock->lo_flags & LO_WITNESS) - lock->lo_witness = enroll(lock->lo_name, + lock->lo_witness = enroll(lock->lo_type, lock->lo_class); else lock->lo_witness = NULL; @@ -356,7 +358,7 @@ witness_init(struct lock_object *lock) mtx_unlock(&all_mtx); if (!witness_cold && !witness_dead && panicstr == NULL && (lock->lo_flags & LO_WITNESS) != 0) - lock->lo_witness = enroll(lock->lo_name, class); + lock->lo_witness = enroll(lock->lo_type, class); else lock->lo_witness = NULL; } @@ -551,9 +553,10 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line) goto out; w->w_same_squawked = 1; printf("acquiring duplicate lock of same type: \"%s\"\n", - lock->lo_name); - printf(" 1st @ %s:%d\n", lock1->li_file, lock1->li_line); - printf(" 2nd @ %s:%d\n", file, line); + lock->lo_type); + printf(" 1st %s @ %s:%d\n", lock1->li_lock->lo_name, + lock1->li_file, lock1->li_line); + printf(" 2nd %s @ %s:%d\n", lock->lo_name, file, line); #ifdef DDB go_into_ddb = 1; #endif /* DDB */ @@ -647,20 +650,23 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line) } } while (i >= 0); if (i < 0) { - printf(" 1st %p %s @ %s:%d\n", lock1->li_lock, - lock1->li_lock->lo_name, lock1->li_file, + printf(" 1st %p %s (%s) @ %s:%d\n", + lock1->li_lock, lock1->li_lock->lo_name, + lock1->li_lock->lo_type, lock1->li_file, lock1->li_line); - printf(" 2nd %p %s @ %s:%d\n", lock, - lock->lo_name, file, line); + printf(" 2nd %p %s (%s) @ %s:%d\n", lock, + lock->lo_name, lock->lo_type, file, line); } else { - printf(" 1st %p %s @ %s:%d\n", lock2->li_lock, - lock2->li_lock->lo_name, lock2->li_file, + printf(" 1st %p %s (%s) @ %s:%d\n", + lock2->li_lock, lock2->li_lock->lo_name, + lock2->li_lock->lo_type, lock2->li_file, lock2->li_line); - printf(" 2nd %p %s @ %s:%d\n", lock1->li_lock, - lock1->li_lock->lo_name, lock1->li_file, + printf(" 2nd %p %s (%s) @ %s:%d\n", + lock1->li_lock, lock1->li_lock->lo_name, + lock1->li_lock->lo_type, lock1->li_file, lock1->li_line); - printf(" 3rd %p %s @ %s:%d\n", lock, - lock->lo_name, file, line); + printf(" 3rd %p %s (%s) @ %s:%d\n", lock, + lock->lo_name, lock->lo_type, file, line); } #ifdef DDB go_into_ddb = 1; @@ -678,7 +684,7 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line) mtx_unlock_spin(&w_mtx); else { CTR3(KTR_WITNESS, "%s: adding %s as a child of %s", __func__, - lock->lo_name, lock1->li_lock->lo_name); + lock->lo_type, lock1->li_lock->lo_type); if (!itismychild(lock1->li_lock->lo_witness, w)) mtx_unlock_spin(&w_mtx); } @@ -1289,10 +1295,13 @@ witness_list_locks(struct lock_list_entry **lock_list) for (i = lle->ll_count - 1; i >= 0; i--) { instance = &lle->ll_children[i]; lock = instance->li_lock; - printf("%s (%s) %s (%p) locked @ %s:%d\n", + printf("%s %s %s", (instance->li_flags & LI_EXCLUSIVE) != 0 ? "exclusive" : "shared", - lock->lo_class->lc_name, lock->lo_name, lock, + lock->lo_class->lc_name, lock->lo_name); + if (lock->lo_type != lock->lo_name) + printf("(%s) ", lock->lo_type); + printf(" (%p) locked @ %s:%d\n", lock, instance->li_file, instance->li_line); nheld++; } diff --git a/sys/sys/_lock.h b/sys/sys/_lock.h index cc035df..c3c2540a 100644 --- a/sys/sys/_lock.h +++ b/sys/sys/_lock.h @@ -33,7 +33,8 @@ struct lock_object { struct lock_class *lo_class; - const char *lo_name; + const char *lo_name; /* Individual lock name. */ + const char *lo_type; /* General lock type. */ u_int lo_flags; STAILQ_ENTRY(lock_object) lo_list; /* List of all locks in system. */ struct witness *lo_witness; |