svn commit: r327481 - stable/11/sys/kern
Mateusz Guzik
mjg at FreeBSD.org
Tue Jan 2 00:14:47 UTC 2018
Author: mjg
Date: Tue Jan 2 00:14:46 2018
New Revision: 327481
URL: https://svnweb.freebsd.org/changeset/base/327481
Log:
MFC r325924:
sched: move panic handling code out of choosethread
This avoids jumps in the common case of the kernel not being panicked.
Modified:
stable/11/sys/kern/kern_switch.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/kern/kern_switch.c
==============================================================================
--- stable/11/sys/kern/kern_switch.c Tue Jan 2 00:11:56 2018 (r327480)
+++ stable/11/sys/kern/kern_switch.c Tue Jan 2 00:14:46 2018 (r327481)
@@ -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);
More information about the svn-src-all
mailing list