aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/futex.c
diff options
context:
space:
mode:
authorDarren Hart <dvhltc@us.ibm.com>2009-04-03 16:40:31 -0400
committerThomas Gleixner <tglx@linutronix.de>2009-04-06 05:14:02 -0400
commit9121e4783cd5c7e2a407763f3b61c2d573891133 (patch)
tree0a3079a738d199514d1ecdb479567e772ca1e03d /kernel/futex.c
parenta72188d8a64ebe74722f1cf7ffac41b41ffdba21 (diff)
futex: distangle futex_requeue()
futex_requeue() is getting a bit long-winded, and will be getting more so after the requeue_pi patch. Factor out the actual requeueing into a nicely contained inline function to reduce function length and improve legibility. Signed-off-by: Darren Hart <dvhltc@us.ibm.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/futex.c')
-rw-r--r--kernel/futex.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/kernel/futex.c b/kernel/futex.c
index 6b597cf33b02..e76942e2a79f 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -940,6 +940,34 @@ out:
940 return ret; 940 return ret;
941} 941}
942 942
943/**
944 * requeue_futex() - Requeue a futex_q from one hb to another
945 * @q: the futex_q to requeue
946 * @hb1: the source hash_bucket
947 * @hb2: the target hash_bucket
948 * @key2: the new key for the requeued futex_q
949 */
950static inline
951void requeue_futex(struct futex_q *q, struct futex_hash_bucket *hb1,
952 struct futex_hash_bucket *hb2, union futex_key *key2)
953{
954
955 /*
956 * If key1 and key2 hash to the same bucket, no need to
957 * requeue.
958 */
959 if (likely(&hb1->chain != &hb2->chain)) {
960 plist_del(&q->list, &hb1->chain);
961 plist_add(&q->list, &hb2->chain);
962 q->lock_ptr = &hb2->lock;
963#ifdef CONFIG_DEBUG_PI_LIST
964 q->list.plist.lock = &hb2->lock;
965#endif
966 }
967 get_futex_key_refs(key2);
968 q->key = *key2;
969}
970
943/* 971/*
944 * Requeue all waiters hashed on one physical page to another 972 * Requeue all waiters hashed on one physical page to another
945 * physical page. 973 * physical page.
@@ -999,20 +1027,7 @@ retry_private:
999 if (++ret <= nr_wake) { 1027 if (++ret <= nr_wake) {
1000 wake_futex(this); 1028 wake_futex(this);
1001 } else { 1029 } else {
1002 /* 1030 requeue_futex(this, hb1, hb2, &key2);
1003 * If key1 and key2 hash to the same bucket, no need to
1004 * requeue.
1005 */
1006 if (likely(head1 != &hb2->chain)) {
1007 plist_del(&this->list, &hb1->chain);
1008 plist_add(&this->list, &hb2->chain);
1009 this->lock_ptr = &hb2->lock;
1010#ifdef CONFIG_DEBUG_PI_LIST
1011 this->list.plist.lock = &hb2->lock;
1012#endif
1013 }
1014 this->key = key2;
1015 get_futex_key_refs(&key2);
1016 drop_count++; 1031 drop_count++;
1017 1032
1018 if (ret - nr_wake >= nr_requeue) 1033 if (ret - nr_wake >= nr_requeue)