Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Aug 2011 09:14:56 +0000 (UTC)
From:      Attilio Rao <attilio@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r225288 - stable/8/sys/kern
Message-ID:  <201108310914.p7V9Eulo091537@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108310914.p7V9Eulo091537>