提交 5ed59af8 编写于 作者: L Linus Torvalds

Merge branch 'core-locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull core/locking changes for v3.4 from Ingo Molnar

* 'core-locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  futex: Simplify return logic
  futex: Cover all PI opcodes with cmpxchg enabled check
...@@ -2628,7 +2628,7 @@ void exit_robust_list(struct task_struct *curr) ...@@ -2628,7 +2628,7 @@ void exit_robust_list(struct task_struct *curr)
long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
u32 __user *uaddr2, u32 val2, u32 val3) u32 __user *uaddr2, u32 val2, u32 val3)
{ {
int ret = -ENOSYS, cmd = op & FUTEX_CMD_MASK; int cmd = op & FUTEX_CMD_MASK;
unsigned int flags = 0; unsigned int flags = 0;
if (!(op & FUTEX_PRIVATE_FLAG)) if (!(op & FUTEX_PRIVATE_FLAG))
...@@ -2640,50 +2640,45 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, ...@@ -2640,50 +2640,45 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
return -ENOSYS; return -ENOSYS;
} }
switch (cmd) {
case FUTEX_LOCK_PI:
case FUTEX_UNLOCK_PI:
case FUTEX_TRYLOCK_PI:
case FUTEX_WAIT_REQUEUE_PI:
case FUTEX_CMP_REQUEUE_PI:
if (!futex_cmpxchg_enabled)
return -ENOSYS;
}
switch (cmd) { switch (cmd) {
case FUTEX_WAIT: case FUTEX_WAIT:
val3 = FUTEX_BITSET_MATCH_ANY; val3 = FUTEX_BITSET_MATCH_ANY;
case FUTEX_WAIT_BITSET: case FUTEX_WAIT_BITSET:
ret = futex_wait(uaddr, flags, val, timeout, val3); return futex_wait(uaddr, flags, val, timeout, val3);
break;
case FUTEX_WAKE: case FUTEX_WAKE:
val3 = FUTEX_BITSET_MATCH_ANY; val3 = FUTEX_BITSET_MATCH_ANY;
case FUTEX_WAKE_BITSET: case FUTEX_WAKE_BITSET:
ret = futex_wake(uaddr, flags, val, val3); return futex_wake(uaddr, flags, val, val3);
break;
case FUTEX_REQUEUE: case FUTEX_REQUEUE:
ret = futex_requeue(uaddr, flags, uaddr2, val, val2, NULL, 0); return futex_requeue(uaddr, flags, uaddr2, val, val2, NULL, 0);
break;
case FUTEX_CMP_REQUEUE: case FUTEX_CMP_REQUEUE:
ret = futex_requeue(uaddr, flags, uaddr2, val, val2, &val3, 0); return futex_requeue(uaddr, flags, uaddr2, val, val2, &val3, 0);
break;
case FUTEX_WAKE_OP: case FUTEX_WAKE_OP:
ret = futex_wake_op(uaddr, flags, uaddr2, val, val2, val3); return futex_wake_op(uaddr, flags, uaddr2, val, val2, val3);
break;
case FUTEX_LOCK_PI: case FUTEX_LOCK_PI:
if (futex_cmpxchg_enabled) return futex_lock_pi(uaddr, flags, val, timeout, 0);
ret = futex_lock_pi(uaddr, flags, val, timeout, 0);
break;
case FUTEX_UNLOCK_PI: case FUTEX_UNLOCK_PI:
if (futex_cmpxchg_enabled) return futex_unlock_pi(uaddr, flags);
ret = futex_unlock_pi(uaddr, flags);
break;
case FUTEX_TRYLOCK_PI: case FUTEX_TRYLOCK_PI:
if (futex_cmpxchg_enabled) return futex_lock_pi(uaddr, flags, 0, timeout, 1);
ret = futex_lock_pi(uaddr, flags, 0, timeout, 1);
break;
case FUTEX_WAIT_REQUEUE_PI: case FUTEX_WAIT_REQUEUE_PI:
val3 = FUTEX_BITSET_MATCH_ANY; val3 = FUTEX_BITSET_MATCH_ANY;
ret = futex_wait_requeue_pi(uaddr, flags, val, timeout, val3, return futex_wait_requeue_pi(uaddr, flags, val, timeout, val3,
uaddr2); uaddr2);
break;
case FUTEX_CMP_REQUEUE_PI: case FUTEX_CMP_REQUEUE_PI:
ret = futex_requeue(uaddr, flags, uaddr2, val, val2, &val3, 1); return futex_requeue(uaddr, flags, uaddr2, val, val2, &val3, 1);
break;
default:
ret = -ENOSYS;
} }
return ret; return -ENOSYS;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册