svn commit: r225288 - stable/8/sys/kern

Attilio Rao attilio at FreeBSD.org
Wed Aug 31 09:14:56 UTC 2011


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);
 }


More information about the svn-src-stable-8 mailing list