From owner-svn-src-stable@FreeBSD.ORG Fri May 14 01:43:13 2010 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7FC97106566C; Fri, 14 May 2010 01:43:13 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6465D8FC0C; Fri, 14 May 2010 01:43:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o4E1hDbB010130; Fri, 14 May 2010 01:43:13 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o4E1hDc5010127; Fri, 14 May 2010 01:43:13 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201005140143.o4E1hDc5010127@svn.freebsd.org> From: Attilio Rao Date: Fri, 14 May 2010 01:43:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208055 - stable/8/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2010 01:43:13 -0000 Author: attilio Date: Fri May 14 01:43:13 2010 New Revision: 208055 URL: http://svn.freebsd.org/changeset/base/208055 Log: MFC r206878, r206897, r207921: Fix a deadlock in the shutdown code when some CPUs are performing smp_rendezvous() (or smp_tlb_shootdown()) and are waiting for acknowledgment. Modified: stable/8/sys/kern/kern_shutdown.c stable/8/sys/kern/subr_smp.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/geom/sched/ (props changed) Modified: stable/8/sys/kern/kern_shutdown.c ============================================================================== --- stable/8/sys/kern/kern_shutdown.c Fri May 14 01:25:30 2010 (r208054) +++ stable/8/sys/kern/kern_shutdown.c Fri May 14 01:43:13 2010 (r208055) @@ -62,7 +62,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* smp_active */ +#include #include #include @@ -485,15 +485,26 @@ static void shutdown_reset(void *junk, int howto) { + printf("Rebooting...\n"); + DELAY(1000000); /* wait 1 sec for printf's to complete and be read */ + /* - * Disable interrupts on CPU0 in order to avoid fast handlers - * to preempt the stopping process and to deadlock against other - * CPUs. + * Acquiring smp_ipi_mtx here has a double effect: + * - it disables interrupts avoiding CPU0 preemption + * by fast handlers (thus deadlocking against other CPUs) + * - it avoids deadlocks against smp_rendezvous() or, more + * generally, threads busy-waiting, with this spinlock held, + * and waiting for responses by threads on other CPUs + * (ie. smp_tlb_shootdown()). + * + * For the !SMP case it just needs to handle the former problem. */ +#ifdef SMP + mtx_lock_spin(&smp_ipi_mtx); +#else spinlock_enter(); +#endif - printf("Rebooting...\n"); - DELAY(1000000); /* wait 1 sec for printf's to complete and be read */ /* cpu_boot(howto); */ /* doesn't do anything at the moment */ cpu_reset(); /* NOTREACHED */ /* assuming reset worked */ Modified: stable/8/sys/kern/subr_smp.c ============================================================================== --- stable/8/sys/kern/subr_smp.c Fri May 14 01:25:30 2010 (r208054) +++ stable/8/sys/kern/subr_smp.c Fri May 14 01:43:13 2010 (r208055) @@ -137,6 +137,8 @@ static void mp_start(void *dummy) { + mtx_init(&smp_ipi_mtx, "smp rendezvous", NULL, MTX_SPIN); + /* Probe for MP hardware. */ if (smp_disabled != 0 || cpu_mp_probe() == 0) { mp_ncpus = 1; @@ -144,7 +146,6 @@ mp_start(void *dummy) return; } - mtx_init(&smp_ipi_mtx, "smp rendezvous", NULL, MTX_SPIN); cpu_mp_start(); printf("FreeBSD/SMP: Multiprocessor System Detected: %d CPUs\n", mp_ncpus);