Author: mjg Date: Fri Nov 17 02:45:38 2017 New Revision: 325924 URL: https://svnweb.freebsd.org/changeset/base/325924
Log: sched: move panic handling code out of choosethread This avoids jumps in the common case of the kernel not being panicked. Modified: head/sys/kern/kern_switch.c Modified: head/sys/kern/kern_switch.c ============================================================================== --- head/sys/kern/kern_switch.c Fri Nov 17 02:29:06 2017 (r325923) +++ head/sys/kern/kern_switch.c Fri Nov 17 02:45:38 2017 (r325924) @@ -150,24 +150,37 @@ SYSCTL_PROC(_kern_sched_stats, OID_AUTO, reset, CTLTYP /* * Select the thread that will be run next. */ -struct thread * -choosethread(void) + +static __noinline struct thread * +choosethread_panic(struct thread *td) { - struct thread *td; -retry: - td = sched_choose(); - /* * 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; } + + TD_SET_RUNNING(td); + 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); _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"