diff options
author | Jason Low <jason.low2@hp.com> | 2014-01-12 18:31:22 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-01-13 05:45:17 -0500 |
commit | 0d00c7b20c7716ce08399570ea48813ecf001aa8 (patch) | |
tree | a94b3f78d7766514672f3feb165fa9e848a4527e /kernel/futex.c | |
parent | 1c62448e39285b23b4770aaf46d32368fff990df (diff) |
futexes: Clean up various details
- Remove unnecessary head variables.
- Delete unused parameter in queue_unlock().
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Reviewed-by: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jason Low <jason.low2@hp.com>
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Jeff Mahoney <jeffm@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Scott Norton <scott.norton@hp.com>
Cc: Tom Vaden <tom.vaden@hp.com>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Cc: Waiman Long <Waiman.Long@hp.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/1389569486-25487-2-git-send-email-davidlohr@hp.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/futex.c')
-rw-r--r-- | kernel/futex.c | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/kernel/futex.c b/kernel/futex.c index f6ff0191ecf7..085f5fa0b342 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -598,13 +598,10 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb, | |||
598 | { | 598 | { |
599 | struct futex_pi_state *pi_state = NULL; | 599 | struct futex_pi_state *pi_state = NULL; |
600 | struct futex_q *this, *next; | 600 | struct futex_q *this, *next; |
601 | struct plist_head *head; | ||
602 | struct task_struct *p; | 601 | struct task_struct *p; |
603 | pid_t pid = uval & FUTEX_TID_MASK; | 602 | pid_t pid = uval & FUTEX_TID_MASK; |
604 | 603 | ||
605 | head = &hb->chain; | 604 | plist_for_each_entry_safe(this, next, &hb->chain, list) { |
606 | |||
607 | plist_for_each_entry_safe(this, next, head, list) { | ||
608 | if (match_futex(&this->key, key)) { | 605 | if (match_futex(&this->key, key)) { |
609 | /* | 606 | /* |
610 | * Another waiter already exists - bump up | 607 | * Another waiter already exists - bump up |
@@ -986,7 +983,6 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset) | |||
986 | { | 983 | { |
987 | struct futex_hash_bucket *hb; | 984 | struct futex_hash_bucket *hb; |
988 | struct futex_q *this, *next; | 985 | struct futex_q *this, *next; |
989 | struct plist_head *head; | ||
990 | union futex_key key = FUTEX_KEY_INIT; | 986 | union futex_key key = FUTEX_KEY_INIT; |
991 | int ret; | 987 | int ret; |
992 | 988 | ||
@@ -999,9 +995,8 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset) | |||
999 | 995 | ||
1000 | hb = hash_futex(&key); | 996 | hb = hash_futex(&key); |
1001 | spin_lock(&hb->lock); | 997 | spin_lock(&hb->lock); |
1002 | head = &hb->chain; | ||
1003 | 998 | ||
1004 | plist_for_each_entry_safe(this, next, head, list) { | 999 | plist_for_each_entry_safe(this, next, &hb->chain, list) { |
1005 | if (match_futex (&this->key, &key)) { | 1000 | if (match_futex (&this->key, &key)) { |
1006 | if (this->pi_state || this->rt_waiter) { | 1001 | if (this->pi_state || this->rt_waiter) { |
1007 | ret = -EINVAL; | 1002 | ret = -EINVAL; |
@@ -1034,7 +1029,6 @@ futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2, | |||
1034 | { | 1029 | { |
1035 | union futex_key key1 = FUTEX_KEY_INIT, key2 = FUTEX_KEY_INIT; | 1030 | union futex_key key1 = FUTEX_KEY_INIT, key2 = FUTEX_KEY_INIT; |
1036 | struct futex_hash_bucket *hb1, *hb2; | 1031 | struct futex_hash_bucket *hb1, *hb2; |
1037 | struct plist_head *head; | ||
1038 | struct futex_q *this, *next; | 1032 | struct futex_q *this, *next; |
1039 | int ret, op_ret; | 1033 | int ret, op_ret; |
1040 | 1034 | ||
@@ -1082,9 +1076,7 @@ retry_private: | |||
1082 | goto retry; | 1076 | goto retry; |
1083 | } | 1077 | } |
1084 | 1078 | ||
1085 | head = &hb1->chain; | 1079 | plist_for_each_entry_safe(this, next, &hb1->chain, list) { |
1086 | |||
1087 | plist_for_each_entry_safe(this, next, head, list) { | ||
1088 | if (match_futex (&this->key, &key1)) { | 1080 | if (match_futex (&this->key, &key1)) { |
1089 | if (this->pi_state || this->rt_waiter) { | 1081 | if (this->pi_state || this->rt_waiter) { |
1090 | ret = -EINVAL; | 1082 | ret = -EINVAL; |
@@ -1097,10 +1089,8 @@ retry_private: | |||
1097 | } | 1089 | } |
1098 | 1090 | ||
1099 | if (op_ret > 0) { | 1091 | if (op_ret > 0) { |
1100 | head = &hb2->chain; | ||
1101 | |||
1102 | op_ret = 0; | 1092 | op_ret = 0; |
1103 | plist_for_each_entry_safe(this, next, head, list) { | 1093 | plist_for_each_entry_safe(this, next, &hb2->chain, list) { |
1104 | if (match_futex (&this->key, &key2)) { | 1094 | if (match_futex (&this->key, &key2)) { |
1105 | if (this->pi_state || this->rt_waiter) { | 1095 | if (this->pi_state || this->rt_waiter) { |
1106 | ret = -EINVAL; | 1096 | ret = -EINVAL; |
@@ -1270,7 +1260,6 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags, | |||
1270 | int drop_count = 0, task_count = 0, ret; | 1260 | int drop_count = 0, task_count = 0, ret; |
1271 | struct futex_pi_state *pi_state = NULL; | 1261 | struct futex_pi_state *pi_state = NULL; |
1272 | struct futex_hash_bucket *hb1, *hb2; | 1262 | struct futex_hash_bucket *hb1, *hb2; |
1273 | struct plist_head *head1; | ||
1274 | struct futex_q *this, *next; | 1263 | struct futex_q *this, *next; |
1275 | u32 curval2; | 1264 | u32 curval2; |
1276 | 1265 | ||
@@ -1393,8 +1382,7 @@ retry_private: | |||
1393 | } | 1382 | } |
1394 | } | 1383 | } |
1395 | 1384 | ||
1396 | head1 = &hb1->chain; | 1385 | plist_for_each_entry_safe(this, next, &hb1->chain, list) { |
1397 | plist_for_each_entry_safe(this, next, head1, list) { | ||
1398 | if (task_count - nr_wake >= nr_requeue) | 1386 | if (task_count - nr_wake >= nr_requeue) |
1399 | break; | 1387 | break; |
1400 | 1388 | ||
@@ -1494,7 +1482,7 @@ static inline struct futex_hash_bucket *queue_lock(struct futex_q *q) | |||
1494 | } | 1482 | } |
1495 | 1483 | ||
1496 | static inline void | 1484 | static inline void |
1497 | queue_unlock(struct futex_q *q, struct futex_hash_bucket *hb) | 1485 | queue_unlock(struct futex_hash_bucket *hb) |
1498 | __releases(&hb->lock) | 1486 | __releases(&hb->lock) |
1499 | { | 1487 | { |
1500 | spin_unlock(&hb->lock); | 1488 | spin_unlock(&hb->lock); |
@@ -1867,7 +1855,7 @@ retry_private: | |||
1867 | ret = get_futex_value_locked(&uval, uaddr); | 1855 | ret = get_futex_value_locked(&uval, uaddr); |
1868 | 1856 | ||
1869 | if (ret) { | 1857 | if (ret) { |
1870 | queue_unlock(q, *hb); | 1858 | queue_unlock(*hb); |
1871 | 1859 | ||
1872 | ret = get_user(uval, uaddr); | 1860 | ret = get_user(uval, uaddr); |
1873 | if (ret) | 1861 | if (ret) |
@@ -1881,7 +1869,7 @@ retry_private: | |||
1881 | } | 1869 | } |
1882 | 1870 | ||
1883 | if (uval != val) { | 1871 | if (uval != val) { |
1884 | queue_unlock(q, *hb); | 1872 | queue_unlock(*hb); |
1885 | ret = -EWOULDBLOCK; | 1873 | ret = -EWOULDBLOCK; |
1886 | } | 1874 | } |
1887 | 1875 | ||
@@ -2029,7 +2017,7 @@ retry_private: | |||
2029 | * Task is exiting and we just wait for the | 2017 | * Task is exiting and we just wait for the |
2030 | * exit to complete. | 2018 | * exit to complete. |
2031 | */ | 2019 | */ |
2032 | queue_unlock(&q, hb); | 2020 | queue_unlock(hb); |
2033 | put_futex_key(&q.key); | 2021 | put_futex_key(&q.key); |
2034 | cond_resched(); | 2022 | cond_resched(); |
2035 | goto retry; | 2023 | goto retry; |
@@ -2081,7 +2069,7 @@ retry_private: | |||
2081 | goto out_put_key; | 2069 | goto out_put_key; |
2082 | 2070 | ||
2083 | out_unlock_put_key: | 2071 | out_unlock_put_key: |
2084 | queue_unlock(&q, hb); | 2072 | queue_unlock(hb); |
2085 | 2073 | ||
2086 | out_put_key: | 2074 | out_put_key: |
2087 | put_futex_key(&q.key); | 2075 | put_futex_key(&q.key); |
@@ -2091,7 +2079,7 @@ out: | |||
2091 | return ret != -EINTR ? ret : -ERESTARTNOINTR; | 2079 | return ret != -EINTR ? ret : -ERESTARTNOINTR; |
2092 | 2080 | ||
2093 | uaddr_faulted: | 2081 | uaddr_faulted: |
2094 | queue_unlock(&q, hb); | 2082 | queue_unlock(hb); |
2095 | 2083 | ||
2096 | ret = fault_in_user_writeable(uaddr); | 2084 | ret = fault_in_user_writeable(uaddr); |
2097 | if (ret) | 2085 | if (ret) |
@@ -2113,7 +2101,6 @@ static int futex_unlock_pi(u32 __user *uaddr, unsigned int flags) | |||
2113 | { | 2101 | { |
2114 | struct futex_hash_bucket *hb; | 2102 | struct futex_hash_bucket *hb; |
2115 | struct futex_q *this, *next; | 2103 | struct futex_q *this, *next; |
2116 | struct plist_head *head; | ||
2117 | union futex_key key = FUTEX_KEY_INIT; | 2104 | union futex_key key = FUTEX_KEY_INIT; |
2118 | u32 uval, vpid = task_pid_vnr(current); | 2105 | u32 uval, vpid = task_pid_vnr(current); |
2119 | int ret; | 2106 | int ret; |
@@ -2153,9 +2140,7 @@ retry: | |||
2153 | * Ok, other tasks may need to be woken up - check waiters | 2140 | * Ok, other tasks may need to be woken up - check waiters |
2154 | * and do the wakeup if necessary: | 2141 | * and do the wakeup if necessary: |
2155 | */ | 2142 | */ |
2156 | head = &hb->chain; | 2143 | plist_for_each_entry_safe(this, next, &hb->chain, list) { |
2157 | |||
2158 | plist_for_each_entry_safe(this, next, head, list) { | ||
2159 | if (!match_futex (&this->key, &key)) | 2144 | if (!match_futex (&this->key, &key)) |
2160 | continue; | 2145 | continue; |
2161 | ret = wake_futex_pi(uaddr, uval, this); | 2146 | ret = wake_futex_pi(uaddr, uval, this); |