Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Feb 2013 18:32:42 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r247195 - head/sys/arm/arm
Message-ID:  <201302231832.r1NIWgj0005639@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Feb 23 18:32:42 2013
New Revision: 247195
URL: http://svnweb.freebsd.org/changeset/base/247195

Log:
  Add basic and not very reliable protection against going to sleep with
  thread scheduled by interrupt fired after we entered critical section.
  None of cpu_sleep() implementations on ARM check sched_runnable() now, so
  put the first line of defence here.  This mostly fixes unexpectedly long
  sleeps in synthetic tests of calloutng code and probably other situations.

Modified:
  head/sys/arm/arm/machdep.c

Modified: head/sys/arm/arm/machdep.c
==============================================================================
--- head/sys/arm/arm/machdep.c	Sat Feb 23 16:14:07 2013	(r247194)
+++ head/sys/arm/arm/machdep.c	Sat Feb 23 18:32:42 2013	(r247195)
@@ -45,6 +45,7 @@
 #include "opt_compat.h"
 #include "opt_ddb.h"
 #include "opt_platform.h"
+#include "opt_sched.h"
 #include "opt_timer.h"
 
 #include <sys/cdefs.h>
@@ -70,6 +71,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/pcpu.h>
 #include <sys/ptrace.h>
+#include <sys/sched.h>
 #include <sys/signalvar.h>
 #include <sys/syscallsubr.h>
 #include <sys/sysctl.h>
@@ -433,19 +435,24 @@ void
 cpu_idle(int busy)
 {
 	
+	CTR2(KTR_SPARE2, "cpu_idle(%d) at %d",
+	    busy, curcpu);
 #ifndef NO_EVENTTIMERS
 	if (!busy) {
 		critical_enter();
 		cpu_idleclock();
 	}
 #endif
-	cpu_sleep(0);
+	if (!sched_runnable())
+		cpu_sleep(0);
 #ifndef NO_EVENTTIMERS
 	if (!busy) {
 		cpu_activeclock();
 		critical_exit();
 	}
 #endif
+	CTR2(KTR_SPARE2, "cpu_idle(%d) at %d done",
+	    busy, curcpu);
 }
 
 int



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