Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1369921
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC patch 1/7] futex: Provide helpers for hash bucket add/remove |
| Date | 2016-04-02 13:20 +0200 |
| Message-ID | <rjrKW-2UX-7@gated-at.bofh.it> (permalink) |
| References | <rjrKV-2UX-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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 */
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC patch 0/7] futex: Add support for attached futexes Thomas Gleixner <tglx@linutronix.de> - 2016-04-02 13:20 +0200
[RFC patch 1/7] futex: Provide helpers for hash bucket add/remove Thomas Gleixner <tglx@linutronix.de> - 2016-04-02 13:20 +0200
[RFC patch 2/7] futex: Add some more function commentry Thomas Gleixner <tglx@linutronix.de> - 2016-04-02 13:20 +0200
[RFC patch 5/7] perf/bench/futex-hash: Support for attached futexes Thomas Gleixner <tglx@linutronix.de> - 2016-04-02 13:20 +0200
[RFC patch 4/7] futex: Add support for attached futexes Thomas Gleixner <tglx@linutronix.de> - 2016-04-02 13:20 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Peter Zijlstra <peterz@infradead.org> - 2016-04-02 18:30 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Thomas Gleixner <tglx@linutronix.de> - 2016-04-03 12:10 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Peter Zijlstra <peterz@infradead.org> - 2016-04-02 18:30 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Thomas Gleixner <tglx@linutronix.de> - 2016-04-02 20:10 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Andy Lutomirski <luto@kernel.org> - 2016-04-02 20:30 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Thomas Gleixner <tglx@linutronix.de> - 2016-04-03 12:00 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Andy Lutomirski <luto@amacapital.net> - 2016-04-03 15:20 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Thomas Gleixner <tglx@linutronix.de> - 2016-04-03 18:00 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Andy Lutomirski <luto@amacapital.net> - 2016-04-03 18:20 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-04-03 01:50 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Thomas Gleixner <tglx@linutronix.de> - 2016-04-03 12:10 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Ingo Molnar <mingo@kernel.org> - 2016-04-03 13:20 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-03 13:40 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Torvald Riegel <triegel@redhat.com> - 2016-04-05 09:50 +0200
Re: [RFC patch 4/7] futex: Add support for attached futexes Carlos O'Donell <carlos@redhat.com> - 2016-04-05 18:00 +0200
[RFC patch 7/7] [PATCH] glibc: nptl: Add support for attached pthread_mutexes Thomas Gleixner <tglx@linutronix.de> - 2016-04-02 13:20 +0200
Re: [RFC patch 7/7] [PATCH] glibc: nptl: Add support for attached pthread_mutexes Peter Zijlstra <peterz@infradead.org> - 2016-04-02 18:40 +0200
Re: [RFC patch 7/7] [PATCH] glibc: nptl: Add support for attached pthread_mutexes Peter Zijlstra <peterz@infradead.org> - 2016-04-02 18:40 +0200
Re: [RFC patch 7/7] [PATCH] glibc: nptl: Add support for attached pthread_mutexes Thomas Gleixner <tglx@linutronix.de> - 2016-04-03 12:20 +0200
csiph-web