summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2002-04-04 20:52:27 +0000
committerjhb <jhb@FreeBSD.org>2002-04-04 20:52:27 +0000
commitec0e08c9444306d8093468bc7a54703a255e8d28 (patch)
treef9cd7ddc9bf36a0e10c9ea4900b6a23d76b539e4 /sys/kern/kern_mutex.c
parent883d8a55267a8794b49fe0d31af99d0e6f9835ad (diff)
downloadFreeBSD-src-ec0e08c9444306d8093468bc7a54703a255e8d28.zip
FreeBSD-src-ec0e08c9444306d8093468bc7a54703a255e8d28.tar.gz
Change mtx_init() to now take an extra argument. The third argument is
the generic lock type for use with witness. If this argument is NULL then the lock name is used as the lock type. Add a macro for a lock type name for network driver locks.
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index fe8560a..b0e3f30 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -789,15 +789,17 @@ mtx_sysinit(void *arg)
{
struct mtx_args *margs = arg;
- mtx_init(margs->ma_mtx, margs->ma_desc, margs->ma_opts);
+ mtx_init(margs->ma_mtx, margs->ma_desc, NULL, margs->ma_opts);
}
/*
* Mutex initialization routine; initialize lock `m' of type contained in
- * `opts' with options contained in `opts' and description `description.'
+ * `opts' with options contained in `opts' and name `name.' The optional
+ * lock type `type' is used as a general lock category name for use with
+ * witness.
*/
void
-mtx_init(struct mtx *m, const char *description, int opts)
+mtx_init(struct mtx *m, const char *name, const char *type, int opts)
{
struct lock_object *lock;
@@ -811,13 +813,14 @@ mtx_init(struct mtx *m, const char *description, int opts)
lock = &m->mtx_object;
KASSERT((lock->lo_flags & LO_INITIALIZED) == 0,
- ("mutex %s %p already initialized", description, m));
+ ("mutex %s %p already initialized", name, m));
bzero(m, sizeof(*m));
if (opts & MTX_SPIN)
lock->lo_class = &lock_class_mtx_spin;
else
lock->lo_class = &lock_class_mtx_sleep;
- lock->lo_name = description;
+ lock->lo_name = name;
+ lock->lo_type = type != NULL ? type : name;
if (opts & MTX_QUIET)
lock->lo_flags = LO_QUIET;
if (opts & MTX_RECURSE)
@@ -877,9 +880,9 @@ mutex_init(void)
/*
* Initialize mutexes.
*/
- mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE);
- mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE);
- mtx_init(&proc0.p_mtx, "process lock", MTX_DEF | MTX_DUPOK);
+ mtx_init(&Giant, "Giant", NULL, MTX_DEF | MTX_RECURSE);
+ mtx_init(&sched_lock, "sched lock", NULL, MTX_SPIN | MTX_RECURSE);
+ mtx_init(&proc0.p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK);
mtx_lock(&Giant);
}
OpenPOWER on IntegriCloud