Re: [PATCH] BUG(): sched.c: Line 944

Linus Torvalds
2002-09-16T21:35:57Z

On 16 Sep 2002, Robert Love wrote:
>
> I liked this idea, and was working on implementing it when I ran into a
> few roadblocks. Your ideas are welcome.
>
> First, "preempt_count()" is used as an l-value in a lot of places, i.e.
> look at all the "preempt_count() += foo" in the IRQ code. We cannot
> mask things out of it.

Ok. Let's just make the masking explicit in in_atomic() then, like you
suggest:

> Simplest solution is to:
>
> #define in_atomic() \
> (preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())
>
> although I still dislike the masking just to make the schedule()
> code-path cleaner.

I don't think this is a scheduler cleanliness issue: it's a consistency
issue. If "in_interrupt()" and friends do not care about PREEMPT_ACTIVE,
then neither should "in_atomic()". The fact that the scheduler test gets
cleaned up is secondary - although it is obviously a result of being
consistent.

> Oh, and there is another problem: printk() from schedule() implicitly
> calls wake_up(). My machine dies even with just a printk() and not a
> BUG()... I suspect there may be some SMP issue in that whole mess too,
> because setting oops_in_progress prior did not help.

Hmm.. It will call wake_up() because it will try to wake up any klogd.
What's the problem? Calling wake_up() should be fine from there..

Linus