* [PATCH] x86: Get rid of __HAVE_ARCH_CMPXCHG
@ 2014-07-11 9:51 Borislav Petkov
2014-07-11 10:19 ` Geert Uytterhoeven
0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2014-07-11 9:51 UTC (permalink / raw)
To: Thomas Gleixner, Peter Zijlstra; +Cc: X86 ML, LKML
From: Borislav Petkov <bp@suse.de>
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 drop it and simpify a bit of code in doing that.
Signed-off-by: Borislav Petkov <bp@suse.de>
---
arch/x86/include/asm/cmpxchg.h | 2 --
arch/x86/include/asm/cmpxchg_32.h | 2 --
arch/x86/include/asm/cmpxchg_64.h | 2 --
arch/x86/include/asm/mc146818rtc.h | 2 +-
arch/x86/include/asm/mutex_32.h | 16 ++--------------
arch/x86/kernel/acpi/boot.c | 4 ----
kernel/locking/rtmutex.c | 2 +-
7 files changed, 4 insertions(+), 26 deletions(-)
diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
index d47786acb016..ad19841eddfe 100644
--- a/arch/x86/include/asm/cmpxchg.h
+++ b/arch/x86/include/asm/cmpxchg.h
@@ -143,7 +143,6 @@ extern void __add_wrong_size(void)
# include <asm/cmpxchg_64.h>
#endif
-#ifdef __HAVE_ARCH_CMPXCHG
#define cmpxchg(ptr, old, new) \
__cmpxchg(ptr, old, new, sizeof(*(ptr)))
@@ -152,7 +151,6 @@ extern void __add_wrong_size(void)
#define cmpxchg_local(ptr, old, new) \
__cmpxchg_local(ptr, old, new, sizeof(*(ptr)))
-#endif
/*
* xadd() adds "inc" to "*ptr" and atomically returns the previous
diff --git a/arch/x86/include/asm/cmpxchg_32.h b/arch/x86/include/asm/cmpxchg_32.h
index f8bf2eecab86..f7e142926481 100644
--- a/arch/x86/include/asm/cmpxchg_32.h
+++ b/arch/x86/include/asm/cmpxchg_32.h
@@ -34,8 +34,6 @@ static inline void set_64bit(volatile u64 *ptr, u64 value)
: "memory");
}
-#define __HAVE_ARCH_CMPXCHG 1
-
#ifdef CONFIG_X86_CMPXCHG64
#define cmpxchg64(ptr, o, n) \
((__typeof__(*(ptr)))__cmpxchg64((ptr), (unsigned long long)(o), \
diff --git a/arch/x86/include/asm/cmpxchg_64.h b/arch/x86/include/asm/cmpxchg_64.h
index 614be87f1a9b..1af94697aae5 100644
--- a/arch/x86/include/asm/cmpxchg_64.h
+++ b/arch/x86/include/asm/cmpxchg_64.h
@@ -6,8 +6,6 @@ static inline void set_64bit(volatile u64 *ptr, u64 val)
*ptr = val;
}
-#define __HAVE_ARCH_CMPXCHG 1
-
#define cmpxchg64(ptr, o, n) \
({ \
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
diff --git a/arch/x86/include/asm/mc146818rtc.h b/arch/x86/include/asm/mc146818rtc.h
index a55c7efcc4ed..0f555cc31984 100644
--- a/arch/x86/include/asm/mc146818rtc.h
+++ b/arch/x86/include/asm/mc146818rtc.h
@@ -13,7 +13,7 @@
#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */
#endif
-#if defined(CONFIG_X86_32) && defined(__HAVE_ARCH_CMPXCHG)
+#if defined(CONFIG_X86_32)
/*
* This lock provides nmi access to the CMOS/RTC registers. It has some
* special properties. It is owned by a CPU and stores the index register
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 */
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 86281ffb96d6..a531f6564ed0 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -74,10 +74,6 @@ int acpi_fix_pin2_polarity __initdata;
static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
#endif
-#ifndef __HAVE_ARCH_CMPXCHG
-#warning ACPI uses CMPXCHG, i486 and later hardware
-#endif
-
/* --------------------------------------------------------------------------
Boot-time Configuration
-------------------------------------------------------------------------- */
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index fc605941b9b8..28477b9ac6a9 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -73,7 +73,7 @@ static void fixup_rt_mutex_waiters(struct rt_mutex *lock)
* We can speed up the acquire/release, if the architecture
* supports cmpxchg and if there's no debugging state to be set up
*/
-#if defined(__HAVE_ARCH_CMPXCHG) && !defined(CONFIG_DEBUG_RT_MUTEXES)
+#ifndef CONFIG_DEBUG_RT_MUTEXES
# define rt_mutex_cmpxchg(l,c,n) (cmpxchg(&l->owner, c, n) == c)
static inline void mark_rt_mutex_waiters(struct rt_mutex *lock)
{
--
2.0.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] x86: Get rid of __HAVE_ARCH_CMPXCHG
2014-07-11 9:51 [PATCH] x86: Get rid of __HAVE_ARCH_CMPXCHG Borislav Petkov
@ 2014-07-11 10:19 ` Geert Uytterhoeven
2014-07-11 10:28 ` Borislav Petkov
0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2014-07-11 10:19 UTC (permalink / raw)
To: Borislav Petkov; +Cc: Thomas Gleixner, Peter Zijlstra, X86 ML, LKML
On Fri, Jul 11, 2014 at 11:51 AM, Borislav Petkov <bp@alien8.de> wrote:
> From: Borislav Petkov <bp@suse.de>
>
> 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 drop it and simpify a bit of code in doing that.
>
> Signed-off-by: Borislav Petkov <bp@suse.de>
> ---
> arch/x86/include/asm/cmpxchg.h | 2 --
> arch/x86/include/asm/cmpxchg_32.h | 2 --
> arch/x86/include/asm/cmpxchg_64.h | 2 --
> arch/x86/include/asm/mc146818rtc.h | 2 +-
> arch/x86/include/asm/mutex_32.h | 16 ++--------------
> arch/x86/kernel/acpi/boot.c | 4 ----
> kernel/locking/rtmutex.c | 2 +-
> 7 files changed, 4 insertions(+), 26 deletions(-)
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -73,7 +73,7 @@ static void fixup_rt_mutex_waiters(struct rt_mutex *lock)
> * We can speed up the acquire/release, if the architecture
> * supports cmpxchg and if there's no debugging state to be set up
> */
> -#if defined(__HAVE_ARCH_CMPXCHG) && !defined(CONFIG_DEBUG_RT_MUTEXES)
> +#ifndef CONFIG_DEBUG_RT_MUTEXES
> # define rt_mutex_cmpxchg(l,c,n) (cmpxchg(&l->owner, c, n) == c)
> static inline void mark_rt_mutex_waiters(struct rt_mutex *lock)
> {
What about non-x86? __HAVE_ARCH_CMPXCHG isn't always defined.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] x86: Get rid of __HAVE_ARCH_CMPXCHG
2014-07-11 10:19 ` Geert Uytterhoeven
@ 2014-07-11 10:28 ` Borislav Petkov
2014-07-11 10:35 ` Geert Uytterhoeven
0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2014-07-11 10:28 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Thomas Gleixner, Peter Zijlstra, X86 ML, LKML
On Fri, Jul 11, 2014 at 12:19:43PM +0200, Geert Uytterhoeven wrote:
> What about non-x86? __HAVE_ARCH_CMPXCHG isn't always defined.
Bah, this hunk was definitely not supposed to be there. Thanks for the
catch!
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] x86: Get rid of __HAVE_ARCH_CMPXCHG
2014-07-11 10:28 ` Borislav Petkov
@ 2014-07-11 10:35 ` Geert Uytterhoeven
2014-07-11 10:43 ` Borislav Petkov
0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2014-07-11 10:35 UTC (permalink / raw)
To: Borislav Petkov; +Cc: Thomas Gleixner, Peter Zijlstra, X86 ML, LKML
On Fri, Jul 11, 2014 at 12:28 PM, Borislav Petkov <bp@alien8.de> wrote:
> On Fri, Jul 11, 2014 at 12:19:43PM +0200, Geert Uytterhoeven wrote:
>> What about non-x86? __HAVE_ARCH_CMPXCHG isn't always defined.
>
> Bah, this hunk was definitely not supposed to be there. Thanks for the
> catch!
IC.
In that case you also want to add a (new) "#define __HAVE_ARCH_CMPXCHG 1"
to one of the shared x86 header files, right?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] x86: Get rid of __HAVE_ARCH_CMPXCHG
2014-07-11 10:35 ` Geert Uytterhoeven
@ 2014-07-11 10:43 ` Borislav Petkov
2014-07-12 0:30 ` [tip:x86/cleanups] x86: Simplify __HAVE_ARCH_CMPXCHG tests tip-bot for Borislav Petkov
0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2014-07-11 10:43 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Thomas Gleixner, Peter Zijlstra, X86 ML, LKML
On Fri, Jul 11, 2014 at 12:35:43PM +0200, Geert Uytterhoeven wrote:
> In that case you also want to add a (new) "#define __HAVE_ARCH_CMPXCHG
> 1" to one of the shared x86 header files, right?
Yeah, I can't remove it after all. :-)
Diffstat is arch/x86/-only now, as it was supposed to be.
--
From: Borislav Petkov <bp@suse.de>
Subject: [PATCH] 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>
---
arch/x86/include/asm/cmpxchg.h | 4 ++--
arch/x86/include/asm/cmpxchg_32.h | 2 --
arch/x86/include/asm/cmpxchg_64.h | 2 --
arch/x86/include/asm/mc146818rtc.h | 2 +-
arch/x86/include/asm/mutex_32.h | 16 ++--------------
arch/x86/kernel/acpi/boot.c | 4 ----
6 files changed, 5 insertions(+), 25 deletions(-)
diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
index d47786acb016..99c105d78b7e 100644
--- a/arch/x86/include/asm/cmpxchg.h
+++ b/arch/x86/include/asm/cmpxchg.h
@@ -4,6 +4,8 @@
#include <linux/compiler.h>
#include <asm/alternative.h> /* Provides LOCK_PREFIX */
+#define __HAVE_ARCH_CMPXCHG 1
+
/*
* Non-existant functions to indicate usage errors at link time
* (or compile-time if the compiler implements __compiletime_error().
@@ -143,7 +145,6 @@ extern void __add_wrong_size(void)
# include <asm/cmpxchg_64.h>
#endif
-#ifdef __HAVE_ARCH_CMPXCHG
#define cmpxchg(ptr, old, new) \
__cmpxchg(ptr, old, new, sizeof(*(ptr)))
@@ -152,7 +153,6 @@ extern void __add_wrong_size(void)
#define cmpxchg_local(ptr, old, new) \
__cmpxchg_local(ptr, old, new, sizeof(*(ptr)))
-#endif
/*
* xadd() adds "inc" to "*ptr" and atomically returns the previous
diff --git a/arch/x86/include/asm/cmpxchg_32.h b/arch/x86/include/asm/cmpxchg_32.h
index f8bf2eecab86..f7e142926481 100644
--- a/arch/x86/include/asm/cmpxchg_32.h
+++ b/arch/x86/include/asm/cmpxchg_32.h
@@ -34,8 +34,6 @@ static inline void set_64bit(volatile u64 *ptr, u64 value)
: "memory");
}
-#define __HAVE_ARCH_CMPXCHG 1
-
#ifdef CONFIG_X86_CMPXCHG64
#define cmpxchg64(ptr, o, n) \
((__typeof__(*(ptr)))__cmpxchg64((ptr), (unsigned long long)(o), \
diff --git a/arch/x86/include/asm/cmpxchg_64.h b/arch/x86/include/asm/cmpxchg_64.h
index 614be87f1a9b..1af94697aae5 100644
--- a/arch/x86/include/asm/cmpxchg_64.h
+++ b/arch/x86/include/asm/cmpxchg_64.h
@@ -6,8 +6,6 @@ static inline void set_64bit(volatile u64 *ptr, u64 val)
*ptr = val;
}
-#define __HAVE_ARCH_CMPXCHG 1
-
#define cmpxchg64(ptr, o, n) \
({ \
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
diff --git a/arch/x86/include/asm/mc146818rtc.h b/arch/x86/include/asm/mc146818rtc.h
index a55c7efcc4ed..0f555cc31984 100644
--- a/arch/x86/include/asm/mc146818rtc.h
+++ b/arch/x86/include/asm/mc146818rtc.h
@@ -13,7 +13,7 @@
#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */
#endif
-#if defined(CONFIG_X86_32) && defined(__HAVE_ARCH_CMPXCHG)
+#if defined(CONFIG_X86_32)
/*
* This lock provides nmi access to the CMOS/RTC registers. It has some
* special properties. It is owned by a CPU and stores the index register
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 */
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 86281ffb96d6..a531f6564ed0 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -74,10 +74,6 @@ int acpi_fix_pin2_polarity __initdata;
static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
#endif
-#ifndef __HAVE_ARCH_CMPXCHG
-#warning ACPI uses CMPXCHG, i486 and later hardware
-#endif
-
/* --------------------------------------------------------------------------
Boot-time Configuration
-------------------------------------------------------------------------- */
--
2.0.0
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply related [flat|nested] 6+ messages in thread* [tip:x86/cleanups] x86: Simplify __HAVE_ARCH_CMPXCHG tests
2014-07-11 10:43 ` Borislav Petkov
@ 2014-07-12 0:30 ` tip-bot for Borislav Petkov
0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Borislav Petkov @ 2014-07-12 0:30 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, tglx, hpa, bp
Commit-ID: b08ee5f7e4135d64b8edd769367f8964a725122e
Gitweb: http://git.kernel.org/tip/b08ee5f7e4135d64b8edd769367f8964a725122e
Author: Borislav Petkov <bp@suse.de>
AuthorDate: Fri, 11 Jul 2014 12:43:38 +0200
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 11 Jul 2014 17:28:51 -0700
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>
---
arch/x86/include/asm/cmpxchg.h | 4 ++--
arch/x86/include/asm/cmpxchg_32.h | 2 --
arch/x86/include/asm/cmpxchg_64.h | 2 --
arch/x86/include/asm/mc146818rtc.h | 2 +-
arch/x86/include/asm/mutex_32.h | 16 ++--------------
arch/x86/kernel/acpi/boot.c | 4 ----
6 files changed, 5 insertions(+), 25 deletions(-)
diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
index d47786a..99c105d7 100644
--- a/arch/x86/include/asm/cmpxchg.h
+++ b/arch/x86/include/asm/cmpxchg.h
@@ -4,6 +4,8 @@
#include <linux/compiler.h>
#include <asm/alternative.h> /* Provides LOCK_PREFIX */
+#define __HAVE_ARCH_CMPXCHG 1
+
/*
* Non-existant functions to indicate usage errors at link time
* (or compile-time if the compiler implements __compiletime_error().
@@ -143,7 +145,6 @@ extern void __add_wrong_size(void)
# include <asm/cmpxchg_64.h>
#endif
-#ifdef __HAVE_ARCH_CMPXCHG
#define cmpxchg(ptr, old, new) \
__cmpxchg(ptr, old, new, sizeof(*(ptr)))
@@ -152,7 +153,6 @@ extern void __add_wrong_size(void)
#define cmpxchg_local(ptr, old, new) \
__cmpxchg_local(ptr, old, new, sizeof(*(ptr)))
-#endif
/*
* xadd() adds "inc" to "*ptr" and atomically returns the previous
diff --git a/arch/x86/include/asm/cmpxchg_32.h b/arch/x86/include/asm/cmpxchg_32.h
index f8bf2ee..f7e1429 100644
--- a/arch/x86/include/asm/cmpxchg_32.h
+++ b/arch/x86/include/asm/cmpxchg_32.h
@@ -34,8 +34,6 @@ static inline void set_64bit(volatile u64 *ptr, u64 value)
: "memory");
}
-#define __HAVE_ARCH_CMPXCHG 1
-
#ifdef CONFIG_X86_CMPXCHG64
#define cmpxchg64(ptr, o, n) \
((__typeof__(*(ptr)))__cmpxchg64((ptr), (unsigned long long)(o), \
diff --git a/arch/x86/include/asm/cmpxchg_64.h b/arch/x86/include/asm/cmpxchg_64.h
index 614be87..1af9469 100644
--- a/arch/x86/include/asm/cmpxchg_64.h
+++ b/arch/x86/include/asm/cmpxchg_64.h
@@ -6,8 +6,6 @@ static inline void set_64bit(volatile u64 *ptr, u64 val)
*ptr = val;
}
-#define __HAVE_ARCH_CMPXCHG 1
-
#define cmpxchg64(ptr, o, n) \
({ \
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
diff --git a/arch/x86/include/asm/mc146818rtc.h b/arch/x86/include/asm/mc146818rtc.h
index a55c7ef..0f555cc 100644
--- a/arch/x86/include/asm/mc146818rtc.h
+++ b/arch/x86/include/asm/mc146818rtc.h
@@ -13,7 +13,7 @@
#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */
#endif
-#if defined(CONFIG_X86_32) && defined(__HAVE_ARCH_CMPXCHG)
+#if defined(CONFIG_X86_32)
/*
* This lock provides nmi access to the CMOS/RTC registers. It has some
* special properties. It is owned by a CPU and stores the index register
diff --git a/arch/x86/include/asm/mutex_32.h b/arch/x86/include/asm/mutex_32.h
index 0208c3c..85e6cda 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 */
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 86281ff..a531f65 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -74,10 +74,6 @@ int acpi_fix_pin2_polarity __initdata;
static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
#endif
-#ifndef __HAVE_ARCH_CMPXCHG
-#warning ACPI uses CMPXCHG, i486 and later hardware
-#endif
-
/* --------------------------------------------------------------------------
Boot-time Configuration
-------------------------------------------------------------------------- */
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-07-12 0:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-11 9:51 [PATCH] x86: Get rid of __HAVE_ARCH_CMPXCHG Borislav Petkov
2014-07-11 10:19 ` Geert Uytterhoeven
2014-07-11 10:28 ` Borislav Petkov
2014-07-11 10:35 ` Geert Uytterhoeven
2014-07-11 10:43 ` Borislav Petkov
2014-07-12 0:30 ` [tip:x86/cleanups] x86: Simplify __HAVE_ARCH_CMPXCHG tests tip-bot for Borislav Petkov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.