From owner-svn-src-head@freebsd.org Fri Nov 17 02:45:39 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EDBD6DF1C64; Fri, 17 Nov 2017 02:45:39 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BB73D7648E; Fri, 17 Nov 2017 02:45:39 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vAH2jc1g055360; Fri, 17 Nov 2017 02:45:38 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vAH2jceC055359; Fri, 17 Nov 2017 02:45:38 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201711170245.vAH2jceC055359@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Fri, 17 Nov 2017 02:45:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r325924 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 325924 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Nov 2017 02:45:40 -0000 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);