- At the top of sleepq_catch_signals() lock the thread and check TDF_NEEDSIGCHK
before doing the very expensive cursig() and related locking. NEEDSIGCHK is updated whenever our signal mask change or when a signal is delivered and should be sufficient to avoid the more expensive tests. This eliminates another source of PROC_LOCK contention in multithreaded programs.
This commit is contained in:
parent
bd4e153568
commit
241fbd3d13
@ -385,12 +385,20 @@ sleepq_catch_signals(void *wchan, int pri)
|
||||
sc = SC_LOOKUP(wchan);
|
||||
mtx_assert(&sc->sc_lock, MA_OWNED);
|
||||
MPASS(wchan != NULL);
|
||||
/*
|
||||
* See if there are any pending signals for this thread. If not
|
||||
* we can switch immediately. Otherwise do the signal processing
|
||||
* directly.
|
||||
*/
|
||||
thread_lock(td);
|
||||
if ((td->td_flags & TDF_NEEDSIGCHK) == 0) {
|
||||
sleepq_switch(wchan, pri);
|
||||
return (0);
|
||||
}
|
||||
thread_unlock(td);
|
||||
mtx_unlock_spin(&sc->sc_lock);
|
||||
CTR3(KTR_PROC, "sleepq catching signals: thread %p (pid %ld, %s)",
|
||||
(void *)td, (long)p->p_pid, td->td_name);
|
||||
|
||||
mtx_unlock_spin(&sc->sc_lock);
|
||||
|
||||
/* See if there are any pending signals for this thread. */
|
||||
PROC_LOCK(p);
|
||||
ps = p->p_sigacts;
|
||||
mtx_lock(&ps->ps_mtx);
|
||||
|
Loading…
Reference in New Issue
Block a user