sched/swait: Switch to full exclusive mode
authorPeter Zijlstra <peterz@infradead.org>
Tue, 12 Jun 2018 08:34:51 +0000 (10:34 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 20 Jun 2018 09:35:56 +0000 (11:35 +0200)
commit0abf17bc7790dd0467ed0e38522242f23c5da1c4
treeef6c4c8f6feb00066e79e4144cab2f4e7ca30b79
parent6519750210d9d3330e85d12e0128652edde448d2
sched/swait: Switch to full exclusive mode

Linus noted that swait basically implements exclusive mode -- because
swake_up() only wakes a single waiter. And because of that it should
take care to properly deal with the interruptible case.

In short, the problem is that swake_up() can race with a signal. In
this this case it is possible the swake_up() 'wakes' the waiter that
is already on the way out because it just got a signal and the wakeup
gets lost.

The normal wait code is very careful and avoids this situation, make
sure we do too.

Copy the exact exclusive semantics from wait.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: bigeasy@linutronix.de
Cc: oleg@redhat.com
Cc: paulmck@linux.vnet.ibm.com
Cc: pbonzini@redhat.com
Link: https://lkml.kernel.org/r/20180612083909.209762413@infradead.org
include/linux/swait.h
kernel/sched/swait.c