Skip to contentSkip to conversation

Remove bogus WARN_ON in futex_wait

PATCH In review Andi Kleen 5 participants 8 messages May 19, 2004 – May 20, 2004

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 Remove bogus WARN_ON in futex_wait

futex_wait goes to an interruptible sleep, but does a WARN_ON later if it wakes up early. But waking up early is totally legal, since the sleep is interruptible and any signal can wake it up.

Remove the WARN_ON checking for that.

diff -u linux/kernel/Makefile-o linux/kernel/Makefile

kernel/futex.c renamed from kernel/futex.c-o +0 -2
diff -u linux/kernel/futex.c-o linux/kernel/futex.c
@@ -504,8 +504,6 @@
 		return 0;
 	if (time == 0)
 		return -ETIMEDOUT;
-	/* A spurious wakeup should never happen. */
-	WARN_ON(!signal_pending(current));
 	return -EINTR;
 
  out_unqueue:
#1 lore raw
Quoted 4 lines · Andi Kleen

futex_wait goes to an interruptible sleep, but does a WARN_ON later if it wakes up early. But waking up early is totally legal, since the sleep is interruptible and any signal can wake it up.

That's not what the WARN_ON is saynig, unless I'm missing something. It's checking if we were woken up early and there's no signal pending for us.

Cheers,
Muli

Quoted 20 lines

Remove the WARN_ON checking for that.

diff -u linux/kernel/Makefile-o linux/kernel/Makefile diff -u linux/kernel/futex.c-o linux/kernel/futex.c

kernel/futex.c renamed from kernel/futex.c-o +0 -3
@@ -504,8 +504,6 @@
 		return 0;
 	if (time == 0)
 		return -ETIMEDOUT;
-	/* A spurious wakeup should never happen. */
-	WARN_ON(!signal_pending(current));
 	return -EINTR;
 
  out_unqueue:
-

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/
author
#2 lore raw
Quoted 9 lines · On Wed, 19 May 2004 13:43:40 +0300 Muli Ben-Yehuda <[email protected]> wrote:
Quoted 4 lines · Andi Kleen

futex_wait goes to an interruptible sleep, but does a WARN_ON later if it wakes up early. But waking up early is totally legal, since the sleep is interruptible and any signal can wake it up.

That's not what the WARN_ON is saynig, unless I'm missing something. It's checking if we were woken up early and there's no signal pending for us.

True. Anyways, it seems to happen in practice.

-Andi

#3 lore raw
Quoted 10 lines · Andi Kleen
Quoted 6 lines · On Wed, 19 May 2004 13:43:40 +0300 Muli Ben-Yehuda <[email protected]> wrote:
Quoted 3 lines · Andi Kleen

futex_wait goes to an interruptible sleep, but does a WARN_ON later if it wakes up early. But waking up early is totally legal, since the sleep is interruptible and any signal can wake it up.

Quoted 7 lines
Quoted 3 lines

That's not what the WARN_ON is saynig, unless I'm missing something. It's checking if we were woken up early and there's no signal pending for us.

True. Anyways, it seems to happen in practice.

Somebody thought an early wakeup there was buggy (but harmless). There was a patch for kernel/sched.c that was supposed to print the source of the wakeup. I think the WARN_ON in the futex is pretty uninteresting without the sched.c patch...

#4 lore raw
In reply to Andi Kleen
Quoted 9 lines · Andi Kleen
Quoted 6 lines · On Wed, 19 May 2004 13:43:40 +0300 Muli Ben-Yehuda <[email protected]> wrote:
Quoted 4 lines · Andi Kleen

futex_wait goes to an interruptible sleep, but does a WARN_ON later if it wakes up early. But waking up early is totally legal, since the sleep is interruptible and any signal can wake it up.

Quoted 5 lines
Quoted 3 lines

That's not what the WARN_ON is saynig, unless I'm missing something. It's checking if we were woken up early and there's no signal pending for us.

True. Anyways, it seems to happen in practice.

Granted; the interesting question is whether this is harmless or something to worry about. Any ideas why it happens?

Cheers,
Muli

Signature · 2 lines
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/
#5 lore raw
In reply to Andi Kleen
Quoted 9 lines · Andi Kleen
Quoted 6 lines · On Wed, 19 May 2004 13:43:40 +0300 Muli Ben-Yehuda <[email protected]> wrote:
Quoted 4 lines · Andi Kleen

futex_wait goes to an interruptible sleep, but does a WARN_ON later if it wakes up early. But waking up early is totally legal, since the sleep is interruptible and any signal can wake it up.

Quoted 5 lines
Quoted 3 lines

That's not what the WARN_ON is saynig, unless I'm missing something. It's checking if we were woken up early and there's no signal pending for us.

True. Anyways, it seems to happen in practice.

I'm guessing that at least one of the ways to trigger this is with ptrace. Linux has a nasty habit of waking "wake on signal" sleeps without a signal if ptrace cancels the signal.

Signature · 1 line
Daniel Jacobowitz
#6 lore raw
In reply to Andi Kleen
Quoted 9 lines · Andi Kleen
Quoted 6 lines · On Wed, 19 May 2004 13:43:40 +0300 Muli Ben-Yehuda <[email protected]> wrote:
Quoted 4 lines · Andi Kleen

futex_wait goes to an interruptible sleep, but does a WARN_ON later if it wakes up early. But waking up early is totally legal, since the sleep is interruptible and any signal can wake it up.

Quoted 5 lines
Quoted 3 lines

That's not what the WARN_ON is saynig, unless I'm missing something. It's checking if we were woken up early and there's no signal pending for us.

True. Anyways, it seems to happen in practice.

Which we've been trying to figure out. We return -EINTR in this case even though it's a lie. Don't know if it breaks anything, but I *really* want to know who the buggy waker is before pronouncing it harmless.

Rusty.

Signature · 1 line
Anyone who quotes me in their signature is an idiot -- Rusty Russell
author
#7 lore raw
Quoted 4 lines · On Thu, 20 May 2004 10:52:46 +1000 Rusty Russell <[email protected]> wrote:

Which we've been trying to figure out. We return -EINTR in this case even though it's a lie. Don't know if it breaks anything, but I *really* want to know who the buggy waker is before pronouncing it harmless.

e.g. from ptrace, like Daniel said. I don't think it was from ptrace in the case where I saw a report, but it shows that the WARN_ON is bogus. If you really want to know what causes it you would need more debugging code as Nick pointed out too. So, the WARN_ON in its current form
is known to trigger in a valid situation and not sufficient to find possible problems. I would remove it.

-Andi