diff options
author | jeff <jeff@FreeBSD.org> | 2008-03-21 08:23:25 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2008-03-21 08:23:25 +0000 |
commit | ba540b27d633327453067e692e5ccb2095d417c1 (patch) | |
tree | 85009349e539f1265173b5d33889d0fca5031c61 /sys/kern/subr_trap.c | |
parent | 8420f5505a178be36939d61d6e9da31e0f2eb05a (diff) | |
download | FreeBSD-src-ba540b27d633327453067e692e5ccb2095d417c1.zip FreeBSD-src-ba540b27d633327453067e692e5ccb2095d417c1.tar.gz |
- Add a new td flag TDF_NEEDSUSPCHK that is set whenever a thread needs
to enter thread_suspend_check().
- Set TDF_ASTPENDING along with TDF_NEEDSUSPCHK so we can move the
thread_suspend_check() to ast() rather than userret().
- Check TDF_NEEDSUSPCHK in the sleepq_catch_signals() optimization so
that we don't miss a suspend request. If this is set use the
expensive signal path.
- Set NEEDSUSPCHK when creating a new thread in thr in case the
creating thread is due to be suspended as well but has not yet.
Reviewed by: davidxu (Authored original patch)
Diffstat (limited to 'sys/kern/subr_trap.c')
-rw-r--r-- | sys/kern/subr_trap.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 1701fba..a92abd2 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -96,11 +96,9 @@ userret(struct thread *td, struct trapframe *frame) thread_unlock(td); PROC_UNLOCK(p); #endif - #ifdef KTRACE KTRUSERRET(td); #endif - /* * If this thread tickled GEOM, we need to wait for the giggling to * stop before we return to userland @@ -109,21 +107,9 @@ userret(struct thread *td, struct trapframe *frame) g_waitidle(); /* - * We need to check to see if we have to exit or wait due to a - * single threading requirement or some other STOP condition. - * Don't bother doing all the work if the stop bits are not set - * at this time.. If we miss it, we miss it.. no big deal. - */ - if (P_SHOULDSTOP(p)) { - PROC_LOCK(p); - thread_suspend_check(0); /* Can suspend or kill */ - PROC_UNLOCK(p); - } - /* * Charge system time if profiling. */ if (p->p_flag & P_PROFIL) { - addupc_task(td, TRAPF_PC(frame), td->td_pticks * psratio); } /* @@ -172,9 +158,8 @@ ast(struct trapframe *framep) */ thread_lock(td); flags = td->td_flags; - td->td_flags &= ~(TDF_ASTPENDING | TDF_NEEDSIGCHK | - TDF_NEEDRESCHED | TDF_ALRMPEND | TDF_PROFPEND | - TDF_MACPEND); + td->td_flags &= ~(TDF_ASTPENDING | TDF_NEEDSIGCHK | TDF_NEEDSUSPCHK | + TDF_NEEDRESCHED | TDF_ALRMPEND | TDF_PROFPEND | TDF_MACPEND); thread_unlock(td); PCPU_INC(cnt.v_trap); @@ -242,6 +227,15 @@ ast(struct trapframe *framep) mtx_unlock(&p->p_sigacts->ps_mtx); PROC_UNLOCK(p); } + /* + * We need to check to see if we have to exit or wait due to a + * single threading requirement or some other STOP condition. + */ + if (flags & TDF_NEEDSUSPCHK) { + PROC_LOCK(p); + thread_suspend_check(0); + PROC_UNLOCK(p); + } userret(td, framep); mtx_assert(&Giant, MA_NOTOWNED); |