Change stop() to require the sched_lock as well as p's process lock to

avoid silly lock contention on sched_lock since in 2 out of the 3 places
that we call stop(), we get sched_lock right after calling it and we were
locking sched_lock inside of stop() anyways.
This commit is contained in:
John Baldwin 2001-04-03 01:39:23 +00:00
parent fb45b6d4e3
commit 5b3047d59f

View File

@ -1240,7 +1240,9 @@ psignal(p, sig)
psignal(p->p_pptr, SIGCHLD); psignal(p->p_pptr, SIGCHLD);
PROC_UNLOCK(p->p_pptr); PROC_UNLOCK(p->p_pptr);
} }
mtx_lock_spin(&sched_lock);
stop(p); stop(p);
mtx_unlock_spin(&sched_lock);
goto out; goto out;
} else } else
goto runfast; goto runfast;
@ -1396,8 +1398,8 @@ issignal(p)
psignal(p->p_pptr, SIGCHLD); psignal(p->p_pptr, SIGCHLD);
PROC_UNLOCK(p->p_pptr); PROC_UNLOCK(p->p_pptr);
do { do {
stop(p);
mtx_lock_spin(&sched_lock); mtx_lock_spin(&sched_lock);
stop(p);
PROC_UNLOCK_NOSWITCH(p); PROC_UNLOCK_NOSWITCH(p);
DROP_GIANT_NOSWITCH(); DROP_GIANT_NOSWITCH();
mi_switch(); mi_switch();
@ -1474,8 +1476,8 @@ issignal(p)
psignal(p->p_pptr, SIGCHLD); psignal(p->p_pptr, SIGCHLD);
PROC_UNLOCK(p->p_pptr); PROC_UNLOCK(p->p_pptr);
} }
stop(p);
mtx_lock_spin(&sched_lock); mtx_lock_spin(&sched_lock);
stop(p);
PROC_UNLOCK_NOSWITCH(p); PROC_UNLOCK_NOSWITCH(p);
DROP_GIANT_NOSWITCH(); DROP_GIANT_NOSWITCH();
mi_switch(); mi_switch();
@ -1519,19 +1521,19 @@ issignal(p)
/* /*
* Put the argument process into the stopped state and notify the parent * Put the argument process into the stopped state and notify the parent
* via wakeup. Signals are handled elsewhere. The process must not be * via wakeup. Signals are handled elsewhere. The process must not be
* on the run queue. Must be called with the proc p locked. * on the run queue. Must be called with the proc p locked and the scheduler
* lock held.
*/ */
void static void
stop(p) stop(p)
register struct proc *p; register struct proc *p;
{ {
PROC_LOCK_ASSERT(p, MA_OWNED); PROC_LOCK_ASSERT(p, MA_OWNED);
mtx_lock_spin(&sched_lock); mtx_assert(&sched_lock, MA_OWNED);
p->p_stat = SSTOP; p->p_stat = SSTOP;
p->p_flag &= ~P_WAITED; p->p_flag &= ~P_WAITED;
wakeup((caddr_t)p->p_pptr); wakeup((caddr_t)p->p_pptr);
mtx_unlock_spin(&sched_lock);
} }
/* /*