mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Davidlohr Bueso <davidlohr@hp.com>
To: mingo@kernel.org, tglx@linutronix.de
Cc: peterz@infradead.org, davidlohr@hp.com, aswin@hp.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] futex: add plist_del + atomic_dec helper
Date: Sun, 30 Mar 2014 16:08:48 -0700	[thread overview]
Message-ID: <1396220928-4426-3-git-send-email-davidlohr@hp.com> (raw)
In-Reply-To: <1396220928-4426-1-git-send-email-davidlohr@hp.com>

When removing a waiter from the plist, we always decrement the
hb waiters to reflect such logic. Add an unqueue_waiter() helper,
thus preventing any future changes that might not do so.

For the enqueuing, this isn't worth it since we will increment the
hb waiters before doing the plist_add().

Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
---
 kernel/futex.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index 395e285..b9ef521 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -291,6 +291,13 @@ static inline int hb_waiters_pending(struct futex_hash_bucket *hb)
 #endif
 }
 
+static inline void unqueue_waiter(struct futex_q *q,
+				  struct futex_hash_bucket *hb)
+{
+	plist_del(&q->list, &hb->chain);
+	hb_waiters_dec(hb);
+}
+
 /*
  * We hash on the keys returned from get_futex_key (see below).
  */
@@ -972,8 +979,7 @@ static void __unqueue_futex(struct futex_q *q)
 		return;
 
 	hb = container_of(q->lock_ptr, struct futex_hash_bucket, lock);
-	plist_del(&q->list, &hb->chain);
-	hb_waiters_dec(hb);
+	unqueue_waiter(q, hb);
 }
 
 /*
@@ -1276,8 +1282,7 @@ void requeue_futex(struct futex_q *q, struct futex_hash_bucket *hb1,
 	 * requeue.
 	 */
 	if (likely(&hb1->chain != &hb2->chain)) {
-		plist_del(&q->list, &hb1->chain);
-		hb_waiters_dec(hb1);
+		unqueue_waiter(q, hb1);
 		plist_add(&q->list, &hb2->chain);
 		hb_waiters_inc(hb2);
 		q->lock_ptr = &hb2->lock;
@@ -2375,8 +2380,7 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb,
 		 * We were woken prior to requeue by a timeout or a signal.
 		 * Unqueue the futex_q and determine which it was.
 		 */
-		plist_del(&q->list, &hb->chain);
-		hb_waiters_dec(hb);
+		unqueue_waiter(q, hb);
 
 		/* Handle spurious wakeups gracefully */
 		ret = -EWOULDBLOCK;
-- 
1.8.1.4


      parent reply	other threads:[~2014-03-30 23:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-30 23:08 [PATCH 0/2] futex: updates for hb waiters Davidlohr Bueso
2014-03-30 23:08 ` [PATCH 1/2] futex: update comments for ordering guarantees Davidlohr Bueso
2014-03-30 23:08 ` 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=1396220928-4426-3-git-send-email-davidlohr@hp.com \
    --to=davidlohr@hp.com \
    --cc=aswin@hp.com \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®