sched: move panic handling code out of choosethread
This avoids jumps in the common case of the kernel not being panicked.
This commit is contained in:
parent
997131646f
commit
32aef9ff05
@ -150,22 +150,21 @@ SYSCTL_PROC(_kern_sched_stats, OID_AUTO, reset, CTLTYPE_INT | CTLFLAG_WR, NULL,
|
||||
/*
|
||||
* Select the thread that will be run next.
|
||||
*/
|
||||
struct thread *
|
||||
choosethread(void)
|
||||
{
|
||||
struct thread *td;
|
||||
|
||||
retry:
|
||||
td = sched_choose();
|
||||
static __noinline struct thread *
|
||||
choosethread_panic(struct thread *td)
|
||||
{
|
||||
|
||||
/*
|
||||
* If we are in panic, only allow system threads,
|
||||
* plus the one we are running in, to be run.
|
||||
*/
|
||||
if (panicstr && ((td->td_proc->p_flag & P_SYSTEM) == 0 &&
|
||||
retry:
|
||||
if (((td->td_proc->p_flag & P_SYSTEM) == 0 &&
|
||||
(td->td_flags & TDF_INPANIC) == 0)) {
|
||||
/* note that it is no longer on the run queue */
|
||||
TD_SET_CAN_RUN(td);
|
||||
td = sched_choose();
|
||||
goto retry;
|
||||
}
|
||||
|
||||
@ -173,6 +172,20 @@ retry:
|
||||
return (td);
|
||||
}
|
||||
|
||||
struct thread *
|
||||
choosethread(void)
|
||||
{
|
||||
struct thread *td;
|
||||
|
||||
td = sched_choose();
|
||||
|
||||
if (__predict_false(panicstr != NULL))
|
||||
return (choosethread_panic(td));
|
||||
|
||||
TD_SET_RUNNING(td);
|
||||
return (td);
|
||||
}
|
||||
|
||||
/*
|
||||
* Kernel thread preemption implementation. Critical sections mark
|
||||
* regions of code in which preemptions are not allowed.
|
||||
|
Loading…
x
Reference in New Issue
Block a user