[PATCH -tip] futex: Acknowledge a new waiter in counter before plist

From: Davidlohr Bueso
Date: Wed Apr 20 2016 - 23:09:43 EST


Otherwise an incoming waker on the dest hash bucket can miss
the waiter adding itself to the plist during the lockless
check optimization (small window but still the correct way
of doing this); similarly to the decrement counterpart.

Cc: stable@xxxxxxxxxx (since v3.14+)
Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Signed-off-by: Davidlohr Bueso <dbueso@xxxxxxx>
---
kernel/futex.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index e66e8d4fccff..913f05cfe8b8 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1745,8 +1745,8 @@ void requeue_futex(struct futex_q *q, struct futex_hash_bucket *hb1,
if (likely(&hb1->chain != &hb2->chain)) {
hb_remove_q(q, hb1);
hb_waiters_dec(hb1);
- plist_add(&q->list, &hb2->chain);
hb_waiters_inc(hb2);
+ plist_add(&q->list, &hb2->chain);
q->lock_ptr = &hb2->lock;
}
get_futex_key_refs(key2);
--
2.8.1