summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-07-10 14:57:57 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2009-07-10 14:24:05 -0700
commitd86ee4809d0329d4aa0d0f2c76c2295a16862799 (patch)
tree32b3eaf766c1127ef2298c2e48b5441b7cf9b843 /include
parentc99e6efe1ba04561e7d93a81f0be07e37427e835 (diff)
downloadlinux-3.10-d86ee4809d0329d4aa0d0f2c76c2295a16862799.tar.gz
linux-3.10-d86ee4809d0329d4aa0d0f2c76c2295a16862799.tar.bz2
linux-3.10-d86ee4809d0329d4aa0d0f2c76c2295a16862799.zip
sched: optimize cond_resched()
Optimize cond_resched() by removing one conditional. Currently cond_resched() checks system_state == SYSTEM_RUNNING in order to avoid scheduling before the scheduler is running. We can however, as per suggestion of Matt, use PREEMPT_ACTIVE to accomplish that very same. Suggested-by: Matt Mackall <mpm@selenic.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Acked-by: Matt Mackall <mpm@selenic.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/sched.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 2a99f1c15cf..16a982e389f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -501,8 +501,11 @@ struct task_cputime {
/*
* Disable preemption until the scheduler is running.
* Reset by start_kernel()->sched_init()->init_idle().
+ *
+ * We include PREEMPT_ACTIVE to avoid cond_resched() from working
+ * before the scheduler is active -- see should_resched().
*/
-#define INIT_PREEMPT_COUNT (1)
+#define INIT_PREEMPT_COUNT (1 + PREEMPT_ACTIVE)
/**
* struct thread_group_cputimer - thread group interval timer counts