summaryrefslogtreecommitdiff
path: root/arch/x86/include/asm/mutex_32.h
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2014-07-11 14:43:38 +0400
committerH. Peter Anvin <hpa@linux.intel.com>2014-07-12 04:28:51 +0400
commitb08ee5f7e4135d64b8edd769367f8964a725122e (patch)
treec23c93542548c4ef5da24ed60d3c5dc038b3b607 /arch/x86/include/asm/mutex_32.h
parent891715793f0451e5114d200be932ac14ce8521a3 (diff)
downloadlinux-b08ee5f7e4135d64b8edd769367f8964a725122e.tar.xz
x86: Simplify __HAVE_ARCH_CMPXCHG tests
Both the 32-bit and 64-bit cmpxchg.h header define __HAVE_ARCH_CMPXCHG and there's ifdeffery which checks it. But since both bitness define it, we can just as well move it up to the main cmpxchg header and simpify a bit of code in doing that. Signed-off-by: Borislav Petkov <bp@suse.de> Link: http://lkml.kernel.org/r/20140711104338.GB17083@pd.tnic Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/include/asm/mutex_32.h')
-rw-r--r--arch/x86/include/asm/mutex_32.h16
1 files changed, 2 insertions, 14 deletions
diff --git a/arch/x86/include/asm/mutex_32.h b/arch/x86/include/asm/mutex_32.h
index 0208c3c2cbc6..85e6cda45a02 100644
--- a/arch/x86/include/asm/mutex_32.h
+++ b/arch/x86/include/asm/mutex_32.h
@@ -100,23 +100,11 @@ do { \
static inline int __mutex_fastpath_trylock(atomic_t *count,
int (*fail_fn)(atomic_t *))
{
- /*
- * We have two variants here. The cmpxchg based one is the best one
- * because it never induce a false contention state. It is included
- * here because architectures using the inc/dec algorithms over the
- * xchg ones are much more likely to support cmpxchg natively.
- *
- * If not we fall back to the spinlock based variant - that is
- * just as efficient (and simpler) as a 'destructive' probing of
- * the mutex state would be.
- */
-#ifdef __HAVE_ARCH_CMPXCHG
+ /* cmpxchg because it never induces a false contention state. */
if (likely(atomic_cmpxchg(count, 1, 0) == 1))
return 1;
+
return 0;
-#else
- return fail_fn(count);
-#endif
}
#endif /* _ASM_X86_MUTEX_32_H */