* __HAVE_ARCH_CMPXCHG on ARM?
@ 2015-01-29 18:56 ` Nathan Sullivan
0 siblings, 0 replies; 16+ messages in thread
From: Nathan Sullivan @ 2015-01-29 18:56 UTC (permalink / raw)
To: yong.zhang; +Cc: yong.zhang0, will.deacon, linux-arm-kernel, linux-rt-users
While investigating a performance issue on RT 3.14, I noticed that
__HAVE_ARCH_CMPXCHG is not defined for ARM. This causes -rt locks to
always use the slow path and impacts performance. ARMv6 and above
have a cmpxchg implementation already that will work just fine.
In 2012, Yong Zhang submitted a patch to fix this[1], but it mysteriously
disappeared afterwards. I did notice that the s-o-b line has a different
email address than the windriver one. Yong, do you mind re-submitting the
patch with a fixed s-o-b?
Thanks!
Nathan Sullivan
[1]: http://lists.infradead.org/pipermail/linux-arm-kernel/2012-May/102122.html (duplicated below)
-- 8< --
From: Yong Zhang <yong.zhang at windriver.com>
Both pi_stress and sigwaittest in rt-test show performance gain with
__HAVE_ARCH_CMPXCHG. Testing result on coretile_express_a9x4:
pi_stress -p 99 --duration=300 (on linux-3.4-rc5; bigger is better)
vanilla: Total inversion performed: 5493381
patched: Total inversion performed: 5621746
sigwaittest -p 99 -l 100000 (on linux-3.4-rc5-rt6; less is better)
3.4-rc5-rt6: Min 24, Cur 27, Avg 30, Max 98
patched: Min 19, Cur 21, Avg 23, Max 96
Signed-off-by: Yong Zhang <yong.zhang0 at gmail.com>
Cc: Russell King <rmk+kernel at arm.linux.org.uk>
Cc: Nicolas Pitre <nico at linaro.org>
Cc: Will Deacon <will.deacon at arm.com>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Thomas Gleixner <tglx at linutronix.de>
Cc: linux-arm-kernel at lists.infradead.org
---
arch/arm/include/asm/cmpxchg.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
index 7eb18c1..a91b44e 100644
--- a/arch/arm/include/asm/cmpxchg.h
+++ b/arch/arm/include/asm/cmpxchg.h
@@ -127,6 +127,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
#else /* min ARCH >= ARMv6 */
+#define __HAVE_ARCH_CMPXCHG 1
+
extern void __bad_cmpxchg(volatile void *ptr, int size);
/*
--
1.7.5.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* __HAVE_ARCH_CMPXCHG on ARM?
@ 2015-01-29 18:56 ` Nathan Sullivan
0 siblings, 0 replies; 16+ messages in thread
From: Nathan Sullivan @ 2015-01-29 18:56 UTC (permalink / raw)
To: linux-arm-kernel
While investigating a performance issue on RT 3.14, I noticed that
__HAVE_ARCH_CMPXCHG is not defined for ARM. This causes -rt locks to
always use the slow path and impacts performance. ARMv6 and above
have a cmpxchg implementation already that will work just fine.
In 2012, Yong Zhang submitted a patch to fix this[1], but it mysteriously
disappeared afterwards. I did notice that the s-o-b line has a different
email address than the windriver one. Yong, do you mind re-submitting the
patch with a fixed s-o-b?
Thanks!
Nathan Sullivan
[1]: http://lists.infradead.org/pipermail/linux-arm-kernel/2012-May/102122.html (duplicated below)
-- 8< --
From: Yong Zhang <yong.zhang@windriver.com>
Both pi_stress and sigwaittest in rt-test show performance gain with
__HAVE_ARCH_CMPXCHG. Testing result on coretile_express_a9x4:
pi_stress -p 99 --duration=300 (on linux-3.4-rc5; bigger is better)
vanilla: Total inversion performed: 5493381
patched: Total inversion performed: 5621746
sigwaittest -p 99 -l 100000 (on linux-3.4-rc5-rt6; less is better)
3.4-rc5-rt6: Min 24, Cur 27, Avg 30, Max 98
patched: Min 19, Cur 21, Avg 23, Max 96
Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Nicolas Pitre <nico@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arm-kernel at lists.infradead.org
---
arch/arm/include/asm/cmpxchg.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
index 7eb18c1..a91b44e 100644
--- a/arch/arm/include/asm/cmpxchg.h
+++ b/arch/arm/include/asm/cmpxchg.h
@@ -127,6 +127,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
#else /* min ARCH >= ARMv6 */
+#define __HAVE_ARCH_CMPXCHG 1
+
extern void __bad_cmpxchg(volatile void *ptr, int size);
/*
--
1.7.5.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: __HAVE_ARCH_CMPXCHG on ARM?
[not found] ` <CAM2zO=CVCZFNiSukgcgNNT0==xgLK4w5HF3Pz=dcFmrEHPtLdw@mail.gmail.com>
@ 2015-02-02 13:39 ` Will Deacon
0 siblings, 0 replies; 16+ messages in thread
From: Will Deacon @ 2015-02-02 13:39 UTC (permalink / raw)
To: Yong Zhang; +Cc: Nathan Sullivan, Yong Zhang, linux-arm-kernel, linux-rt-users
On Fri, Jan 30, 2015 at 08:44:48AM +0000, Yong Zhang wrote:
> On Fri, Jan 30, 2015 at 2:56 AM, Nathan Sullivan <nathan.sullivan@ni.com<mailto:nathan.sullivan@ni.com>> wrote:
>
> While investigating a performance issue on RT 3.14, I noticed that
> __HAVE_ARCH_CMPXCHG is not defined for ARM. This causes -rt locks to
> always use the slow path and impacts performance. ARMv6 and above
> have a cmpxchg implementation already that will work just fine.
>
> In 2012, Yong Zhang submitted a patch to fix this[1], but it mysteriously
> disappeared afterwards. I did notice that the s-o-b line has a different
> email address than the windriver one. Yong, do you mind re-submitting the
>
> It actually doesn't matter. Anyway feel free to add another s-o-b to
> the patch:
>
> Signed-off-by: Yong Zhang <yong.zhang@windriver.com<mailto:yong.zhang@windriver.com>>
[...]
> diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
> index 7eb18c1..a91b44e 100644
> --- a/arch/arm/include/asm/cmpxchg.h
> +++ b/arch/arm/include/asm/cmpxchg.h
> @@ -127,6 +127,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
>
> #else /* min ARCH >= ARMv6 */
>
> +#define __HAVE_ARCH_CMPXCHG 1
Is it even possible to have CONFIG_SMP=y on an architecture that doesn't
support native cmpxchg? Certainly, the asm-generic cmpxchg.h barfs if
SMP, so couldn't we just change/extend the __HAVE_ARCH_CMPXCHG check in
rtmutex.c to work automatically with SMP architectures? That would help
arm64 too.
Will
^ permalink raw reply [flat|nested] 16+ messages in thread
* __HAVE_ARCH_CMPXCHG on ARM?
@ 2015-02-02 13:39 ` Will Deacon
0 siblings, 0 replies; 16+ messages in thread
From: Will Deacon @ 2015-02-02 13:39 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Jan 30, 2015 at 08:44:48AM +0000, Yong Zhang wrote:
> On Fri, Jan 30, 2015 at 2:56 AM, Nathan Sullivan <nathan.sullivan at ni.com<mailto:nathan.sullivan@ni.com>> wrote:
>
> While investigating a performance issue on RT 3.14, I noticed that
> __HAVE_ARCH_CMPXCHG is not defined for ARM. This causes -rt locks to
> always use the slow path and impacts performance. ARMv6 and above
> have a cmpxchg implementation already that will work just fine.
>
> In 2012, Yong Zhang submitted a patch to fix this[1], but it mysteriously
> disappeared afterwards. I did notice that the s-o-b line has a different
> email address than the windriver one. Yong, do you mind re-submitting the
>
> It actually doesn't matter. Anyway feel free to add another s-o-b to
> the patch:
>
> Signed-off-by: Yong Zhang <yong.zhang at windriver.com<mailto:yong.zhang@windriver.com>>
[...]
> diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
> index 7eb18c1..a91b44e 100644
> --- a/arch/arm/include/asm/cmpxchg.h
> +++ b/arch/arm/include/asm/cmpxchg.h
> @@ -127,6 +127,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
>
> #else /* min ARCH >= ARMv6 */
>
> +#define __HAVE_ARCH_CMPXCHG 1
Is it even possible to have CONFIG_SMP=y on an architecture that doesn't
support native cmpxchg? Certainly, the asm-generic cmpxchg.h barfs if
SMP, so couldn't we just change/extend the __HAVE_ARCH_CMPXCHG check in
rtmutex.c to work automatically with SMP architectures? That would help
arm64 too.
Will
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: __HAVE_ARCH_CMPXCHG on ARM?
2015-02-02 13:39 ` Will Deacon
@ 2015-02-03 16:48 ` Nathan Sullivan
-1 siblings, 0 replies; 16+ messages in thread
From: Nathan Sullivan @ 2015-02-03 16:48 UTC (permalink / raw)
To: Will Deacon; +Cc: Yong Zhang, Yong Zhang, linux-arm-kernel, linux-rt-users
On Mon, Feb 02, 2015 at 01:39:33PM +0000, Will Deacon wrote:
> On Fri, Jan 30, 2015 at 08:44:48AM +0000, Yong Zhang wrote:
> > On Fri, Jan 30, 2015 at 2:56 AM, Nathan Sullivan <nathan.sullivan@ni.com<mailto:nathan.sullivan@ni.com>> wrote:
> >
> > While investigating a performance issue on RT 3.14, I noticed that
> > __HAVE_ARCH_CMPXCHG is not defined for ARM. This causes -rt locks to
> > always use the slow path and impacts performance. ARMv6 and above
> > have a cmpxchg implementation already that will work just fine.
> >
> > In 2012, Yong Zhang submitted a patch to fix this[1], but it mysteriously
> > disappeared afterwards. I did notice that the s-o-b line has a different
> > email address than the windriver one. Yong, do you mind re-submitting the
> >
> > It actually doesn't matter. Anyway feel free to add another s-o-b to
> > the patch:
> >
> > Signed-off-by: Yong Zhang <yong.zhang@windriver.com<mailto:yong.zhang@windriver.com>>
>
> [...]
>
> > diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
> > index 7eb18c1..a91b44e 100644
> > --- a/arch/arm/include/asm/cmpxchg.h
> > +++ b/arch/arm/include/asm/cmpxchg.h
> > @@ -127,6 +127,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
> >
> > #else /* min ARCH >= ARMv6 */
> >
> > +#define __HAVE_ARCH_CMPXCHG 1
>
> Is it even possible to have CONFIG_SMP=y on an architecture that doesn't
> support native cmpxchg? Certainly, the asm-generic cmpxchg.h barfs if
> SMP, so couldn't we just change/extend the __HAVE_ARCH_CMPXCHG check in
> rtmutex.c to work automatically with SMP architectures? That would help
> arm64 too.
>
> Will
What about single Cortex-A8s, for example? Seems like a non-SMP build should still
have cmpxchg.
Nathan
^ permalink raw reply [flat|nested] 16+ messages in thread
* __HAVE_ARCH_CMPXCHG on ARM?
@ 2015-02-03 16:48 ` Nathan Sullivan
0 siblings, 0 replies; 16+ messages in thread
From: Nathan Sullivan @ 2015-02-03 16:48 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Feb 02, 2015 at 01:39:33PM +0000, Will Deacon wrote:
> On Fri, Jan 30, 2015 at 08:44:48AM +0000, Yong Zhang wrote:
> > On Fri, Jan 30, 2015 at 2:56 AM, Nathan Sullivan <nathan.sullivan at ni.com<mailto:nathan.sullivan@ni.com>> wrote:
> >
> > While investigating a performance issue on RT 3.14, I noticed that
> > __HAVE_ARCH_CMPXCHG is not defined for ARM. This causes -rt locks to
> > always use the slow path and impacts performance. ARMv6 and above
> > have a cmpxchg implementation already that will work just fine.
> >
> > In 2012, Yong Zhang submitted a patch to fix this[1], but it mysteriously
> > disappeared afterwards. I did notice that the s-o-b line has a different
> > email address than the windriver one. Yong, do you mind re-submitting the
> >
> > It actually doesn't matter. Anyway feel free to add another s-o-b to
> > the patch:
> >
> > Signed-off-by: Yong Zhang <yong.zhang at windriver.com<mailto:yong.zhang@windriver.com>>
>
> [...]
>
> > diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
> > index 7eb18c1..a91b44e 100644
> > --- a/arch/arm/include/asm/cmpxchg.h
> > +++ b/arch/arm/include/asm/cmpxchg.h
> > @@ -127,6 +127,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
> >
> > #else /* min ARCH >= ARMv6 */
> >
> > +#define __HAVE_ARCH_CMPXCHG 1
>
> Is it even possible to have CONFIG_SMP=y on an architecture that doesn't
> support native cmpxchg? Certainly, the asm-generic cmpxchg.h barfs if
> SMP, so couldn't we just change/extend the __HAVE_ARCH_CMPXCHG check in
> rtmutex.c to work automatically with SMP architectures? That would help
> arm64 too.
>
> Will
What about single Cortex-A8s, for example? Seems like a non-SMP build should still
have cmpxchg.
Nathan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: __HAVE_ARCH_CMPXCHG on ARM?
2015-02-03 16:48 ` Nathan Sullivan
@ 2015-02-03 16:57 ` Will Deacon
-1 siblings, 0 replies; 16+ messages in thread
From: Will Deacon @ 2015-02-03 16:57 UTC (permalink / raw)
To: Nathan Sullivan; +Cc: Yong Zhang, Yong Zhang, linux-arm-kernel, linux-rt-users
On Tue, Feb 03, 2015 at 04:48:48PM +0000, Nathan Sullivan wrote:
> On Mon, Feb 02, 2015 at 01:39:33PM +0000, Will Deacon wrote:
> > On Fri, Jan 30, 2015 at 08:44:48AM +0000, Yong Zhang wrote:
> > > On Fri, Jan 30, 2015 at 2:56 AM, Nathan Sullivan <nathan.sullivan@ni.com<mailto:nathan.sullivan@ni.com>> wrote:
> > >
> > > While investigating a performance issue on RT 3.14, I noticed that
> > > __HAVE_ARCH_CMPXCHG is not defined for ARM. This causes -rt locks to
> > > always use the slow path and impacts performance. ARMv6 and above
> > > have a cmpxchg implementation already that will work just fine.
> > >
> > > In 2012, Yong Zhang submitted a patch to fix this[1], but it mysteriously
> > > disappeared afterwards. I did notice that the s-o-b line has a different
> > > email address than the windriver one. Yong, do you mind re-submitting the
> > >
> > > It actually doesn't matter. Anyway feel free to add another s-o-b to
> > > the patch:
> > >
> > > Signed-off-by: Yong Zhang <yong.zhang@windriver.com<mailto:yong.zhang@windriver.com>>
> >
> > [...]
> >
> > > diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
> > > index 7eb18c1..a91b44e 100644
> > > --- a/arch/arm/include/asm/cmpxchg.h
> > > +++ b/arch/arm/include/asm/cmpxchg.h
> > > @@ -127,6 +127,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
> > >
> > > #else /* min ARCH >= ARMv6 */
> > >
> > > +#define __HAVE_ARCH_CMPXCHG 1
> >
> > Is it even possible to have CONFIG_SMP=y on an architecture that doesn't
> > support native cmpxchg? Certainly, the asm-generic cmpxchg.h barfs if
> > SMP, so couldn't we just change/extend the __HAVE_ARCH_CMPXCHG check in
> > rtmutex.c to work automatically with SMP architectures? That would help
> > arm64 too.
> >
> > Will
>
> What about single Cortex-A8s, for example? Seems like a non-SMP build
> should still have cmpxchg.
If you have benchmarks that show an improvement then sure, but I don't
know how much an uncontended rtmutex would really care.
Will
^ permalink raw reply [flat|nested] 16+ messages in thread
* __HAVE_ARCH_CMPXCHG on ARM?
@ 2015-02-03 16:57 ` Will Deacon
0 siblings, 0 replies; 16+ messages in thread
From: Will Deacon @ 2015-02-03 16:57 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Feb 03, 2015 at 04:48:48PM +0000, Nathan Sullivan wrote:
> On Mon, Feb 02, 2015 at 01:39:33PM +0000, Will Deacon wrote:
> > On Fri, Jan 30, 2015 at 08:44:48AM +0000, Yong Zhang wrote:
> > > On Fri, Jan 30, 2015 at 2:56 AM, Nathan Sullivan <nathan.sullivan at ni.com<mailto:nathan.sullivan@ni.com>> wrote:
> > >
> > > While investigating a performance issue on RT 3.14, I noticed that
> > > __HAVE_ARCH_CMPXCHG is not defined for ARM. This causes -rt locks to
> > > always use the slow path and impacts performance. ARMv6 and above
> > > have a cmpxchg implementation already that will work just fine.
> > >
> > > In 2012, Yong Zhang submitted a patch to fix this[1], but it mysteriously
> > > disappeared afterwards. I did notice that the s-o-b line has a different
> > > email address than the windriver one. Yong, do you mind re-submitting the
> > >
> > > It actually doesn't matter. Anyway feel free to add another s-o-b to
> > > the patch:
> > >
> > > Signed-off-by: Yong Zhang <yong.zhang at windriver.com<mailto:yong.zhang@windriver.com>>
> >
> > [...]
> >
> > > diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
> > > index 7eb18c1..a91b44e 100644
> > > --- a/arch/arm/include/asm/cmpxchg.h
> > > +++ b/arch/arm/include/asm/cmpxchg.h
> > > @@ -127,6 +127,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
> > >
> > > #else /* min ARCH >= ARMv6 */
> > >
> > > +#define __HAVE_ARCH_CMPXCHG 1
> >
> > Is it even possible to have CONFIG_SMP=y on an architecture that doesn't
> > support native cmpxchg? Certainly, the asm-generic cmpxchg.h barfs if
> > SMP, so couldn't we just change/extend the __HAVE_ARCH_CMPXCHG check in
> > rtmutex.c to work automatically with SMP architectures? That would help
> > arm64 too.
> >
> > Will
>
> What about single Cortex-A8s, for example? Seems like a non-SMP build
> should still have cmpxchg.
If you have benchmarks that show an improvement then sure, but I don't
know how much an uncontended rtmutex would really care.
Will
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: __HAVE_ARCH_CMPXCHG on ARM?
2015-02-02 13:39 ` Will Deacon
@ 2015-02-03 19:27 ` Josh Cartwright
-1 siblings, 0 replies; 16+ messages in thread
From: Josh Cartwright @ 2015-02-03 19:27 UTC (permalink / raw)
To: Will Deacon
Cc: Yong Zhang, Yong Zhang, Nathan Sullivan, linux-rt-users,
linux-arm-kernel, linux-arch
On Mon, Feb 02, 2015 at 01:39:33PM +0000, Will Deacon wrote:
> On Fri, Jan 30, 2015 at 08:44:48AM +0000, Yong Zhang wrote:
> > On Fri, Jan 30, 2015 at 2:56 AM, Nathan Sullivan <nathan.sullivan@ni.com<mailto:nathan.sullivan@ni.com>> wrote:
> >
> > While investigating a performance issue on RT 3.14, I noticed that
> > __HAVE_ARCH_CMPXCHG is not defined for ARM. This causes -rt locks to
> > always use the slow path and impacts performance. ARMv6 and above
> > have a cmpxchg implementation already that will work just fine.
> >
> > In 2012, Yong Zhang submitted a patch to fix this[1], but it mysteriously
> > disappeared afterwards. I did notice that the s-o-b line has a different
> > email address than the windriver one. Yong, do you mind re-submitting the
> >
> > It actually doesn't matter. Anyway feel free to add another s-o-b to
> > the patch:
> >
> > Signed-off-by: Yong Zhang <yong.zhang@windriver.com<mailto:yong.zhang@windriver.com>>
I did a quick scan of architectures and looked at the various cmpxchg
implementations. Assuming that __HAVE_ARCH_CMPXCHG really means "this
architecture implements a native cmpxchg which is faster than the
generic implementation", I put what I found in the following table; note
that I'm not 100% confident these are correct, as in some instances I
had to make a judgement call as to whether the implementation is "fast",
hopefully it's still useful :).
native native
cmpxchg (UP) cmpxchg (SMP) __HAVE_ARCH_CMPXCHG
alpha X X X
arc X[1] X[1]
arm (pre ARMv6) [2]
arm (ARMv6+) X X
arm64 X X
avr32 X X X
blackfin X
c6x [2]
cris [3]
frv X X
hexagon X X X
ia64 X X X
m32r X X X
m68k X[4] X[4] X[4]
metag X X X
microblaze [2]
mips X X
mn10300 X[5]
nios2 [2]
openrisc [6]
parisc X X X
powerpc X X X
s390 X X X
score [7] [7] X[7]
sh X X X
sparc X X X
tile X X
unicore32 [2]
x86 X X X
xtensa X X
1: Conditional on CONFIG_ARC_HAS_LLSC
2: SMP not a supported configuration
3: No cmpxchg() implementation at all?
4: Conditional on CONFIG_RMW_INSNS
5: Conditional on CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
6: SMP not supported? Uses generic cmpxchg.
7: Should use generic cmpxchg/cmpxchg_local? Setting __HAVE_ARCH_CMPXCHG a bug?
> > +#define __HAVE_ARCH_CMPXCHG 1
>
> Is it even possible to have CONFIG_SMP=y on an architecture that doesn't
> support native cmpxchg? Certainly, the asm-generic cmpxchg.h barfs if
> SMP, so couldn't we just change/extend the __HAVE_ARCH_CMPXCHG check in
> rtmutex.c to work automatically with SMP architectures? That would help
> arm64 too.
Looks like there are a few arch-specific conditionals that might need to
be worked out for arc, m68k, and mn10300; but this could potentially
work.
If we don't go down that route, we should probably at least add
__HAVE_ARCH_CMPXCHG for arm64, blackfin (on SMP), frv, mips, tile, and
xtensa as well.
Josh
^ permalink raw reply [flat|nested] 16+ messages in thread
* __HAVE_ARCH_CMPXCHG on ARM?
@ 2015-02-03 19:27 ` Josh Cartwright
0 siblings, 0 replies; 16+ messages in thread
From: Josh Cartwright @ 2015-02-03 19:27 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Feb 02, 2015 at 01:39:33PM +0000, Will Deacon wrote:
> On Fri, Jan 30, 2015 at 08:44:48AM +0000, Yong Zhang wrote:
> > On Fri, Jan 30, 2015 at 2:56 AM, Nathan Sullivan <nathan.sullivan at ni.com<mailto:nathan.sullivan@ni.com>> wrote:
> >
> > While investigating a performance issue on RT 3.14, I noticed that
> > __HAVE_ARCH_CMPXCHG is not defined for ARM. This causes -rt locks to
> > always use the slow path and impacts performance. ARMv6 and above
> > have a cmpxchg implementation already that will work just fine.
> >
> > In 2012, Yong Zhang submitted a patch to fix this[1], but it mysteriously
> > disappeared afterwards. I did notice that the s-o-b line has a different
> > email address than the windriver one. Yong, do you mind re-submitting the
> >
> > It actually doesn't matter. Anyway feel free to add another s-o-b to
> > the patch:
> >
> > Signed-off-by: Yong Zhang <yong.zhang at windriver.com<mailto:yong.zhang@windriver.com>>
I did a quick scan of architectures and looked at the various cmpxchg
implementations. Assuming that __HAVE_ARCH_CMPXCHG really means "this
architecture implements a native cmpxchg which is faster than the
generic implementation", I put what I found in the following table; note
that I'm not 100% confident these are correct, as in some instances I
had to make a judgement call as to whether the implementation is "fast",
hopefully it's still useful :).
native native
cmpxchg (UP) cmpxchg (SMP) __HAVE_ARCH_CMPXCHG
alpha X X X
arc X[1] X[1]
arm (pre ARMv6) [2]
arm (ARMv6+) X X
arm64 X X
avr32 X X X
blackfin X
c6x [2]
cris [3]
frv X X
hexagon X X X
ia64 X X X
m32r X X X
m68k X[4] X[4] X[4]
metag X X X
microblaze [2]
mips X X
mn10300 X[5]
nios2 [2]
openrisc [6]
parisc X X X
powerpc X X X
s390 X X X
score [7] [7] X[7]
sh X X X
sparc X X X
tile X X
unicore32 [2]
x86 X X X
xtensa X X
1: Conditional on CONFIG_ARC_HAS_LLSC
2: SMP not a supported configuration
3: No cmpxchg() implementation at all?
4: Conditional on CONFIG_RMW_INSNS
5: Conditional on CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
6: SMP not supported? Uses generic cmpxchg.
7: Should use generic cmpxchg/cmpxchg_local? Setting __HAVE_ARCH_CMPXCHG a bug?
> > +#define __HAVE_ARCH_CMPXCHG 1
>
> Is it even possible to have CONFIG_SMP=y on an architecture that doesn't
> support native cmpxchg? Certainly, the asm-generic cmpxchg.h barfs if
> SMP, so couldn't we just change/extend the __HAVE_ARCH_CMPXCHG check in
> rtmutex.c to work automatically with SMP architectures? That would help
> arm64 too.
Looks like there are a few arch-specific conditionals that might need to
be worked out for arc, m68k, and mn10300; but this could potentially
work.
If we don't go down that route, we should probably at least add
__HAVE_ARCH_CMPXCHG for arm64, blackfin (on SMP), frv, mips, tile, and
xtensa as well.
Josh
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: __HAVE_ARCH_CMPXCHG on ARM?
2015-02-02 13:39 ` Will Deacon
@ 2015-02-18 10:43 ` Sebastian Andrzej Siewior
-1 siblings, 0 replies; 16+ messages in thread
From: Sebastian Andrzej Siewior @ 2015-02-18 10:43 UTC (permalink / raw)
To: Will Deacon, peterz, rostedt, tglx
Cc: Yong Zhang, Nathan Sullivan, Yong Zhang, linux-arm-kernel,
linux-rt-users
* Will Deacon | 2015-02-02 13:39:33 [+0000]:
>> diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
>> index 7eb18c1..a91b44e 100644
>> --- a/arch/arm/include/asm/cmpxchg.h
>> +++ b/arch/arm/include/asm/cmpxchg.h
>> @@ -127,6 +127,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
>>
>> #else /* min ARCH >= ARMv6 */
>>
>> +#define __HAVE_ARCH_CMPXCHG 1
>
>Is it even possible to have CONFIG_SMP=y on an architecture that doesn't
>support native cmpxchg? Certainly, the asm-generic cmpxchg.h barfs if
>SMP, so couldn't we just change/extend the __HAVE_ARCH_CMPXCHG check in
>rtmutex.c to work automatically with SMP architectures? That would help
>arm64 too.
RT mutex was first introduced in 23f78d4a0 ("[PATCH] pi-futex: rt mutex core")
which is v2.6.18. The generic cmpxchg was introduced laster in
068fbad288 ("Add cmpxchg_local to asm-generic for per cpu atomic
operations") which is v2.6.25.
Back then something was required to get RT mutex working with the fast
path on architectures without cmpxchg and this seems to be the result.
Please correct me if I'm wrong.
On the other hand, how do you implement a SMP systems without native cmpxchg()
support? Isn't this a prerequisite?
Right now I don't see a reason why we should not remove
__HAVE_ARCH_CMPXCHG and assume cmpxchg() is always there.
>Will
Sebastian
^ permalink raw reply [flat|nested] 16+ messages in thread
* __HAVE_ARCH_CMPXCHG on ARM?
@ 2015-02-18 10:43 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 16+ messages in thread
From: Sebastian Andrzej Siewior @ 2015-02-18 10:43 UTC (permalink / raw)
To: linux-arm-kernel
* Will Deacon | 2015-02-02 13:39:33 [+0000]:
>> diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
>> index 7eb18c1..a91b44e 100644
>> --- a/arch/arm/include/asm/cmpxchg.h
>> +++ b/arch/arm/include/asm/cmpxchg.h
>> @@ -127,6 +127,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
>>
>> #else /* min ARCH >= ARMv6 */
>>
>> +#define __HAVE_ARCH_CMPXCHG 1
>
>Is it even possible to have CONFIG_SMP=y on an architecture that doesn't
>support native cmpxchg? Certainly, the asm-generic cmpxchg.h barfs if
>SMP, so couldn't we just change/extend the __HAVE_ARCH_CMPXCHG check in
>rtmutex.c to work automatically with SMP architectures? That would help
>arm64 too.
RT mutex was first introduced in 23f78d4a0 ("[PATCH] pi-futex: rt mutex core")
which is v2.6.18. The generic cmpxchg was introduced laster in
068fbad288 ("Add cmpxchg_local to asm-generic for per cpu atomic
operations") which is v2.6.25.
Back then something was required to get RT mutex working with the fast
path on architectures without cmpxchg and this seems to be the result.
Please correct me if I'm wrong.
On the other hand, how do you implement a SMP systems without native cmpxchg()
support? Isn't this a prerequisite?
Right now I don't see a reason why we should not remove
__HAVE_ARCH_CMPXCHG and assume cmpxchg() is always there.
>Will
Sebastian
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: __HAVE_ARCH_CMPXCHG on ARM?
2015-02-03 19:27 ` Josh Cartwright
@ 2015-02-18 10:44 ` Sebastian Andrzej Siewior
-1 siblings, 0 replies; 16+ messages in thread
From: Sebastian Andrzej Siewior @ 2015-02-18 10:44 UTC (permalink / raw)
To: Josh Cartwright
Cc: Will Deacon, Yong Zhang, Yong Zhang, Nathan Sullivan,
linux-rt-users, linux-arm-kernel, linux-arch
* Josh Cartwright | 2015-02-03 13:27:30 [-0600]:
> native native
> cmpxchg (UP) cmpxchg (SMP) __HAVE_ARCH_CMPXCHG
> xtensa X X
This one does not always have cmpxchg on UP (only the SMP variant which
provides atomic operation).
> Josh
Sebastian
^ permalink raw reply [flat|nested] 16+ messages in thread
* __HAVE_ARCH_CMPXCHG on ARM?
@ 2015-02-18 10:44 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 16+ messages in thread
From: Sebastian Andrzej Siewior @ 2015-02-18 10:44 UTC (permalink / raw)
To: linux-arm-kernel
* Josh Cartwright | 2015-02-03 13:27:30 [-0600]:
> native native
> cmpxchg (UP) cmpxchg (SMP) __HAVE_ARCH_CMPXCHG
> xtensa X X
This one does not always have cmpxchg on UP (only the SMP variant which
provides atomic operation).
> Josh
Sebastian
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: __HAVE_ARCH_CMPXCHG on ARM?
2015-02-18 10:44 ` Sebastian Andrzej Siewior
@ 2015-02-18 16:34 ` Josh Cartwright
-1 siblings, 0 replies; 16+ messages in thread
From: Josh Cartwright @ 2015-02-18 16:34 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: Will Deacon, Yong Zhang, Yong Zhang, Nathan Sullivan,
linux-rt-users, linux-arm-kernel, linux-arch
On Wed, Feb 18, 2015 at 11:44:59AM +0100, Sebastian Andrzej Siewior wrote:
> * Josh Cartwright | 2015-02-03 13:27:30 [-0600]:
>
> > native native
> > cmpxchg (UP) cmpxchg (SMP) __HAVE_ARCH_CMPXCHG
> > xtensa X X
>
> This one does not always have cmpxchg on UP (only the SMP variant which
> provides atomic operation).
Ah! Thanks for double checking my work; my eyes started to glaze over
after looking at the other 29 architectures.
Josh
^ permalink raw reply [flat|nested] 16+ messages in thread
* __HAVE_ARCH_CMPXCHG on ARM?
@ 2015-02-18 16:34 ` Josh Cartwright
0 siblings, 0 replies; 16+ messages in thread
From: Josh Cartwright @ 2015-02-18 16:34 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Feb 18, 2015 at 11:44:59AM +0100, Sebastian Andrzej Siewior wrote:
> * Josh Cartwright | 2015-02-03 13:27:30 [-0600]:
>
> > native native
> > cmpxchg (UP) cmpxchg (SMP) __HAVE_ARCH_CMPXCHG
> > xtensa X X
>
> This one does not always have cmpxchg on UP (only the SMP variant which
> provides atomic operation).
Ah! Thanks for double checking my work; my eyes started to glaze over
after looking at the other 29 architectures.
Josh
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2015-02-18 16:34 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-29 18:56 __HAVE_ARCH_CMPXCHG on ARM? Nathan Sullivan
2015-01-29 18:56 ` Nathan Sullivan
[not found] ` <CAM2zO=CVCZFNiSukgcgNNT0==xgLK4w5HF3Pz=dcFmrEHPtLdw@mail.gmail.com>
2015-02-02 13:39 ` Will Deacon
2015-02-02 13:39 ` Will Deacon
2015-02-03 16:48 ` Nathan Sullivan
2015-02-03 16:48 ` Nathan Sullivan
2015-02-03 16:57 ` Will Deacon
2015-02-03 16:57 ` Will Deacon
2015-02-03 19:27 ` Josh Cartwright
2015-02-03 19:27 ` Josh Cartwright
2015-02-18 10:44 ` Sebastian Andrzej Siewior
2015-02-18 10:44 ` Sebastian Andrzej Siewior
2015-02-18 16:34 ` Josh Cartwright
2015-02-18 16:34 ` Josh Cartwright
2015-02-18 10:43 ` Sebastian Andrzej Siewior
2015-02-18 10:43 ` Sebastian Andrzej Siewior
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.