From: Zou Nan hai <nanhai.zou@intel.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [Patch] jbd commit code deadloop when installing Linux
Date: 28 Jun 2006 13:46:22 +0800 [thread overview]
Message-ID: <1151473582.6052.28.camel@linux-znh> (raw)
In-Reply-To: <20060627235500.8c2c290e.akpm@osdl.org>
On Wed, 2006-06-28 at 14:55, Andrew Morton wrote:
> On Wed, 28 Jun 2006 08:38:59 +0200
> Ingo Molnar <mingo@elte.hu> wrote:
>
> >
> > * Andrew Morton <akpm@osdl.org> wrote:
> >
> > > > We see system hang in ext3 jbd code
> > > > when Linux install program anaconda copying
> > > > packages.
> > > >
> > > > That is because anaconda is invoked from linuxrc
> > > > in initrd when system_state is still SYSTEM_BOOTING.
> >
> > [ argh ...! ]
>
> That's what I thought ;)
>
> > > > Thus the cond_resched checks in journal_commit_transaction
> > > > will always return 1 without actually schedule,
> > > > then the system fall into deadloop.
> > >
> > > That's a bug in cond_resched().
> > >
> > > Something like this..
> >
> > Acked-by: Ingo Molnar <mingo@elte.hu>
> >
>
> Thanks. Zou, it'd be great if you could test this in your setup, please.
> I've tagged it as 2.6.17.x material.
Andrew,
I am building the env to test.
The patch was my original idea, but I was afraid of breaking any code
that rely on the OLD wrong cond_sched semantic. However later I did a
grep found that there is very few code that checks the return value of
cond_resched. So the patch should be safe.
However I think cond_resched_lock and cond_resched_softirq also need fix
to make the semantic consistent.
Please check the following patch.
Zou Nan hai
Signed-off-by: Zou Nan hai <nanhai.zou@intel.com>
--- linux-2.6.17/kernel/sched.c 2006-06-18 09:49:35.000000000 +0800
+++ linux-2.6.17-fix/kernel/sched.c 2006-06-28 13:34:39.000000000 +0800
@@ -4044,7 +4044,7 @@ asmlinkage long sys_sched_yield(void)
return 0;
}
-static inline void __cond_resched(void)
+static inline int __cond_resched(void)
{
/*
* The BKS might be reacquired before we have dropped
@@ -4052,22 +4052,21 @@ static inline void __cond_resched(void)
* cond_resched() call.
*/
if (unlikely(preempt_count()))
- return;
+ return 0;
if (unlikely(system_state != SYSTEM_RUNNING))
- return;
+ return 0;
do {
add_preempt_count(PREEMPT_ACTIVE);
schedule();
sub_preempt_count(PREEMPT_ACTIVE);
} while (need_resched());
+ return 1;
}
int __sched cond_resched(void)
{
- if (need_resched()) {
- __cond_resched();
- return 1;
- }
+ if (need_resched())
+ return __cond_resched();
return 0;
}
@@ -4094,8 +4093,7 @@ int cond_resched_lock(spinlock_t *lock)
if (need_resched()) {
_raw_spin_unlock(lock);
preempt_enable_no_resched();
- __cond_resched();
- ret = 1;
+ ret |= __cond_resched();
spin_lock(lock);
}
return ret;
@@ -4106,14 +4104,13 @@ EXPORT_SYMBOL(cond_resched_lock);
int __sched cond_resched_softirq(void)
{
BUG_ON(!in_softirq());
-
+ int ret = 0;
if (need_resched()) {
__local_bh_enable();
- __cond_resched();
+ ret = __cond_resched();
local_bh_disable();
- return 1;
}
- return 0;
+ return ret;
}
EXPORT_SYMBOL(cond_resched_softirq);
next prev parent reply other threads:[~2006-06-28 7:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-28 4:48 [Patch] jbd commit code deadloop when installing Linux Zou Nan hai
2006-06-28 6:40 ` Andrew Morton
2006-06-28 6:38 ` Ingo Molnar
2006-06-28 6:55 ` Andrew Morton
2006-06-28 5:46 ` Zou Nan hai [this message]
2006-06-28 7:39 ` Ingo Molnar
2006-06-28 7:40 ` Andrew Morton
2006-06-28 6:02 ` Zou Nan hai
2006-06-28 8:04 ` Andrew Morton
2006-06-28 6:50 ` Zou Nan hai
2006-06-28 8:45 ` Andrew Morton
2006-06-28 7:14 ` Zou Nan hai
2006-06-28 9:29 ` Ingo Molnar
2006-06-28 7:55 ` Ingo Molnar
2006-06-28 9:10 ` Arjan van de Ven
2006-06-28 7:32 ` Zou Nan hai
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=1151473582.6052.28.camel@linux-znh \
--to=nanhai.zou@intel.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