Skip to content

Commit

Permalink
futex: Cleanup stale fshared flag interfaces
Browse files Browse the repository at this point in the history
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: Thomas Gleixner <[email protected]>
Cc: Darren Hart <[email protected]>
LKML-Reference: <[email protected]>
  • Loading branch information
KAGA-KOKO committed Nov 10, 2010
1 parent 4c115e9 commit ae791a2
Showing 1 changed file with 30 additions and 34 deletions.
64 changes: 30 additions & 34 deletions kernel/futex.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key)
return 0;
}

static inline
void put_futex_key(int fshared, union futex_key *key)
static inline void put_futex_key(union futex_key *key)
{
drop_futex_key_refs(key);
}
Expand Down Expand Up @@ -907,7 +906,7 @@ static int futex_wake(u32 __user *uaddr, int fshared, int nr_wake, u32 bitset)
}

spin_unlock(&hb->lock);
put_futex_key(fshared, &key);
put_futex_key(&key);
out:
return ret;
}
Expand Down Expand Up @@ -965,8 +964,8 @@ futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
if (!fshared)
goto retry_private;

put_futex_key(fshared, &key2);
put_futex_key(fshared, &key1);
put_futex_key(&key2);
put_futex_key(&key1);
goto retry;
}

Expand Down Expand Up @@ -996,9 +995,9 @@ futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,

double_unlock_hb(hb1, hb2);
out_put_keys:
put_futex_key(fshared, &key2);
put_futex_key(&key2);
out_put_key1:
put_futex_key(fshared, &key1);
put_futex_key(&key1);
out:
return ret;
}
Expand Down Expand Up @@ -1219,8 +1218,8 @@ static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
if (!fshared)
goto retry_private;

put_futex_key(fshared, &key2);
put_futex_key(fshared, &key1);
put_futex_key(&key2);
put_futex_key(&key1);
goto retry;
}
if (curval != *cmpval) {
Expand Down Expand Up @@ -1260,17 +1259,17 @@ static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
break;
case -EFAULT:
double_unlock_hb(hb1, hb2);
put_futex_key(fshared, &key2);
put_futex_key(fshared, &key1);
put_futex_key(&key2);
put_futex_key(&key1);
ret = fault_in_user_writeable(uaddr2);
if (!ret)
goto retry;
goto out;
case -EAGAIN:
/* The owner was exiting, try again. */
double_unlock_hb(hb1, hb2);
put_futex_key(fshared, &key2);
put_futex_key(fshared, &key1);
put_futex_key(&key2);
put_futex_key(&key1);
cond_resched();
goto retry;
default:
Expand Down Expand Up @@ -1352,9 +1351,9 @@ static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
drop_futex_key_refs(&key1);

out_put_keys:
put_futex_key(fshared, &key2);
put_futex_key(&key2);
out_put_key1:
put_futex_key(fshared, &key1);
put_futex_key(&key1);
out:
if (pi_state != NULL)
free_pi_state(pi_state);
Expand Down Expand Up @@ -1494,7 +1493,7 @@ static void unqueue_me_pi(struct futex_q *q)
* private futexes.
*/
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;
struct futex_pi_state *pi_state = q->pi_state;
Expand Down Expand Up @@ -1600,7 +1599,6 @@ static long futex_wait_restart(struct restart_block *restart);
/**
* fixup_owner() - Post lock pi_state and corner case management
* @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)
* @locked: if the attempt to take the rt_mutex succeeded (1) or not (0)
*
Expand All @@ -1613,8 +1611,7 @@ static long futex_wait_restart(struct restart_block *restart);
* 0 - success, lock not taken
* <0 - on error (-EFAULT)
*/
static int fixup_owner(u32 __user *uaddr, int fshared, struct futex_q *q,
int locked)
static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked)
{
struct task_struct *owner;
int ret = 0;
Expand All @@ -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:
*/
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;
}

Expand All @@ -1652,7 +1649,7 @@ static int fixup_owner(u32 __user *uaddr, int fshared, struct futex_q *q,
* lock. Fix the state up.
*/
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;
}

Expand Down Expand Up @@ -1772,7 +1769,7 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, int fshared,
if (!fshared)
goto retry_private;

put_futex_key(fshared, &q->key);
put_futex_key(&q->key);
goto retry;
}

Expand All @@ -1783,7 +1780,7 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, int fshared,

out:
if (ret)
put_futex_key(fshared, &q->key);
put_futex_key(&q->key);
return ret;
}

Expand Down Expand Up @@ -1941,7 +1938,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared,
* exit to complete.
*/
queue_unlock(&q, hb);
put_futex_key(fshared, &q.key);
put_futex_key(&q.key);
cond_resched();
goto retry;
default:
Expand Down Expand Up @@ -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
* 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
* the lock, clear our -ETIMEDOUT or -EINTR.
Expand All @@ -1995,7 +1992,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared,
queue_unlock(&q, hb);

out_put_key:
put_futex_key(fshared, &q.key);
put_futex_key(&q.key);
out:
if (to)
destroy_hrtimer_on_stack(&to->timer);
Expand All @@ -2011,7 +2008,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared,
if (!fshared)
goto retry_private;

put_futex_key(fshared, &q.key);
put_futex_key(&q.key);
goto retry;
}

Expand Down Expand Up @@ -2093,14 +2090,14 @@ static int futex_unlock_pi(u32 __user *uaddr, int fshared)

out_unlock:
spin_unlock(&hb->lock);
put_futex_key(fshared, &key);
put_futex_key(&key);

out:
return ret;

pi_faulted:
spin_unlock(&hb->lock);
put_futex_key(fshared, &key);
put_futex_key(&key);

ret = fault_in_user_writeable(uaddr);
if (!ret)
Expand Down Expand Up @@ -2273,8 +2270,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared,
*/
if (q.pi_state && (q.pi_state->owner != current)) {
spin_lock(q.lock_ptr);
ret = fixup_pi_state_owner(uaddr2, &q, current,
fshared);
ret = fixup_pi_state_owner(uaddr2, &q, current);
spin_unlock(q.lock_ptr);
}
} else {
Expand All @@ -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
* 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
* acquired the lock, clear -ETIMEDOUT or -EINTR.
Expand Down Expand Up @@ -2324,9 +2320,9 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared,
}

out_put_keys:
put_futex_key(fshared, &q.key);
put_futex_key(&q.key);
out_key2:
put_futex_key(fshared, &key2);
put_futex_key(&key2);

out:
if (to) {
Expand Down

0 comments on commit ae791a2

Please sign in to comment.