summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/alpha/alpha/machdep.c2
-rw-r--r--sys/amd64/amd64/machdep.c2
-rw-r--r--sys/i386/i386/machdep.c2
-rw-r--r--sys/ia64/ia64/machdep.c2
-rw-r--r--sys/kern/init_main.c2
-rw-r--r--sys/kern/kern_fork.c2
-rw-r--r--sys/kern/kern_mutex.c4
-rw-r--r--sys/kern/kern_proc.c2
-rw-r--r--sys/kern/subr_turnstile.c4
-rw-r--r--sys/kern/subr_witness.c20
-rw-r--r--sys/powerpc/aim/machdep.c2
-rw-r--r--sys/powerpc/powerpc/machdep.c2
-rw-r--r--sys/sparc64/sparc64/machdep.c2
-rw-r--r--sys/sys/lock.h1
-rw-r--r--sys/sys/mutex.h1
-rw-r--r--sys/vm/uma_int.h2
16 files changed, 20 insertions, 32 deletions
diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c
index 7fd8867..2b12d2d 100644
--- a/sys/alpha/alpha/machdep.c
+++ b/sys/alpha/alpha/machdep.c
@@ -955,7 +955,7 @@ alpha_init(pfn, ptb, bim, bip, biv)
*/
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_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK);
mtx_init(&clock_lock, "clk", MTX_SPIN | MTX_RECURSE);
mtx_init(&icu_lock, "icu", MTX_SPIN);
mtx_lock(&Giant);
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 8b6cc82..b96b93e 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -1705,7 +1705,7 @@ init386(first)
*/
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_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK);
mtx_init(&clock_lock, "clk", MTX_SPIN | MTX_RECURSE);
mtx_init(&icu_lock, "icu", MTX_SPIN | MTX_NOWITNESS);
mtx_lock(&Giant);
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 8b6cc82..b96b93e 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -1705,7 +1705,7 @@ init386(first)
*/
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_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK);
mtx_init(&clock_lock, "clk", MTX_SPIN | MTX_RECURSE);
mtx_init(&icu_lock, "icu", MTX_SPIN | MTX_NOWITNESS);
mtx_lock(&Giant);
diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c
index 05f1c71..417439b 100644
--- a/sys/ia64/ia64/machdep.c
+++ b/sys/ia64/ia64/machdep.c
@@ -694,7 +694,7 @@ ia64_init(u_int64_t arg1, u_int64_t arg2)
*/
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_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK);
mtx_lock(&Giant);
/*
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index e847534..d64a965 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -305,7 +305,7 @@ proc0_init(void *dummy __unused)
*/
LIST_INSERT_HEAD(&allproc, p, p_list);
LIST_INSERT_HEAD(PIDHASH(0), p, p_hash);
- mtx_init(&pgrp0.pg_mtx, "process group", MTX_DEF);
+ mtx_init(&pgrp0.pg_mtx, "process group", MTX_DEF|MTX_DUPOK);
p->p_pgrp = &pgrp0;
LIST_INSERT_HEAD(PGRPHASH(0), &pgrp0, pg_hash);
LIST_INIT(&pgrp0.pg_members);
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 723fd62..db4a459 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -463,7 +463,7 @@ again:
*/
proc_linkup(p2, kg2, ke2, td2);
- mtx_init(&p2->p_mtx, "process lock", MTX_DEF);
+ mtx_init(&p2->p_mtx, "process lock", MTX_DEF|MTX_DUPOK);
PROC_LOCK(p2);
/* note.. XXXKSE no pcb or u-area yet */
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 6847cde..95edd18 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -625,7 +625,7 @@ mtx_init(struct mtx *m, const char *description, int opts)
struct lock_object *lock;
MPASS((opts & ~(MTX_SPIN | MTX_QUIET | MTX_RECURSE |
- MTX_SLEEPABLE | MTX_NOWITNESS)) == 0);
+ MTX_SLEEPABLE | MTX_NOWITNESS | MTX_DUPOK)) == 0);
#ifdef MUTEX_DEBUG
/* Diagnostic and error correction */
@@ -649,6 +649,8 @@ mtx_init(struct mtx *m, const char *description, int opts)
lock->lo_flags |= LO_SLEEPABLE;
if ((opts & MTX_NOWITNESS) == 0)
lock->lo_flags |= LO_WITNESS;
+ if (opts & MTX_DUPOK)
+ lock->lo_flags |= LO_DUPOK;
m->mtx_lock = MTX_UNOWNED;
TAILQ_INIT(&m->mtx_blocked);
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index dff0514..0e236cb 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -341,7 +341,7 @@ enterpgrp(p, pgid, pgrp, sess)
KASSERT(!SESS_LEADER(p),
("enterpgrp: session leader attempted setpgrp"));
- mtx_init(&pgrp->pg_mtx, "process group", MTX_DEF);
+ mtx_init(&pgrp->pg_mtx, "process group", MTX_DEF|MTX_DUPOK);
if (sess != NULL) {
/*
diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c
index 6847cde..95edd18 100644
--- a/sys/kern/subr_turnstile.c
+++ b/sys/kern/subr_turnstile.c
@@ -625,7 +625,7 @@ mtx_init(struct mtx *m, const char *description, int opts)
struct lock_object *lock;
MPASS((opts & ~(MTX_SPIN | MTX_QUIET | MTX_RECURSE |
- MTX_SLEEPABLE | MTX_NOWITNESS)) == 0);
+ MTX_SLEEPABLE | MTX_NOWITNESS | MTX_DUPOK)) == 0);
#ifdef MUTEX_DEBUG
/* Diagnostic and error correction */
@@ -649,6 +649,8 @@ mtx_init(struct mtx *m, const char *description, int opts)
lock->lo_flags |= LO_SLEEPABLE;
if ((opts & MTX_NOWITNESS) == 0)
lock->lo_flags |= LO_WITNESS;
+ if (opts & MTX_DUPOK)
+ lock->lo_flags |= LO_DUPOK;
m->mtx_lock = MTX_UNOWNED;
TAILQ_INIT(&m->mtx_blocked);
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 9c0005d..53fbb96 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -124,7 +124,6 @@ static int itismychild(struct witness *parent, struct witness *child);
static void removechild(struct witness *parent, struct witness *child);
static int isitmychild(struct witness *parent, struct witness *child);
static int isitmydescendant(struct witness *parent, struct witness *child);
-static int dup_ok(struct witness *);
static int blessed(struct witness *, struct witness *);
static void witness_display_list(void(*prnt)(const char *fmt, ...),
struct witness_list *list);
@@ -228,12 +227,6 @@ static struct witness_order_list_entry order_lists[] = {
{ NULL, NULL }
};
-static const char *dup_list[] = {
- "process lock",
- "process group",
- NULL
-};
-
/*
* Pairs of locks which have been blessed
* Don't complain about order problems with blessed locks
@@ -549,7 +542,7 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line)
lock1 = &(*lock_list)->ll_children[(*lock_list)->ll_count - 1];
w1 = lock1->li_lock->lo_witness;
if (w1 == w) {
- if (w->w_same_squawked || dup_ok(w))
+ if (w->w_same_squawked || (lock->lo_flags & LO_DUPOK))
goto out;
w->w_same_squawked = 1;
printf("acquiring duplicate lock of same type: \"%s\"\n",
@@ -1144,17 +1137,6 @@ witness_displaydescendants(void(*prnt)(const char *fmt, ...),
}
static int
-dup_ok(struct witness *w)
-{
- const char **dup;
-
- for (dup = dup_list; *dup != NULL; dup++)
- if (strcmp(w->w_name, *dup) == 0)
- return (1);
- return (0);
-}
-
-static int
blessed(struct witness *w1, struct witness *w2)
{
int i;
diff --git a/sys/powerpc/aim/machdep.c b/sys/powerpc/aim/machdep.c
index 654c566..e078d12 100644
--- a/sys/powerpc/aim/machdep.c
+++ b/sys/powerpc/aim/machdep.c
@@ -392,7 +392,7 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, char *args)
*/
mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE);
mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE);
- mtx_init(&proc0.p_mtx, "process lock", MTX_DEF);
+ mtx_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK);
mtx_lock(&Giant);
/*
diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c
index 654c566..e078d12 100644
--- a/sys/powerpc/powerpc/machdep.c
+++ b/sys/powerpc/powerpc/machdep.c
@@ -392,7 +392,7 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, char *args)
*/
mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE);
mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE);
- mtx_init(&proc0.p_mtx, "process lock", MTX_DEF);
+ mtx_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK);
mtx_lock(&Giant);
/*
diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c
index 5e96a40..2beb62d 100644
--- a/sys/sparc64/sparc64/machdep.c
+++ b/sys/sparc64/sparc64/machdep.c
@@ -328,7 +328,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_long o2, u_long o3, ofw_vec_t *vec)
*/
mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE);
mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE);
- mtx_init(&proc0.p_mtx, "process lock", MTX_DEF);
+ mtx_init(&proc0.p_mtx, "process lock", MTX_DEF|MTX_DUPOK);
intr_init2();
mtx_lock(&Giant);
diff --git a/sys/sys/lock.h b/sys/sys/lock.h
index 425a6e9..a55bf54 100644
--- a/sys/sys/lock.h
+++ b/sys/sys/lock.h
@@ -69,6 +69,7 @@ struct lock_class {
#define LO_RECURSABLE 0x00080000 /* Lock may recurse. */
#define LO_SLEEPABLE 0x00100000 /* Lock may be held while sleeping. */
#define LO_UPGRADABLE 0x00200000 /* Lock may be upgraded/downgraded. */
+#define LO_DUPOK 0x00400000 /* Don't check for duplicate acquires */
#define LI_RECURSEMASK 0x0000ffff /* Recursion depth of lock instance. */
#define LI_SLEPT 0x00010000 /* Lock instance has been slept with. */
diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h
index 8fb1fa9..e0bce13 100644
--- a/sys/sys/mutex.h
+++ b/sys/sys/mutex.h
@@ -57,6 +57,7 @@
#define MTX_RECURSE 0x00000004 /* Option: lock allowed to recurse */
#define MTX_NOWITNESS 0x00000008 /* Don't do any witness checking. */
#define MTX_SLEEPABLE 0x00000010 /* We can sleep with this lock. */
+#define MTX_DUPOK 0x00000020 /* Don't log a duplicate acquire */
/*
* Option flags passed to certain lock/unlock routines, through the use
diff --git a/sys/vm/uma_int.h b/sys/vm/uma_int.h
index 77e7c38..ffb8603 100644
--- a/sys/vm/uma_int.h
+++ b/sys/vm/uma_int.h
@@ -287,7 +287,7 @@ void uma_large_free(uma_slab_t slab);
#define ZONE_UNLOCK(z) mtx_unlock(&(z)->uz_lock)
#define CPU_LOCK_INIT(z, cpu) \
- mtx_init(&(z)->uz_cpu[(cpu)].uc_lock, (z)->uz_lname, MTX_DEF)
+ mtx_init(&(z)->uz_cpu[(cpu)].uc_lock, (z)->uz_lname, MTX_DUPOK|MTX_DEF)
#define CPU_LOCK_FINI(z, cpu) \
mtx_destroy(&(z)->uz_cpu[(cpu)].uc_lock)
OpenPOWER on IntegriCloud