Re: [patch] sleep_on() done with cli(), NetROM, 2.2.2

Linus Torvalds (torvalds@transmeta.com)
Tue, 2 Mar 1999 11:02:49 -0800 (PST)


On Tue, 2 Mar 1999, Ingo Molnar wrote:
>
> yep. i just tried to pinpoint the broken places. The kernel/printk.c thing
> has resulted in a lockup in a busy server which was reported to this list.
> The race i introduced creates stuck processes, with their WCHAN pointing
> to the buggy code. I'll try to find something better for the places i care
> about. I think it's not possible to have stable SMP and sleep_on() with
> cli(), so every place has to be touched :(

Doing them as wait queues is the obvious answer: turning

cli();
if (cond)
sleep_on(&cond_list);

into

current->state = TASK_UNINTERRUPTIBLE;
add_wait_queue(&wait, &cond_list);
if (cond)
schedule();
remove_wait_queue(..)

always works, but can often be fairly nasty.

Especially considering that for performance reasons you usually want to
turn it into

if (cond) {
current->state = TASK_UNINTERRUPTIBLE;
add_wait_queue(&wait, &cond_list);
if (cond)
schedule();
remove_wait_queue(..)
}

so that you only do the wait queue stuff if you think you need to.

Linus

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