From owner-svn-src-head@FreeBSD.ORG Sun Nov 25 14:22:09 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6F43A79E; Sun, 25 Nov 2012 14:22:09 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 54F208FC13; Sun, 25 Nov 2012 14:22:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAPEM8lV074657; Sun, 25 Nov 2012 14:22:08 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAPEM8BV074656; Sun, 25 Nov 2012 14:22:08 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201211251422.qAPEM8BV074656@svn.freebsd.org> From: Andriy Gapon Date: Sun, 25 Nov 2012 14:22:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r243515 - head/sys/kern X-SVN-Group: head 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.14 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: Sun, 25 Nov 2012 14:22:09 -0000 Author: avg Date: Sun Nov 25 14:22:08 2012 New Revision: 243515 URL: http://svnweb.freebsd.org/changeset/base/243515 Log: remove stop_scheduler_on_panic knob There has not been any complaints about the default behavior, so there is no need to keep a knob that enables the worse alternative. Now that the hard-stopping of other CPUs is the only behavior, the panic_cpu spinlock-like logic can be dropped, because only a single CPU is supposed to win stop_cpus_hard(other_cpus) race and proceed past that call. MFC after: 1 month Modified: head/sys/kern/kern_shutdown.c Modified: head/sys/kern/kern_shutdown.c ============================================================================== --- head/sys/kern/kern_shutdown.c Sun Nov 25 12:38:12 2012 (r243514) +++ head/sys/kern/kern_shutdown.c Sun Nov 25 14:22:08 2012 (r243515) @@ -121,11 +121,6 @@ SYSCTL_INT(_kern, OID_AUTO, sync_on_pani &sync_on_panic, 0, "Do a sync before rebooting from a panic"); TUNABLE_INT("kern.sync_on_panic", &sync_on_panic); -static int stop_scheduler_on_panic = 1; -SYSCTL_INT(_kern, OID_AUTO, stop_scheduler_on_panic, CTLFLAG_RW | CTLFLAG_TUN, - &stop_scheduler_on_panic, 0, "stop scheduler upon entering panic"); -TUNABLE_INT("kern.stop_scheduler_on_panic", &stop_scheduler_on_panic); - static SYSCTL_NODE(_kern, OID_AUTO, shutdown, CTLFLAG_RW, 0, "Shutdown environment"); @@ -552,7 +547,6 @@ void panic(const char *fmt, ...) { #ifdef SMP - static volatile u_int panic_cpu = NOCPU; cpuset_t other_cpus; #endif struct thread *td = curthread; @@ -560,39 +554,27 @@ panic(const char *fmt, ...) va_list ap; static char buf[256]; - if (stop_scheduler_on_panic) - spinlock_enter(); - else - critical_enter(); + spinlock_enter(); #ifdef SMP /* - * We don't want multiple CPU's to panic at the same time, so we - * use panic_cpu as a simple spinlock. We have to keep checking - * panic_cpu if we are spinning in case the panic on the first - * CPU is canceled. + * stop_cpus_hard(other_cpus) should prevent multiple CPUs from + * concurrently entering panic. Only the winner will proceed + * further. */ - if (panic_cpu != PCPU_GET(cpuid)) - while (atomic_cmpset_int(&panic_cpu, NOCPU, - PCPU_GET(cpuid)) == 0) - while (panic_cpu != NOCPU) - ; /* nothing */ - - if (stop_scheduler_on_panic) { - if (panicstr == NULL && !kdb_active) { - other_cpus = all_cpus; - CPU_CLR(PCPU_GET(cpuid), &other_cpus); - stop_cpus_hard(other_cpus); - } - - /* - * We set stop_scheduler here and not in the block above, - * because we want to ensure that if panic has been called and - * stop_scheduler_on_panic is true, then stop_scheduler will - * always be set. Even if panic has been entered from kdb. - */ - td->td_stopsched = 1; + if (panicstr == NULL && !kdb_active) { + other_cpus = all_cpus; + CPU_CLR(PCPU_GET(cpuid), &other_cpus); + stop_cpus_hard(other_cpus); } + + /* + * We set stop_scheduler here and not in the block above, + * because we want to ensure that if panic has been called and + * stop_scheduler_on_panic is true, then stop_scheduler will + * always be set. Even if panic has been entered from kdb. + */ + td->td_stopsched = 1; #endif bootopt = RB_AUTOBOOT; @@ -632,8 +614,6 @@ panic(const char *fmt, ...) /* thread_unlock(td); */ if (!sync_on_panic) bootopt |= RB_NOSYNC; - if (!stop_scheduler_on_panic) - critical_exit(); kern_reboot(bootopt); }