Re: [Patch] jbd commit code deadloop when installing Linux

From: Andrew Morton
Date: Wed Jun 28 2006 - 02:38:47 EST


On 28 Jun 2006 12:48:43 +0800
Zou Nan hai <nanhai.zou@xxxxxxxxx> 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.
>
> 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..


--- a/kernel/sched.c~cond_resched-fix
+++ a/kernel/sched.c
@@ -4454,7 +4454,7 @@ asmlinkage long sys_sched_yield(void)
return 0;
}

-static inline void __cond_resched(void)
+static inline int __cond_resched(void)
{
#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
__might_sleep(__FILE__, __LINE__);
@@ -4465,22 +4465,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;
}
EXPORT_SYMBOL(cond_resched);
_

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/