Skip to content

Commit 0ee3b6f

Browse files
qwrenH. Peter Anvin
authored andcommitted
x86: replace futex_atomic_cmpxchg_inatomic() with user_atomic_cmpxchg_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>
1 parent f09174c commit 0ee3b6f

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

arch/x86/include/asm/futex.h

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
110110
static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
111111
u32 oldval, u32 newval)
112112
{
113-
int ret = 0;
114-
115-
if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
116-
return -EFAULT;
117-
118-
asm volatile("\t" ASM_STAC "\n"
119-
"1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
120-
"2:\t" ASM_CLAC "\n"
121-
"\t.section .fixup, \"ax\"\n"
122-
"3:\tmov %3, %0\n"
123-
"\tjmp 2b\n"
124-
"\t.previous\n"
125-
_ASM_EXTABLE(1b, 3b)
126-
: "+r" (ret), "=a" (oldval), "+m" (*uaddr)
127-
: "i" (-EFAULT), "r" (newval), "1" (oldval)
128-
: "memory"
129-
);
130-
131-
*uval = oldval;
132-
return ret;
113+
return user_atomic_cmpxchg_inatomic(uval, uaddr, oldval, newval);
133114
}
134115

135116
#endif

0 commit comments

Comments
 (0)