aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-07-24 14:05:23 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-02 08:03:57 -0400
commit716a42348cdaf04534b15fbdc9c83e25baebfed5 (patch)
tree5a49fe4c0ff258ee03478994ffc7fbe8032a340f /include/linux/sched.h
parenta004cd42181409eda70804ded240a791f4564d61 (diff)
sched: Fix cond_resched_lock() in !CONFIG_PREEMPT
The might_sleep() test inside cond_resched_lock() assumes the spinlock is held and then preemption is disabled. This is true with CONFIG_PREEMPT but the preempt_count() doesn't change otherwise. Check by starting from the appropriate preempt offset depending on the config. Reported-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1248458723-12146-1-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index cbbfca69aa4a..c472414953bf 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2293,8 +2293,14 @@ extern int _cond_resched(void);
2293 2293
2294extern int __cond_resched_lock(spinlock_t *lock); 2294extern int __cond_resched_lock(spinlock_t *lock);
2295 2295
2296#ifdef CONFIG_PREEMPT
2297#define PREEMPT_LOCK_OFFSET PREEMPT_OFFSET
2298#else
2299#define PREEMPT_LOCK_OFFSET 0
2300#endif
2301
2296#define cond_resched_lock(lock) ({ \ 2302#define cond_resched_lock(lock) ({ \
2297 __might_sleep(__FILE__, __LINE__, PREEMPT_OFFSET); \ 2303 __might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET); \
2298 __cond_resched_lock(lock); \ 2304 __cond_resched_lock(lock); \
2299}) 2305})
2300 2306