From owner-svn-src-projects@FreeBSD.ORG Sun May 31 13:52:18 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F3FEF106564A; Sun, 31 May 2009 13:52:17 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C858D8FC12; Sun, 31 May 2009 13:52:17 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4VDqH5i044974; Sun, 31 May 2009 13:52:17 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4VDqH8V044973; Sun, 31 May 2009 13:52:17 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200905311352.n4VDqH8V044973@svn.freebsd.org> From: Robert Watson Date: Sun, 31 May 2009 13:52:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r193170 - projects/pnet/sys/kern X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 May 2009 13:52:18 -0000 Author: rwatson Date: Sun May 31 13:52:17 2009 New Revision: 193170 URL: http://svn.freebsd.org/changeset/base/193170 Log: Add a shutdown handler for device polling -- don't issue wakeups to the netisr once file systems are done syncing, otherwise the scheduler may generate IPIs to CPUs that have already been shutdown, leading to a panic. As similar panics (spin lock 0xc0d8e500 (sched lock 1) held by 0xc4d546c0 (tid 100005) too long) have been reported on both 7.x and 8.x in other code, we might want to think about whether there's some missing scheduler shutdown logic to handle this case for unpinned/unbound threads by migrating them to the CPU managing the shutdown and allowing them to preempt. Modified: projects/pnet/sys/kern/kern_poll.c Modified: projects/pnet/sys/kern/kern_poll.c ============================================================================== --- projects/pnet/sys/kern/kern_poll.c Sun May 31 12:36:14 2009 (r193169) +++ projects/pnet/sys/kern/kern_poll.c Sun May 31 13:52:17 2009 (r193170) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include /* needed by net/if.h */ #include @@ -110,6 +111,7 @@ SYSCTL_UINT(_kern_polling, OID_AUTO, bur static int netisr_poll_scheduled; static int netisr_pollmore_scheduled; +static int poll_shutting_down; static int poll_burst_max_sysctl(SYSCTL_HANDLER_ARGS) { @@ -261,10 +263,19 @@ struct pollrec { static struct pollrec pr[POLL_LIST_LEN]; static void +poll_shutdown(void *arg, int howto) +{ + + poll_shutting_down = 1; +} + +static void init_device_poll(void) { mtx_init(&poll_mtx, "polling", NULL, MTX_DEF); + EVENTHANDLER_REGISTER(shutdown_post_sync, poll_shutdown, NULL, + SHUTDOWN_PRI_LAST); } SYSINIT(device_poll, SI_SUB_CLOCKS, SI_ORDER_MIDDLE, init_device_poll, NULL); @@ -288,7 +299,7 @@ hardclock_device_poll(void) static struct timeval prev_t, t; int delta; - if (poll_handlers == 0) + if (poll_handlers == 0 || poll_shutting_down) return; microuptime(&t);