Re: [linux-audio-dev] Re: [announce] [patch] Voluntary Kernel Preemption Patch

Andrew Morton
2004-07-13T22:23:59Z

Andrea Arcangeli <andrea@suse.de> wrote:
>
> > Sleeping with local interrupts disabled is usually a bug, so we should
> > prefer to keep that check in might_sleep().
>
> either it's _always_ a bug including for entry.S or sched_yield, or it's
> _never_ a bug. I don't understand the "usually".

If some code does:

local_irq_disable();
<fiddle with per-cpu stuff>
kmalloc(GFP_KERNEL);
<fiddle with per-cpu stuff>
local_irq_enable();

or

local_irq_disable();
<fiddle with per-cpu stuff>
function_which_calls_cond_resched();
<fiddle with per-cpu stuff>
local_irq_enable();

then we want might_sleep() to warn about the bug.

The fact that a couple of scheduler-internal fastpaths happen to know that
they can call schedule() with interrupts disabled is not relevant to this.