Skip to content

Commit 6898563

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched/wait: Fix signal handling in bit wait helpers
Vladimir reported getting RCU stall warnings and bisected it back to commit: 7431620 ("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: Vladimir Murzin <vladimir.murzin@arm.com> Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> Signed-off-by: Peter 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: 7431620 ("sched: Remove proliferation of wait_on_bit() action functions") Fixes: cbbce82 ("SCHED: add some "wait..on_bit...timeout()" interfaces.") Link: http://lkml.kernel.org/r/20151201130404.GL3816@twins.programming.kicks-ass.net Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 89b4110 commit 6898563

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

kernel/sched/wait.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -583,42 +583,42 @@ EXPORT_SYMBOL(wake_up_atomic_t);
583583

584584
__sched int bit_wait(struct wait_bit_key *word)
585585
{
586-
if (signal_pending_state(current->state, current))
587-
return 1;
588586
schedule();
587+
if (signal_pending(current))
588+
return -EINTR;
589589
return 0;
590590
}
591591
EXPORT_SYMBOL(bit_wait);
592592

593593
__sched int bit_wait_io(struct wait_bit_key *word)
594594
{
595-
if (signal_pending_state(current->state, current))
596-
return 1;
597595
io_schedule();
596+
if (signal_pending(current))
597+
return -EINTR;
598598
return 0;
599599
}
600600
EXPORT_SYMBOL(bit_wait_io);
601601

602602
__sched int bit_wait_timeout(struct wait_bit_key *word)
603603
{
604604
unsigned long now = READ_ONCE(jiffies);
605-
if (signal_pending_state(current->state, current))
606-
return 1;
607605
if (time_after_eq(now, word->timeout))
608606
return -EAGAIN;
609607
schedule_timeout(word->timeout - now);
608+
if (signal_pending(current))
609+
return -EINTR;
610610
return 0;
611611
}
612612
EXPORT_SYMBOL_GPL(bit_wait_timeout);
613613

614614
__sched int bit_wait_io_timeout(struct wait_bit_key *word)
615615
{
616616
unsigned long now = READ_ONCE(jiffies);
617-
if (signal_pending_state(current->state, current))
618-
return 1;
619617
if (time_after_eq(now, word->timeout))
620618
return -EAGAIN;
621619
io_schedule_timeout(word->timeout - now);
620+
if (signal_pending(current))
621+
return -EINTR;
622622
return 0;
623623
}
624624
EXPORT_SYMBOL_GPL(bit_wait_io_timeout);

0 commit comments

Comments
 (0)