All of lore.kernel.org
 help / color / mirror / Atom feed
From: nico@fluxnic.net (Nicolas Pitre)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: mutex: use generic atomic_dec-based implementation for ARMv6+
Date: Fri, 13 Jul 2012 13:07:55 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LFD.2.02.1207131303090.14068@xanadu.home> (raw)
In-Reply-To: <20120713143026.GV18079@mudshark.cambridge.arm.com>

On Fri, 13 Jul 2012, Will Deacon wrote:

> Hi Arnd,
> 
> On Fri, Jul 13, 2012 at 03:14:36PM +0100, Arnd Bergmann wrote:
> > Acked-by: Arnd Bergmann <arnd@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.

The xchg is much better on pre-ARMv6 because it uses the SWP instruction 
which is deprecated from ARMv6.  Given that the atomic dec and xchg are 
rather equivalent on ARMv6 then having only one case is fine.  However 
it is important to comment the fact that despite ARMv6+ choice, the 
pre-ARMv6 does want to remain xchg based.  Having both unified might 
hide this fact otherwise.


Nicolas

  parent reply	other threads:[~2012-07-13 17:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-13 11:04 [PATCH] ARM: mutex: use generic atomic_dec-based implementation for ARMv6+ Will Deacon
2012-07-13 13:21 ` Nicolas Pitre
2012-07-13 13:43   ` Will Deacon
2012-07-13 17:00     ` Nicolas Pitre
2012-07-13 14:14 ` Arnd Bergmann
2012-07-13 14:30   ` Will Deacon
2012-07-13 15:13     ` Will Deacon
2012-07-13 17:07     ` Nicolas Pitre [this message]
2012-08-13 17:38 Will Deacon
2012-08-13 18:14 ` Nicolas Pitre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.02.1207131303090.14068@xanadu.home \
    --to=nico@fluxnic.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.