提交 c2f9f201 编写于 作者: P Peter Zijlstra 提交者: Ingo Molnar

futex: cleanup fshared

fshared doesn't need to be a rw_sem pointer anymore, so clean that up.
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: NNick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 734b05b1
...@@ -200,8 +200,7 @@ static void drop_futex_key_refs(union futex_key *key) ...@@ -200,8 +200,7 @@ static void drop_futex_key_refs(union futex_key *key)
* For other futexes, it points to &current->mm->mmap_sem and * For other futexes, it points to &current->mm->mmap_sem and
* caller must have taken the reader lock. but NOT any spinlocks. * caller must have taken the reader lock. but NOT any spinlocks.
*/ */
static int get_futex_key(u32 __user *uaddr, struct rw_semaphore *fshared, static int get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key)
union futex_key *key)
{ {
unsigned long address = (unsigned long)uaddr; unsigned long address = (unsigned long)uaddr;
struct mm_struct *mm = current->mm; struct mm_struct *mm = current->mm;
...@@ -268,7 +267,7 @@ static int get_futex_key(u32 __user *uaddr, struct rw_semaphore *fshared, ...@@ -268,7 +267,7 @@ static int get_futex_key(u32 __user *uaddr, struct rw_semaphore *fshared,
} }
static inline static inline
void put_futex_key(struct rw_semaphore *fshared, union futex_key *key) void put_futex_key(int fshared, union futex_key *key)
{ {
drop_futex_key_refs(key); drop_futex_key_refs(key);
} }
...@@ -297,10 +296,8 @@ static int get_futex_value_locked(u32 *dest, u32 __user *from) ...@@ -297,10 +296,8 @@ static int get_futex_value_locked(u32 *dest, u32 __user *from)
/* /*
* Fault handling. * Fault handling.
* if fshared is non NULL, current->mm->mmap_sem is already held
*/ */
static int futex_handle_fault(unsigned long address, static int futex_handle_fault(unsigned long address, int attempt)
struct rw_semaphore *fshared, int attempt)
{ {
struct vm_area_struct * vma; struct vm_area_struct * vma;
struct mm_struct *mm = current->mm; struct mm_struct *mm = current->mm;
...@@ -687,8 +684,7 @@ double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2) ...@@ -687,8 +684,7 @@ double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
* Wake up all waiters hashed on the physical page that is mapped * Wake up all waiters hashed on the physical page that is mapped
* to this virtual address: * to this virtual address:
*/ */
static int futex_wake(u32 __user *uaddr, struct rw_semaphore *fshared, static int futex_wake(u32 __user *uaddr, int fshared, int nr_wake, u32 bitset)
int nr_wake, u32 bitset)
{ {
struct futex_hash_bucket *hb; struct futex_hash_bucket *hb;
struct futex_q *this, *next; struct futex_q *this, *next;
...@@ -735,8 +731,7 @@ static int futex_wake(u32 __user *uaddr, struct rw_semaphore *fshared, ...@@ -735,8 +731,7 @@ static int futex_wake(u32 __user *uaddr, struct rw_semaphore *fshared,
* to this virtual address: * to this virtual address:
*/ */
static int static int
futex_wake_op(u32 __user *uaddr1, struct rw_semaphore *fshared, futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
u32 __user *uaddr2,
int nr_wake, int nr_wake2, int op) int nr_wake, int nr_wake2, int op)
{ {
union futex_key key1 = FUTEX_KEY_INIT, key2 = FUTEX_KEY_INIT; union futex_key key1 = FUTEX_KEY_INIT, key2 = FUTEX_KEY_INIT;
...@@ -790,7 +785,7 @@ futex_wake_op(u32 __user *uaddr1, struct rw_semaphore *fshared, ...@@ -790,7 +785,7 @@ futex_wake_op(u32 __user *uaddr1, struct rw_semaphore *fshared,
*/ */
if (attempt++) { if (attempt++) {
ret = futex_handle_fault((unsigned long)uaddr2, ret = futex_handle_fault((unsigned long)uaddr2,
fshared, attempt); attempt);
if (ret) if (ret)
goto out; goto out;
goto retry; goto retry;
...@@ -841,8 +836,7 @@ futex_wake_op(u32 __user *uaddr1, struct rw_semaphore *fshared, ...@@ -841,8 +836,7 @@ futex_wake_op(u32 __user *uaddr1, struct rw_semaphore *fshared,
* Requeue all waiters hashed on one physical page to another * Requeue all waiters hashed on one physical page to another
* physical page. * physical page.
*/ */
static int futex_requeue(u32 __user *uaddr1, struct rw_semaphore *fshared, static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
u32 __user *uaddr2,
int nr_wake, int nr_requeue, u32 *cmpval) int nr_wake, int nr_requeue, u32 *cmpval)
{ {
union futex_key key1 = FUTEX_KEY_INIT, key2 = FUTEX_KEY_INIT; union futex_key key1 = FUTEX_KEY_INIT, key2 = FUTEX_KEY_INIT;
...@@ -1048,8 +1042,7 @@ static void unqueue_me_pi(struct futex_q *q) ...@@ -1048,8 +1042,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, struct task_struct *newowner, int fshared)
struct rw_semaphore *fshared)
{ {
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;
...@@ -1128,7 +1121,7 @@ static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, ...@@ -1128,7 +1121,7 @@ static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
handle_fault: handle_fault:
spin_unlock(q->lock_ptr); spin_unlock(q->lock_ptr);
ret = futex_handle_fault((unsigned long)uaddr, fshared, attempt++); ret = futex_handle_fault((unsigned long)uaddr, attempt++);
spin_lock(q->lock_ptr); spin_lock(q->lock_ptr);
...@@ -1152,7 +1145,7 @@ static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, ...@@ -1152,7 +1145,7 @@ static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
static long futex_wait_restart(struct restart_block *restart); static long futex_wait_restart(struct restart_block *restart);
static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared, static int futex_wait(u32 __user *uaddr, int fshared,
u32 val, ktime_t *abs_time, u32 bitset) u32 val, ktime_t *abs_time, u32 bitset)
{ {
struct task_struct *curr = current; struct task_struct *curr = current;
...@@ -1307,13 +1300,13 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared, ...@@ -1307,13 +1300,13 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared,
static long futex_wait_restart(struct restart_block *restart) static long futex_wait_restart(struct restart_block *restart)
{ {
u32 __user *uaddr = (u32 __user *)restart->futex.uaddr; u32 __user *uaddr = (u32 __user *)restart->futex.uaddr;
struct rw_semaphore *fshared = NULL; int fshared = 0;
ktime_t t; ktime_t t;
t.tv64 = restart->futex.time; t.tv64 = restart->futex.time;
restart->fn = do_no_restart_syscall; restart->fn = do_no_restart_syscall;
if (restart->futex.flags & FLAGS_SHARED) if (restart->futex.flags & FLAGS_SHARED)
fshared = &current->mm->mmap_sem; fshared = 1;
return (long)futex_wait(uaddr, fshared, restart->futex.val, &t, return (long)futex_wait(uaddr, fshared, restart->futex.val, &t,
restart->futex.bitset); restart->futex.bitset);
} }
...@@ -1325,7 +1318,7 @@ static long futex_wait_restart(struct restart_block *restart) ...@@ -1325,7 +1318,7 @@ static long futex_wait_restart(struct restart_block *restart)
* if there are waiters then it will block, it does PI, etc. (Due to * if there are waiters then it will block, it does PI, etc. (Due to
* races the kernel might see a 0 value of the futex too.) * races the kernel might see a 0 value of the futex too.)
*/ */
static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, static int futex_lock_pi(u32 __user *uaddr, int fshared,
int detect, ktime_t *time, int trylock) int detect, ktime_t *time, int trylock)
{ {
struct hrtimer_sleeper timeout, *to = NULL; struct hrtimer_sleeper timeout, *to = NULL;
...@@ -1571,8 +1564,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, ...@@ -1571,8 +1564,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
queue_unlock(&q, hb); queue_unlock(&q, hb);
if (attempt++) { if (attempt++) {
ret = futex_handle_fault((unsigned long)uaddr, fshared, ret = futex_handle_fault((unsigned long)uaddr, attempt);
attempt);
if (ret) if (ret)
goto out_release_sem; goto out_release_sem;
goto retry_unlocked; goto retry_unlocked;
...@@ -1592,7 +1584,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, ...@@ -1592,7 +1584,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
* This is the in-kernel slowpath: we look up the PI state (if any), * This is the in-kernel slowpath: we look up the PI state (if any),
* and do the rt-mutex unlock. * and do the rt-mutex unlock.
*/ */
static int futex_unlock_pi(u32 __user *uaddr, struct rw_semaphore *fshared) static int futex_unlock_pi(u32 __user *uaddr, int fshared)
{ {
struct futex_hash_bucket *hb; struct futex_hash_bucket *hb;
struct futex_q *this, *next; struct futex_q *this, *next;
...@@ -1683,8 +1675,7 @@ static int futex_unlock_pi(u32 __user *uaddr, struct rw_semaphore *fshared) ...@@ -1683,8 +1675,7 @@ static int futex_unlock_pi(u32 __user *uaddr, struct rw_semaphore *fshared)
spin_unlock(&hb->lock); spin_unlock(&hb->lock);
if (attempt++) { if (attempt++) {
ret = futex_handle_fault((unsigned long)uaddr, fshared, ret = futex_handle_fault((unsigned long)uaddr, attempt);
attempt);
if (ret) if (ret)
goto out; goto out;
uval = 0; uval = 0;
...@@ -1816,8 +1807,7 @@ int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi) ...@@ -1816,8 +1807,7 @@ int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi)
* PI futexes happens in exit_pi_state(): * PI futexes happens in exit_pi_state():
*/ */
if (!pi && (uval & FUTEX_WAITERS)) if (!pi && (uval & FUTEX_WAITERS))
futex_wake(uaddr, &curr->mm->mmap_sem, 1, futex_wake(uaddr, 1, 1, FUTEX_BITSET_MATCH_ANY);
FUTEX_BITSET_MATCH_ANY);
} }
return 0; return 0;
} }
...@@ -1913,10 +1903,10 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, ...@@ -1913,10 +1903,10 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
{ {
int ret = -ENOSYS; int ret = -ENOSYS;
int cmd = op & FUTEX_CMD_MASK; int cmd = op & FUTEX_CMD_MASK;
struct rw_semaphore *fshared = NULL; int fshared = 0;
if (!(op & FUTEX_PRIVATE_FLAG)) if (!(op & FUTEX_PRIVATE_FLAG))
fshared = &current->mm->mmap_sem; fshared = 1;
switch (cmd) { switch (cmd) {
case FUTEX_WAIT: case FUTEX_WAIT:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册