From: Frederic Weisbecker <fweisbec@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Li Zefan <lizf@cn.fujitsu.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH] sched: Fix cond_resched_lock() in !CONFIG_PREEMPT
Date: Fri, 24 Jul 2009 20:05:23 +0200 [thread overview]
Message-ID: <1248458723-12146-1-git-send-email-fweisbec@gmail.com> (raw)
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
next reply other threads:[~2009-07-24 18:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-24 18:05 Frederic Weisbecker [this message]
2009-08-02 13:11 ` [tip:sched/core] " tip-bot for Frederic Weisbecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1248458723-12146-1-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®