diff options
author | jhb <jhb@FreeBSD.org> | 2002-04-16 17:03:05 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2002-04-16 17:03:05 +0000 |
commit | 7202da4491f33663719dc05a4db31422f6937123 (patch) | |
tree | c2f74333eb4c882addd55dbf51cfb2fa118bf688 /sys/kern | |
parent | 79d2daeb7f294eac6a6bdb15b21d5fc4213e23e2 (diff) | |
download | FreeBSD-src-7202da4491f33663719dc05a4db31422f6937123.zip FreeBSD-src-7202da4491f33663719dc05a4db31422f6937123.tar.gz |
- Merge the pgrpsess_lock and proctree_lock sx locks into one proctree_lock
sx lock. Trying to get the lock order between these locks was getting
too complicated as the locking in wait1() was being fixed.
- leavepgrp() now requires an exclusive lock of proctree_lock to be held
when it is called.
- fixjobc() no longer gets a shared lock of proctree_lock now that it
requires an xlock be held by the caller.
- Locking notes in sys/proc.h are adjusted to note that everything that
used to be protected by the pgrpsess_lock is now protected by the
proctree_lock.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_proc.c | 24 | ||||
-rw-r--r-- | sys/kern/subr_witness.c | 1 |
2 files changed, 10 insertions, 15 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index afd6ee2..2d512b9 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -80,7 +80,6 @@ struct proclist allproc; struct proclist zombproc; struct sx allproc_lock; struct sx proctree_lock; -struct sx pgrpsess_lock; struct mtx pargs_ref_lock; uma_zone_t proc_zone; uma_zone_t ithread_zone; @@ -96,7 +95,6 @@ procinit() sx_init(&allproc_lock, "allproc"); sx_init(&proctree_lock, "proctree"); - sx_init(&pgrpsess_lock, "pgrpsess"); mtx_init(&pargs_ref_lock, "struct pargs.ref", NULL, MTX_DEF); LIST_INIT(&allproc); LIST_INIT(&zombproc); @@ -284,7 +282,7 @@ dopfind(pid) /* * Locate a process group by number. - * The caller must hold pgrpsess_lock. + * The caller must hold proctree_lock. */ struct pgrp * pgfind(pgid) @@ -292,7 +290,7 @@ pgfind(pgid) { register struct pgrp *pgrp; - PGRPSESS_LOCK_ASSERT(SX_LOCKED); + sx_assert(&proctree_lock, SX_LOCKED); LIST_FOREACH(pgrp, PGRPHASH(pgid), pg_hash) { if (pgrp->pg_id == pgid) { @@ -317,7 +315,7 @@ enterpgrp(p, pgid, pgrp, sess) { struct pgrp *pgrp2; - PGRPSESS_LOCK_ASSERT(SX_XLOCKED); + sx_assert(&proctree_lock, SX_XLOCKED); KASSERT(pgrp != NULL, ("enterpgrp: pgrp == NULL")); KASSERT(p->p_pid == pgid, @@ -362,7 +360,7 @@ enterpgrp(p, pgid, pgrp, sess) LIST_INIT(&pgrp->pg_members); /* - * As we have an exclusive lock of pgrpsess_lock, + * As we have an exclusive lock of proctree_lock, * this should not deadlock. */ LIST_INSERT_HEAD(PGRPHASH(pgid), pgrp, pg_hash); @@ -383,7 +381,8 @@ enterthispgrp(p, pgrp) register struct proc *p; struct pgrp *pgrp; { - PGRPSESS_LOCK_ASSERT(SX_XLOCKED); + + sx_assert(&proctree_lock, SX_XLOCKED); PROC_LOCK_ASSERT(p, MA_NOTOWNED); PGRP_LOCK_ASSERT(pgrp, MA_NOTOWNED); PGRP_LOCK_ASSERT(p->p_pgrp, MA_NOTOWNED); @@ -411,7 +410,7 @@ doenterpgrp(p, pgrp) { struct pgrp *savepgrp; - PGRPSESS_LOCK_ASSERT(SX_XLOCKED); + sx_assert(&proctree_lock, SX_XLOCKED); PROC_LOCK_ASSERT(p, MA_NOTOWNED); PGRP_LOCK_ASSERT(pgrp, MA_NOTOWNED); PGRP_LOCK_ASSERT(p->p_pgrp, MA_NOTOWNED); @@ -449,7 +448,7 @@ leavepgrp(p) { struct pgrp *savepgrp; - PGRPSESS_XLOCK(); + sx_assert(&proctree_lock, SX_XLOCKED); savepgrp = p->p_pgrp; PGRP_LOCK(savepgrp); PROC_LOCK(p); @@ -459,7 +458,6 @@ leavepgrp(p) PGRP_UNLOCK(savepgrp); if (LIST_EMPTY(&savepgrp->pg_members)) pgdelete(savepgrp); - PGRPSESS_XUNLOCK(); return (0); } @@ -472,7 +470,7 @@ pgdelete(pgrp) { struct session *savesess; - PGRPSESS_LOCK_ASSERT(SX_XLOCKED); + sx_assert(&proctree_lock, SX_XLOCKED); PGRP_LOCK_ASSERT(pgrp, MA_NOTOWNED); SESS_LOCK_ASSERT(pgrp->pg_session, MA_NOTOWNED); @@ -520,7 +518,7 @@ fixjobc(p, pgrp, entering) register struct pgrp *hispgrp; register struct session *mysession; - PGRPSESS_LOCK_ASSERT(SX_LOCKED); + sx_assert(&proctree_lock, SX_LOCKED); PROC_LOCK_ASSERT(p, MA_NOTOWNED); PGRP_LOCK_ASSERT(pgrp, MA_NOTOWNED); SESS_LOCK_ASSERT(pgrp->pg_session, MA_NOTOWNED); @@ -530,7 +528,6 @@ fixjobc(p, pgrp, entering) * group; if so, adjust count for p's process group. */ mysession = pgrp->pg_session; - sx_slock(&proctree_lock); if ((hispgrp = p->p_pptr->p_pgrp) != pgrp && hispgrp->pg_session == mysession) { PGRP_LOCK(pgrp); @@ -564,7 +561,6 @@ fixjobc(p, pgrp, entering) PGRP_UNLOCK(hispgrp); } } - sx_sunlock(&proctree_lock); } /* diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 75d8d55..e503515 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -187,7 +187,6 @@ static struct lock_list_entry w_locklistdata[LOCK_CHILDCOUNT]; static struct witness_order_list_entry order_lists[] = { { "Giant", &lock_class_mtx_sleep }, - { "pgrpsess", &lock_class_sx }, { "proctree", &lock_class_sx }, { "allproc", &lock_class_sx }, { "process group", &lock_class_mtx_sleep }, |