From: Jim Houston <jim.houston@ccur.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org
Subject: [PATCH] Re: cond_resched() fix
Date: Mon, 17 Jul 2006 23:25:43 -0400 [thread overview]
Message-ID: <1153193143.6799.26.camel@x2.site> (raw)
Hi Andrew,
I found an off by one error in your recent cond_resched fix. In
cond_resched_lock() it calls __resched_legal()
before dropping the spin lock. __resched_legal() will
always finds the preempt_count non-zero and will prevent
the call to __cond_resched().
The attached patch adds a parameter to __resched_legal()
with the expected preempt_count value. The patch was made
against a Linus's git tree. It will apply cleanly to
linux-2.6.18-rc2.
Jim Houston - Concurrent Computer Corp.
--
--- linux-2.6/kernel/sched.c.orig 2006-07-17 09:30:05.000000000 -0400
+++ linux-2.6/kernel/sched.c 2006-07-17 23:00:50.000000000 -0400
@@ -4456,9 +4456,9 @@
return 0;
}
-static inline int __resched_legal(void)
+static inline int __resched_legal(int expected_preempt_count)
{
- if (unlikely(preempt_count()))
+ if (unlikely(preempt_count() != expected_preempt_count))
return 0;
if (unlikely(system_state != SYSTEM_RUNNING))
return 0;
@@ -4484,7 +4484,7 @@
int __sched cond_resched(void)
{
- if (need_resched() && __resched_legal()) {
+ if (need_resched() && __resched_legal(0)) {
__cond_resched();
return 1;
}
@@ -4510,7 +4510,7 @@
ret = 1;
spin_lock(lock);
}
- if (need_resched() && __resched_legal()) {
+ if (need_resched() && __resched_legal(1)) {
spin_release(&lock->dep_map, 1, _THIS_IP_);
_raw_spin_unlock(lock);
preempt_enable_no_resched();
@@ -4526,7 +4526,7 @@
{
BUG_ON(!in_softirq());
- if (need_resched() && __resched_legal()) {
+ if (need_resched() && __resched_legal(0)) {
raw_local_irq_disable();
_local_bh_enable();
raw_local_irq_enable();
reply other threads:[~2006-07-18 3:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1153193143.6799.26.camel@x2.site \
--to=jim.houston@ccur.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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®