From owner-svn-src-head@FreeBSD.ORG Sun Aug 21 10:52:50 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D17451065670; Sun, 21 Aug 2011 10:52:50 +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 C20AB8FC08; Sun, 21 Aug 2011 10:52:50 +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 p7LAqo3a000913; Sun, 21 Aug 2011 10:52:50 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7LAqoJJ000911; Sun, 21 Aug 2011 10:52:50 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201108211052.p7LAqoJJ000911@svn.freebsd.org> From: Attilio Rao Date: Sun, 21 Aug 2011 10:52:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225057 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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, 21 Aug 2011 10:52:50 -0000 Author: attilio Date: Sun Aug 21 10:52:50 2011 New Revision: 225057 URL: http://svn.freebsd.org/changeset/base/225057 Log: callout_cpu_switch() allows preemption when dropping the outcoming callout cpu lock (and after having dropped it). If the newly scheduled thread wants to acquire the old queue it will just spin forever. Fix this by disabling preemption and interrupts entirely (because fast interrupt handlers may incur in the same problem too) while switching locks. Reported by: hrs, Mike Tancsa , Chip Camden Tested by: hrs, Mike Tancsa , Chip Camden , Nicholas Esborn Approved by: re (kib) MFC after: 10 days Modified: head/sys/kern/kern_timeout.c Modified: head/sys/kern/kern_timeout.c ============================================================================== --- head/sys/kern/kern_timeout.c Sun Aug 21 10:05:39 2011 (r225056) +++ head/sys/kern/kern_timeout.c Sun Aug 21 10:52:50 2011 (r225057) @@ -269,10 +269,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); }