Commit ae791a2d authored by Thomas Gleixner's avatar Thomas Gleixner

futex: Cleanup stale fshared flag interfaces

The fast GUP changes stopped using the fshared flag in
put_futex_keys(), but we kept the interface the same.

Cleanup all stale users.

This patch is split out from Darren Harts combo patch which also
combines various flags. This way the changes are clearly separated.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Darren Hart <dvhart@linux.intel.com>
LKML-Reference: <1289250609-16304-1-git-send-email-dvhart@linux.intel.com>
parent 4c115e95
...@@ -283,8 +283,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key) ...@@ -283,8 +283,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key)
return 0; return 0;
} }
static inline static inline void put_futex_key(union futex_key *key)
void put_futex_key(int fshared, union futex_key *key)
{ {
drop_futex_key_refs(key); drop_futex_key_refs(key);
} }
...@@ -907,7 +906,7 @@ static int futex_wake(u32 __user *uaddr, int fshared, int nr_wake, u32 bitset) ...@@ -907,7 +906,7 @@ static int futex_wake(u32 __user *uaddr, int fshared, int nr_wake, u32 bitset)
} }
spin_unlock(&hb->lock); spin_unlock(&hb->lock);
put_futex_key(fshared, &key); put_futex_key(&key);
out: out:
return ret; return ret;
} }
...@@ -965,8 +964,8 @@ futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2, ...@@ -965,8 +964,8 @@ futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
if (!fshared) if (!fshared)
goto retry_private; goto retry_private;
put_futex_key(fshared, &key2); put_futex_key(&key2);
put_futex_key(fshared, &key1); put_futex_key(&key1);
goto retry; goto retry;
} }
...@@ -996,9 +995,9 @@ futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2, ...@@ -996,9 +995,9 @@ futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
double_unlock_hb(hb1, hb2); double_unlock_hb(hb1, hb2);
out_put_keys: out_put_keys:
put_futex_key(fshared, &key2); put_futex_key(&key2);
out_put_key1: out_put_key1:
put_futex_key(fshared, &key1); put_futex_key(&key1);
out: out:
return ret; return ret;
} }
...@@ -1219,8 +1218,8 @@ static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2, ...@@ -1219,8 +1218,8 @@ static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
if (!fshared) if (!fshared)
goto retry_private; goto retry_private;
put_futex_key(fshared, &key2); put_futex_key(&key2);
put_futex_key(fshared, &key1); put_futex_key(&key1);
goto retry; goto retry;
} }
if (curval != *cmpval) { if (curval != *cmpval) {
...@@ -1260,8 +1259,8 @@ static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2, ...@@ -1260,8 +1259,8 @@ static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
break; break;
case -EFAULT: case -EFAULT:
double_unlock_hb(hb1, hb2); double_unlock_hb(hb1, hb2);
put_futex_key(fshared, &key2); put_futex_key(&key2);
put_futex_key(fshared, &key1); put_futex_key(&key1);
ret = fault_in_user_writeable(uaddr2); ret = fault_in_user_writeable(uaddr2);
if (!ret) if (!ret)
goto retry; goto retry;
...@@ -1269,8 +1268,8 @@ static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2, ...@@ -1269,8 +1268,8 @@ static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
case -EAGAIN: case -EAGAIN:
/* The owner was exiting, try again. */ /* The owner was exiting, try again. */
double_unlock_hb(hb1, hb2); double_unlock_hb(hb1, hb2);
put_futex_key(fshared, &key2); put_futex_key(&key2);
put_futex_key(fshared, &key1); put_futex_key(&key1);
cond_resched(); cond_resched();
goto retry; goto retry;
default: default:
...@@ -1352,9 +1351,9 @@ static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2, ...@@ -1352,9 +1351,9 @@ static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
drop_futex_key_refs(&key1); drop_futex_key_refs(&key1);
out_put_keys: out_put_keys:
put_futex_key(fshared, &key2); put_futex_key(&key2);
out_put_key1: out_put_key1:
put_futex_key(fshared, &key1); put_futex_key(&key1);
out: out:
if (pi_state != NULL) if (pi_state != NULL)
free_pi_state(pi_state); free_pi_state(pi_state);
...@@ -1494,7 +1493,7 @@ static void unqueue_me_pi(struct futex_q *q) ...@@ -1494,7 +1493,7 @@ static void unqueue_me_pi(struct futex_q *q)
* private futexes. * private futexes.
*/ */
static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
struct task_struct *newowner, int fshared) struct task_struct *newowner)
{ {
u32 newtid = task_pid_vnr(newowner) | FUTEX_WAITERS; u32 newtid = task_pid_vnr(newowner) | FUTEX_WAITERS;
struct futex_pi_state *pi_state = q->pi_state; struct futex_pi_state *pi_state = q->pi_state;
...@@ -1600,7 +1599,6 @@ static long futex_wait_restart(struct restart_block *restart); ...@@ -1600,7 +1599,6 @@ static long futex_wait_restart(struct restart_block *restart);
/** /**
* fixup_owner() - Post lock pi_state and corner case management * fixup_owner() - Post lock pi_state and corner case management
* @uaddr: user address of the futex * @uaddr: user address of the futex
* @fshared: whether the futex is shared (1) or not (0)
* @q: futex_q (contains pi_state and access to the rt_mutex) * @q: futex_q (contains pi_state and access to the rt_mutex)
* @locked: if the attempt to take the rt_mutex succeeded (1) or not (0) * @locked: if the attempt to take the rt_mutex succeeded (1) or not (0)
* *
...@@ -1613,8 +1611,7 @@ static long futex_wait_restart(struct restart_block *restart); ...@@ -1613,8 +1611,7 @@ static long futex_wait_restart(struct restart_block *restart);
* 0 - success, lock not taken * 0 - success, lock not taken
* <0 - on error (-EFAULT) * <0 - on error (-EFAULT)
*/ */
static int fixup_owner(u32 __user *uaddr, int fshared, struct futex_q *q, static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked)
int locked)
{ {
struct task_struct *owner; struct task_struct *owner;
int ret = 0; int ret = 0;
...@@ -1625,7 +1622,7 @@ static int fixup_owner(u32 __user *uaddr, int fshared, struct futex_q *q, ...@@ -1625,7 +1622,7 @@ static int fixup_owner(u32 __user *uaddr, int fshared, struct futex_q *q,
* did a lock-steal - fix up the PI-state in that case: * did a lock-steal - fix up the PI-state in that case:
*/ */
if (q->pi_state->owner != current) if (q->pi_state->owner != current)
ret = fixup_pi_state_owner(uaddr, q, current, fshared); ret = fixup_pi_state_owner(uaddr, q, current);
goto out; goto out;
} }
...@@ -1652,7 +1649,7 @@ static int fixup_owner(u32 __user *uaddr, int fshared, struct futex_q *q, ...@@ -1652,7 +1649,7 @@ static int fixup_owner(u32 __user *uaddr, int fshared, struct futex_q *q,
* lock. Fix the state up. * lock. Fix the state up.
*/ */
owner = rt_mutex_owner(&q->pi_state->pi_mutex); owner = rt_mutex_owner(&q->pi_state->pi_mutex);
ret = fixup_pi_state_owner(uaddr, q, owner, fshared); ret = fixup_pi_state_owner(uaddr, q, owner);
goto out; goto out;
} }
...@@ -1772,7 +1769,7 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, int fshared, ...@@ -1772,7 +1769,7 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, int fshared,
if (!fshared) if (!fshared)
goto retry_private; goto retry_private;
put_futex_key(fshared, &q->key); put_futex_key(&q->key);
goto retry; goto retry;
} }
...@@ -1783,7 +1780,7 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, int fshared, ...@@ -1783,7 +1780,7 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, int fshared,
out: out:
if (ret) if (ret)
put_futex_key(fshared, &q->key); put_futex_key(&q->key);
return ret; return ret;
} }
...@@ -1941,7 +1938,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared, ...@@ -1941,7 +1938,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared,
* exit to complete. * exit to complete.
*/ */
queue_unlock(&q, hb); queue_unlock(&q, hb);
put_futex_key(fshared, &q.key); put_futex_key(&q.key);
cond_resched(); cond_resched();
goto retry; goto retry;
default: default:
...@@ -1971,7 +1968,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared, ...@@ -1971,7 +1968,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared,
* Fixup the pi_state owner and possibly acquire the lock if we * Fixup the pi_state owner and possibly acquire the lock if we
* haven't already. * haven't already.
*/ */
res = fixup_owner(uaddr, fshared, &q, !ret); res = fixup_owner(uaddr, &q, !ret);
/* /*
* If fixup_owner() returned an error, proprogate that. If it acquired * If fixup_owner() returned an error, proprogate that. If it acquired
* the lock, clear our -ETIMEDOUT or -EINTR. * the lock, clear our -ETIMEDOUT or -EINTR.
...@@ -1995,7 +1992,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared, ...@@ -1995,7 +1992,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared,
queue_unlock(&q, hb); queue_unlock(&q, hb);
out_put_key: out_put_key:
put_futex_key(fshared, &q.key); put_futex_key(&q.key);
out: out:
if (to) if (to)
destroy_hrtimer_on_stack(&to->timer); destroy_hrtimer_on_stack(&to->timer);
...@@ -2011,7 +2008,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared, ...@@ -2011,7 +2008,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared,
if (!fshared) if (!fshared)
goto retry_private; goto retry_private;
put_futex_key(fshared, &q.key); put_futex_key(&q.key);
goto retry; goto retry;
} }
...@@ -2093,14 +2090,14 @@ static int futex_unlock_pi(u32 __user *uaddr, int fshared) ...@@ -2093,14 +2090,14 @@ static int futex_unlock_pi(u32 __user *uaddr, int fshared)
out_unlock: out_unlock:
spin_unlock(&hb->lock); spin_unlock(&hb->lock);
put_futex_key(fshared, &key); put_futex_key(&key);
out: out:
return ret; return ret;
pi_faulted: pi_faulted:
spin_unlock(&hb->lock); spin_unlock(&hb->lock);
put_futex_key(fshared, &key); put_futex_key(&key);
ret = fault_in_user_writeable(uaddr); ret = fault_in_user_writeable(uaddr);
if (!ret) if (!ret)
...@@ -2273,8 +2270,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared, ...@@ -2273,8 +2270,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared,
*/ */
if (q.pi_state && (q.pi_state->owner != current)) { if (q.pi_state && (q.pi_state->owner != current)) {
spin_lock(q.lock_ptr); spin_lock(q.lock_ptr);
ret = fixup_pi_state_owner(uaddr2, &q, current, ret = fixup_pi_state_owner(uaddr2, &q, current);
fshared);
spin_unlock(q.lock_ptr); spin_unlock(q.lock_ptr);
} }
} else { } else {
...@@ -2293,7 +2289,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared, ...@@ -2293,7 +2289,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared,
* Fixup the pi_state owner and possibly acquire the lock if we * Fixup the pi_state owner and possibly acquire the lock if we
* haven't already. * haven't already.
*/ */
res = fixup_owner(uaddr2, fshared, &q, !ret); res = fixup_owner(uaddr2, &q, !ret);
/* /*
* If fixup_owner() returned an error, proprogate that. If it * If fixup_owner() returned an error, proprogate that. If it
* acquired the lock, clear -ETIMEDOUT or -EINTR. * acquired the lock, clear -ETIMEDOUT or -EINTR.
...@@ -2324,9 +2320,9 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared, ...@@ -2324,9 +2320,9 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared,
} }
out_put_keys: out_put_keys:
put_futex_key(fshared, &q.key); put_futex_key(&q.key);
out_key2: out_key2:
put_futex_key(fshared, &key2); put_futex_key(&key2);
out: out:
if (to) { if (to) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment