Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Jan 2018 00:14:46 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r327481 - stable/11/sys/kern
Message-ID:  <201801020014.w020EkU3029916@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801020014.w020EkU3029916>