Skip to content

Commit

Permalink
x86: replace futex_atomic_cmpxchg_inatomic() with user_atomic_cmpxchg…
Browse files Browse the repository at this point in the history
…_inatomic

futex_atomic_cmpxchg_inatomic() is simply the 32-bit implementation of
user_atomic_cmpxchg_inatomic(), which in turn is simply a
generalization of the original code in
futex_atomic_cmpxchg_inatomic().

Use the newly generalized user_atomic_cmpxchg_inatomic() as the futex
implementation, too.

[ hpa: retain the inline in futex.h rather than changing it to a macro ]

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Link: http://lkml.kernel.org/r/1387002303-6620-2-git-send-email-qiaowei.ren@intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
  • Loading branch information
Qiaowei Ren authored and H. Peter Anvin committed Dec 16, 2013
1 parent f09174c commit 0ee3b6f
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions arch/x86/include/asm/futex.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
u32 oldval, u32 newval)
{
int ret = 0;

if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
return -EFAULT;

asm volatile("\t" ASM_STAC "\n"
"1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
"2:\t" ASM_CLAC "\n"
"\t.section .fixup, \"ax\"\n"
"3:\tmov %3, %0\n"
"\tjmp 2b\n"
"\t.previous\n"
_ASM_EXTABLE(1b, 3b)
: "+r" (ret), "=a" (oldval), "+m" (*uaddr)
: "i" (-EFAULT), "r" (newval), "1" (oldval)
: "memory"
);

*uval = oldval;
return ret;
return user_atomic_cmpxchg_inatomic(uval, uaddr, oldval, newval);
}

#endif
Expand Down

0 comments on commit 0ee3b6f

Please sign in to comment.