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
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=75104

View File

@ -1240,7 +1240,9 @@ psignal(p, sig)
psignal(p->p_pptr, SIGCHLD);
PROC_UNLOCK(p->p_pptr);
}
mtx_lock_spin(&sched_lock);
stop(p);
mtx_unlock_spin(&sched_lock);
goto out;
} else
goto runfast;
@ -1396,8 +1398,8 @@ issignal(p)
psignal(p->p_pptr, SIGCHLD);
PROC_UNLOCK(p->p_pptr);
do {
stop(p);
mtx_lock_spin(&sched_lock);
stop(p);
PROC_UNLOCK_NOSWITCH(p);
DROP_GIANT_NOSWITCH();
mi_switch();
@ -1474,8 +1476,8 @@ issignal(p)
psignal(p->p_pptr, SIGCHLD);
PROC_UNLOCK(p->p_pptr);
}
stop(p);
mtx_lock_spin(&sched_lock);
stop(p);
PROC_UNLOCK_NOSWITCH(p);
DROP_GIANT_NOSWITCH();
mi_switch();
@ -1519,19 +1521,19 @@ issignal(p)
/*
* Put the argument process into the stopped state and notify the parent
* 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)
register struct proc *p;
{
PROC_LOCK_ASSERT(p, MA_OWNED);
mtx_lock_spin(&sched_lock);
mtx_assert(&sched_lock, MA_OWNED);
p->p_stat = SSTOP;
p->p_flag &= ~P_WAITED;
wakeup((caddr_t)p->p_pptr);
mtx_unlock_spin(&sched_lock);
}
/*