From owner-svn-src-stable-8@FreeBSD.ORG Wed Aug 31 09:14:56 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 90EF9106567C; Wed, 31 Aug 2011 09:14:56 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 804838FC20; Wed, 31 Aug 2011 09:14:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7V9EumZ091539; Wed, 31 Aug 2011 09:14:56 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7V9Eulo091537; Wed, 31 Aug 2011 09:14:56 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201108310914.p7V9Eulo091537@svn.freebsd.org> From: Attilio Rao Date: Wed, 31 Aug 2011 09:14:56 +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: r225288 - stable/8/sys/kern X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 09:14:56 -0000 Author: attilio Date: Wed Aug 31 09:14:56 2011 New Revision: 225288 URL: http://svn.freebsd.org/changeset/base/225288 Log: MFC r225057: Fix a race that can happen when switching spinlocks in callout_cpu_switch() and curthread is preempted. Modified: stable/8/sys/kern/kern_timeout.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) Modified: stable/8/sys/kern/kern_timeout.c ============================================================================== --- stable/8/sys/kern/kern_timeout.c Wed Aug 31 08:44:45 2011 (r225287) +++ stable/8/sys/kern/kern_timeout.c Wed Aug 31 09:14:56 2011 (r225288) @@ -267,10 +267,17 @@ callout_cpu_switch(struct callout *c, st MPASS(c != NULL && cc != NULL); CC_LOCK_ASSERT(cc); + /* + * Avoid interrupts and preemption firing after the callout cpu + * is blocked in order to avoid deadlocks as the new thread + * may be willing to acquire the callout cpu lock. + */ c->c_cpu = CPUBLOCK; + spinlock_enter(); CC_UNLOCK(cc); new_cc = CC_CPU(new_cpu); CC_LOCK(new_cc); + spinlock_exit(); c->c_cpu = new_cpu; return (new_cc); }