public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Davidlohr Bueso <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hpa@zytor.com, dbueso@suse.de, linux-kernel@vger.kernel.org,
	mingo@kernel.org, dave@stgolabs.net, peterz@infradead.org,
	tglx@linutronix.de
Subject: [tip:locking/urgent] futex: Acknowledge a new waiter in counter before plist
Date: Thu, 21 Apr 2016 03:06:38 -0700	[thread overview]
Message-ID: <tip-fe1bce9e2107ba3a8faffe572483b6974201a0e6@git.kernel.org> (raw)
In-Reply-To: <1461208164-29150-1-git-send-email-dave@stgolabs.net>

Commit-ID:  fe1bce9e2107ba3a8faffe572483b6974201a0e6
Gitweb:     http://git.kernel.org/tip/fe1bce9e2107ba3a8faffe572483b6974201a0e6
Author:     Davidlohr Bueso <dave@stgolabs.net>
AuthorDate: Wed, 20 Apr 2016 20:09:24 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 21 Apr 2016 11:06:09 +0200

futex: Acknowledge a new waiter in counter before plist

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.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: bigeasy@linutronix.de
Cc: dvhart@infradead.org
Cc: stable@kernel.org
Link: http://lkml.kernel.org/r/1461208164-29150-1-git-send-email-dave@stgolabs.net
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 kernel/futex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index fd204e1..c20f06f 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1535,8 +1535,8 @@ void requeue_futex(struct futex_q *q, struct futex_hash_bucket *hb1,
 	if (likely(&hb1->chain != &hb2->chain)) {
 		plist_del(&q->list, &hb1->chain);
 		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);

      reply	other threads:[~2016-04-21 10:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21  3:09 [PATCH -tip] futex: Acknowledge a new waiter in counter before plist Davidlohr Bueso
2016-04-21 10:06 ` tip-bot for Davidlohr Bueso [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-fe1bce9e2107ba3a8faffe572483b6974201a0e6@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=dave@stgolabs.net \
    --cc=dbueso@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox