diff options
-rw-r--r-- | sys/kern/kern_mutex.c | 19 | ||||
-rw-r--r-- | sys/kern/subr_turnstile.c | 19 | ||||
-rw-r--r-- | sys/sys/mutex.h | 7 |
3 files changed, 28 insertions, 17 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); } diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c index fe8560a..b0e3f30 100644 --- a/sys/kern/subr_turnstile.c +++ b/sys/kern/subr_turnstile.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); } diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index fb60711..bd0c52c 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -97,7 +97,7 @@ * [See below for descriptions] * */ -void mtx_init(struct mtx *m, const char *description, int opts); +void mtx_init(struct mtx *m, const char *name, const char *type, int opts); void mtx_destroy(struct mtx *m); void mtx_sysinit(void *arg); void mutex_init(void); @@ -370,6 +370,11 @@ struct mtx_args { #define GIANT_REQUIRED #endif /* INVARIANTS */ +/* + * Common lock type names. + */ +#define MTX_NETWORK_LOCK "network driver" + #endif /* _KERNEL */ #endif /* !LOCORE */ #endif /* _SYS_MUTEX_H_ */ |