public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: Fix cond_resched_lock() in !CONFIG_PREEMPT
@ 2009-07-24 18:05 Frederic Weisbecker
  2009-08-02 13:11 ` [tip:sched/core] " tip-bot for Frederic Weisbecker
  0 siblings, 1 reply; 2+ messages in thread
From: Frederic Weisbecker @ 2009-07-24 18:05 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Li Zefan, Peter Zijlstra

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>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 include/linux/sched.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index cb070dc..2c35bc2 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2294,8 +2294,14 @@ extern int _cond_resched(void);
 
 extern int __cond_resched_lock(spinlock_t *lock);
 
+#ifdef CONFIG_PREEMPT
+#define PREEMPT_LOCK_OFFSET	PREEMPT_OFFSET
+#else
+#define PREEMPT_LOCK_OFFSET	0
+#endif
+
 #define cond_resched_lock(lock) ({				\
-	__might_sleep(__FILE__, __LINE__, PREEMPT_OFFSET);	\
+	__might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET);	\
 	__cond_resched_lock(lock);				\
 })
 
-- 
1.6.2.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip:sched/core] sched: Fix cond_resched_lock() in !CONFIG_PREEMPT
  2009-07-24 18:05 [PATCH] sched: Fix cond_resched_lock() in !CONFIG_PREEMPT Frederic Weisbecker
@ 2009-08-02 13:11 ` tip-bot for Frederic Weisbecker
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Frederic Weisbecker @ 2009-08-02 13:11 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, fweisbec, a.p.zijlstra, lizf, tglx,
	mingo

Commit-ID:  716a42348cdaf04534b15fbdc9c83e25baebfed5
Gitweb:     http://git.kernel.org/tip/716a42348cdaf04534b15fbdc9c83e25baebfed5
Author:     Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Fri, 24 Jul 2009 20:05:23 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Sun, 2 Aug 2009 14:03:57 +0200

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>


---
 include/linux/sched.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index cbbfca6..c472414 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2293,8 +2293,14 @@ extern int _cond_resched(void);
 
 extern int __cond_resched_lock(spinlock_t *lock);
 
+#ifdef CONFIG_PREEMPT
+#define PREEMPT_LOCK_OFFSET	PREEMPT_OFFSET
+#else
+#define PREEMPT_LOCK_OFFSET	0
+#endif
+
 #define cond_resched_lock(lock) ({				\
-	__might_sleep(__FILE__, __LINE__, PREEMPT_OFFSET);	\
+	__might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET);	\
 	__cond_resched_lock(lock);				\
 })
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-02 13:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-24 18:05 [PATCH] sched: Fix cond_resched_lock() in !CONFIG_PREEMPT Frederic Weisbecker
2009-08-02 13:11 ` [tip:sched/core] " tip-bot for Frederic Weisbecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox