[PATCH] ARM: mutex: use generic atomic_dec-based implementation for ARMv6+

Will Deacon will.deacon at arm.com
Fri Jul 13 10:30:27 EDT 2012


Hi Arnd,

On Fri, Jul 13, 2012 at 03:14:36PM +0100, Arnd Bergmann wrote:
> Acked-by: Arnd Bergmann <arnd at arndb.de>

Thanks for that.

> One question though: can you explain why the xchg implementation is better
> on pre-v6, while the dec implementation is better on v6+? It would probably
> be helpful to put that in the comment at
> 
>  /* On pre-ARMv6 hardware the swp based implementation is the most efficient. */
>  # include <asm-generic/mutex-xchg.h>
>  #else
>  /* ARMv6+ can implement efficient atomic decrement using exclusive accessors. */
>  # include <asm-generic/mutex-dec.h>
> 
> Intuitively, I'd guess that both implementations are equally efficient
> on ARMv6 because they use the same ldrex/strex loop.

I used the atomic decrement version because that's what the old
implementation was most similar to. For some reason I thought that maybe the
register pressure would be higher for xchg, but it doesn't look like that's
the case (there are compiler barriers anyway) and we actually end up with one
fewer instruction using xchg as we longer need the subtract.

If Nicolas is happy with it, I'd be tempted to use mutex-xchg.h regardless
of the architecture version (unfortunately we can't use generic-y for that).

Will



More information about the linux-arm-kernel mailing list