Re: [2.6.29-git12] BUG: scheduling while atomic: swapper/0/0x10000100

Thomas Gleixner
2009-04-10T11:43:07Z

On Fri, 10 Apr 2009, Maciej Rutecki wrote:

> 2009/4/10 Andrew Morton <akpm@linux-foundation.org>
>
> > Did this get fixed?
>
> On 2.6.30-rc1-git3 still the same:
> [ 162.541793] BUG: scheduling while atomic: swapper/0/0x10000100

Yikes.

0x10000100
^----- softirq count leaked.

We have a check for that in do_softirq, but none in do_IRQ. Can you
please apply the patch below and test whether it triggers ?

Thanks,

tglx
---
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index c3fe010..d164396 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -206,6 +206,7 @@ unsigned int __irq_entry do_IRQ(struct pt_regs *regs)
/* high bit used in ret_from_ code */
unsigned vector = ~regs->orig_ax;
unsigned irq;
+ int prev_count = preempt_count();

exit_idle();
irq_enter();
@@ -225,6 +226,13 @@ unsigned int __irq_entry do_IRQ(struct pt_regs *regs)

irq_exit();

+ if (unlikely(prev_count != preempt_count())) {
+ printk(KERN_ERR "huh, entered interrupt %d"
+ "with preempt_count %08x, exited with %08x?\n", irq,
+ prev_count, preempt_count());
+ preempt_count() = prev_count;
+ }
+
set_irq_regs(old_regs);
return 1;
}