diff options
author | mav <mav@FreeBSD.org> | 2013-02-23 18:32:42 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2013-02-23 18:32:42 +0000 |
commit | 4af4a9dc68009f44f40bd5a7aa800549b06bb07d (patch) | |
tree | 86fc1d662fa486700c0eee3295e7c8f95bba5ad9 /sys/arm | |
parent | 9b619254ca339d50462a2ab033e4cb5c94b8c676 (diff) | |
download | FreeBSD-src-4af4a9dc68009f44f40bd5a7aa800549b06bb07d.zip FreeBSD-src-4af4a9dc68009f44f40bd5a7aa800549b06bb07d.tar.gz |
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.
Diffstat (limited to 'sys/arm')
-rw-r--r-- | sys/arm/arm/machdep.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c index ec65c04..5262e71 100644 --- a/sys/arm/arm/machdep.c +++ b/sys/arm/arm/machdep.c @@ -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 |