From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Darren Hart <darren@dvhart.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Michael Kerrisk <mtk.manpages@googlemail.com>,
Davidlohr Bueso <dave@stgolabs.net>, Chris Mason <clm@fb.com>,
"Carlos O'Donell" <carlos@redhat.com>,
Torvald Riegel <triegel@redhat.com>,
Eric Dumazet <edumazet@google.com>
Subject: [RFC patch 1/7] futex: Provide helpers for hash bucket add/remove
Date: Sat, 02 Apr 2016 11:09:15 -0000 [thread overview]
Message-ID: <20160402110035.315879045@linutronix.de> (raw)
In-Reply-To: 20160402095108.894519835@linutronix.de
[-- Attachment #1: futex--Provide-helpers-for-hash-bucket-add-remove.patch --]
[-- Type: text/plain, Size: 2528 bytes --]
Provide helpers for adding/removing futex_q to/from a hash bucket so we don't
have more open coded places when adding support for attached futexes.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/futex.c | 39 +++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
Index: b/kernel/futex.c
===================================================================
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -373,6 +373,35 @@ static inline int hb_waiters_pending(str
#endif
}
+/**
+ * hb_insert_q - Insert futex_q into a hash bucket
+ * @q: Pointer to the futex_q object
+ * @hb: Pointer to the hash bucket
+ * @prio: Priority ordering for insertion
+ *
+ * Inserts @q into the hash buckets @hb plist. Must be called with @hb->lock
+ * held.
+ */
+static inline void
+hb_insert_q(struct futex_q *q, struct futex_hash_bucket *hb, int prio)
+{
+ plist_node_init(&q->list, prio);
+ plist_add(&q->list, &hb->chain);
+}
+
+/**
+ * hb_remove_q - Remove futex_q from a hash bucket
+ * @q: Pointer to the futex_q object
+ * @hb: Pointer to the hash bucket
+ *
+ * Removes @q from the hash buckets @hb plist. Must be called with @hb->lock
+ * held.
+ */
+static inline void hb_remove_q(struct futex_q *q, struct futex_hash_bucket *hb)
+{
+ plist_del(&q->list, &hb->chain);
+}
+
/*
* We hash on the keys returned from get_futex_key (see below).
*/
@@ -1221,7 +1250,7 @@ static void __unqueue_futex(struct futex
return;
hb = container_of(q->lock_ptr, struct futex_hash_bucket, lock);
- plist_del(&q->list, &hb->chain);
+ hb_remove_q(q, hb);
hb_waiters_dec(hb);
}
@@ -1523,7 +1552,7 @@ void requeue_futex(struct futex_q *q, st
* requeue.
*/
if (likely(&hb1->chain != &hb2->chain)) {
- plist_del(&q->list, &hb1->chain);
+ hb_remove_q(q, hb1);
hb_waiters_dec(hb1);
plist_add(&q->list, &hb2->chain);
hb_waiters_inc(hb2);
@@ -1985,9 +2014,7 @@ static inline void queue_me(struct futex
* the others are woken last, in FIFO order.
*/
prio = min(current->normal_prio, MAX_RT_PRIO);
-
- plist_node_init(&q->list, prio);
- plist_add(&q->list, &hb->chain);
+ hb_insert_q(q, hb, prio);
q->task = current;
spin_unlock(&hb->lock);
}
@@ -2697,7 +2724,7 @@ int handle_early_requeue_pi_wakeup(struc
* 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_remove_q(q, hb);
hb_waiters_dec(hb);
/* Handle spurious wakeups gracefully */
next prev parent reply other threads:[~2016-04-02 11:10 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-02 11:09 [RFC patch 0/7] futex: Add support for attached futexes Thomas Gleixner
2016-04-02 11:09 ` Thomas Gleixner [this message]
2016-04-02 11:09 ` [RFC patch 2/7] futex: Add some more function commentry Thomas Gleixner
2016-04-02 11:09 ` [RFC patch 3/7] futex: Make key init a helper function Thomas Gleixner
2016-04-02 11:09 ` [RFC patch 4/7] futex: Add support for attached futexes Thomas Gleixner
2016-04-02 16:26 ` Peter Zijlstra
2016-04-02 18:01 ` Thomas Gleixner
2016-04-02 16:29 ` Peter Zijlstra
2016-04-03 9:59 ` Thomas Gleixner
2016-04-02 18:19 ` Andy Lutomirski
2016-04-03 9:57 ` Thomas Gleixner
2016-04-03 13:18 ` Andy Lutomirski
2016-04-03 15:56 ` Thomas Gleixner
2016-04-03 16:11 ` Andy Lutomirski
2016-04-02 23:48 ` Rasmus Villemoes
2016-04-03 10:05 ` Thomas Gleixner
2016-04-03 11:16 ` Ingo Molnar
2016-04-03 11:30 ` Linus Torvalds
2016-04-05 7:44 ` Torvald Riegel
2016-04-05 15:58 ` Carlos O'Donell
2016-04-02 11:09 ` [RFC patch 5/7] perf/bench/futex-hash: Support " Thomas Gleixner
2016-04-02 11:09 ` [RFC patch 6/7] futex.2: Document attached mode Thomas Gleixner
2016-04-02 11:09 ` [RFC patch 7/7] [PATCH] glibc: nptl: Add support for attached pthread_mutexes Thomas Gleixner
2016-04-02 16:30 ` Peter Zijlstra
2016-04-02 16:32 ` Peter Zijlstra
2016-04-03 10:08 ` Thomas Gleixner
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=20160402110035.315879045@linutronix.de \
--to=tglx@linutronix.de \
--cc=bigeasy@linutronix.de \
--cc=carlos@redhat.com \
--cc=clm@fb.com \
--cc=darren@dvhart.com \
--cc=dave@stgolabs.net \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mtk.manpages@googlemail.com \
--cc=peterz@infradead.org \
--cc=triegel@redhat.com \
/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