From: Linus Torvalds
Date: Mon May 10 2004 - 09:58:06 EST

On Mon, 10 May 2004, Oleg Nesterov wrote:
> so there is no need to recheck the bit in do/while loop, because
> there is no false wakeups now.

You should never assume this. You should assume that there are _always_
false wakeups.

Why? Because Linux has always allowed people to leave wait-queues active,
without being "atomic". For example, the tty read/write layer used to
(still does?) add itself on the wait-queue _once_, and then leave itself
on the wait-queue while in a loop it does copies from/to user space.

Which means that you can get wake-ups from totally unrelated _other_
sources while you're doing IO.

Never EVER assume (and depend on) that you only get one wakeup. It may be
the most common case by far, but it's not guaranteed. If you slept waiting
for something, then you should re-check that something when you wake up.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at