summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern')
-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
6 files changed, 10 insertions, 24 deletions
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;
OpenPOWER on IntegriCloud