Commit 68985633 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

sched/wait: Fix signal handling in bit wait helpers

Vladimir reported getting RCU stall warnings and bisected it back to
commit:

  74316201 ("sched: Remove proliferation of wait_on_bit() action functions")

That commit inadvertently reversed the calls to schedule() and signal_pending(),
thereby not handling the case where the signal receives while we sleep.
Reported-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
Tested-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: mark.rutland@arm.com
Cc: neilb@suse.de
Cc: oleg@redhat.com
Fixes: 74316201 ("sched: Remove proliferation of wait_on_bit() action functions")
Fixes: cbbce822 ("SCHED: add some "wait..on_bit...timeout()" interfaces.")
Link: http://lkml.kernel.org/r/20151201130404.GL3816@twins.programming.kicks-ass.netSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 89b41108
...@@ -583,18 +583,18 @@ EXPORT_SYMBOL(wake_up_atomic_t); ...@@ -583,18 +583,18 @@ EXPORT_SYMBOL(wake_up_atomic_t);
__sched int bit_wait(struct wait_bit_key *word) __sched int bit_wait(struct wait_bit_key *word)
{ {
if (signal_pending_state(current->state, current))
return 1;
schedule(); schedule();
if (signal_pending(current))
return -EINTR;
return 0; return 0;
} }
EXPORT_SYMBOL(bit_wait); EXPORT_SYMBOL(bit_wait);
__sched int bit_wait_io(struct wait_bit_key *word) __sched int bit_wait_io(struct wait_bit_key *word)
{ {
if (signal_pending_state(current->state, current))
return 1;
io_schedule(); io_schedule();
if (signal_pending(current))
return -EINTR;
return 0; return 0;
} }
EXPORT_SYMBOL(bit_wait_io); EXPORT_SYMBOL(bit_wait_io);
...@@ -602,11 +602,11 @@ EXPORT_SYMBOL(bit_wait_io); ...@@ -602,11 +602,11 @@ EXPORT_SYMBOL(bit_wait_io);
__sched int bit_wait_timeout(struct wait_bit_key *word) __sched int bit_wait_timeout(struct wait_bit_key *word)
{ {
unsigned long now = READ_ONCE(jiffies); unsigned long now = READ_ONCE(jiffies);
if (signal_pending_state(current->state, current))
return 1;
if (time_after_eq(now, word->timeout)) if (time_after_eq(now, word->timeout))
return -EAGAIN; return -EAGAIN;
schedule_timeout(word->timeout - now); schedule_timeout(word->timeout - now);
if (signal_pending(current))
return -EINTR;
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(bit_wait_timeout); EXPORT_SYMBOL_GPL(bit_wait_timeout);
...@@ -614,11 +614,11 @@ EXPORT_SYMBOL_GPL(bit_wait_timeout); ...@@ -614,11 +614,11 @@ EXPORT_SYMBOL_GPL(bit_wait_timeout);
__sched int bit_wait_io_timeout(struct wait_bit_key *word) __sched int bit_wait_io_timeout(struct wait_bit_key *word)
{ {
unsigned long now = READ_ONCE(jiffies); unsigned long now = READ_ONCE(jiffies);
if (signal_pending_state(current->state, current))
return 1;
if (time_after_eq(now, word->timeout)) if (time_after_eq(now, word->timeout))
return -EAGAIN; return -EAGAIN;
io_schedule_timeout(word->timeout - now); io_schedule_timeout(word->timeout - now);
if (signal_pending(current))
return -EINTR;
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(bit_wait_io_timeout); EXPORT_SYMBOL_GPL(bit_wait_io_timeout);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment