From owner-svn-src-all@FreeBSD.ORG Sat Feb 23 18:32:42 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BD23A545; Sat, 23 Feb 2013 18:32:42 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 98783CB9; Sat, 23 Feb 2013 18:32:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1NIWgUN005640; Sat, 23 Feb 2013 18:32:42 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1NIWgj0005639; Sat, 23 Feb 2013 18:32:42 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201302231832.r1NIWgj0005639@svn.freebsd.org> From: Alexander Motin Date: Sat, 23 Feb 2013 18:32:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r247195 - head/sys/arm/arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Feb 2013 18:32:42 -0000 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 @@ -70,6 +71,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -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