From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 15/31] arm64: SMP support
Date: Tue, 29 Jan 2013 11:03:12 +0000 [thread overview]
Message-ID: <20130129110311.GD25983@arm.com> (raw)
In-Reply-To: <CALZhoSTsmmsBgT2CtpC1uN9DQM5NTftA024FsyRitCFhPa7LpQ@mail.gmail.com>
On Mon, Jan 28, 2013 at 02:46:53AM +0000, Lei Wen wrote:
> On Sat, Sep 8, 2012 at 12:26 AM, Catalin Marinas <catalin.marinas at arm.com<mailto:catalin.marinas@arm.com>> wrote:
> > This patch adds SMP initialisation and spinlocks implementation for
> > AArch64. The spinlock support uses the new load-acquire/store-release
> > instructions to avoid explicit barriers. The architecture also specifies
> > that an event is automatically generated when clearing the exclusive
> > monitor state to wake up processors in WFE, so there is no need for an
> > explicit DSB/SEV instruction sequence. The SEVL instruction is used to
> > set the exclusive monitor locally as there is no conditional WFE and a
> > branch is more expensive.
> >
> > For the SMP booting protocol, see Documentation/arm64/booting.txt.
> >
> > Signed-off-by: Will Deacon <will.deacon at arm.com<mailto:will.deacon@arm.com>>
> > Signed-off-by: Marc Zyngier <marc.zyngier at arm.com<mailto:marc.zyngier@arm.com>>
> > Signed-off-by: Catalin Marinas <catalin.marinas at arm.com<mailto:catalin.marinas@arm.com>>
> > Acked-by: Arnd Bergmann <arnd at arndb.de<mailto:arnd@arndb.de>>
> > Acked-by: Tony Lindgren <tony at atomide.com<mailto:tony@atomide.com>>
> > ---
> > arch/arm64/include/asm/hardirq.h | 5 +
> > arch/arm64/include/asm/smp.h | 69 +++++
> > arch/arm64/include/asm/spinlock.h | 202 +++++++++++++
> > arch/arm64/include/asm/spinlock_types.h | 38 +++
> > arch/arm64/kernel/smp.c | 469 +++++++++++++++++++++++++++++++
> > 5 files changed, 783 insertions(+), 0 deletions(-)
> > create mode 100644 arch/arm64/include/asm/smp.h
> > create mode 100644 arch/arm64/include/asm/spinlock.h
> > create mode 100644 arch/arm64/include/asm/spinlock_types.h
> > create mode 100644 arch/arm64/kernel/smp.c
> >
> [snip...]
> > +static inline void arch_spin_lock(arch_spinlock_t *lock)
> > +{
> > + unsigned int tmp;
> > +
> > + asm volatile(
> > + " sevl\n"
> > + "1: wfe\n"
> > + "2: ldaxr %w0, [%1]\n"
> > + " cbnz %w0, 1b\n"
> > + " stxr %w0, %w2, [%1]\n"
> > + " cbnz %w0, 2b\n"
> > + : "=&r" (tmp)
> > + : "r" (&lock->lock), "r" (1)
> > + : "memory");
>
> Why just put "memory" attribute here is enough for keep lock variable
> being updated around multi-cores? I check the original spinlock we use
> in bit32 machine: arch/arm/include/asm/spinlock.h It actually use
> smp_mb after successfully acquire that lock, so we don't need it for
> arm64? Or if it is true that we don't need it in arm64, could we also
> eliminate the smp_mb usage in arm32?
We need the smp_mb (which is a dmb instruction) on AArch32 (ARMv6/v7
instruction set). For AArch64 we have load-acquire and store-release
instructions (lda*, stl*) which act as half-barriers. In the
arch_spin_lock function above we have a ldaxr which prevents any memory
accesses inside the locked region to be observed before this
instruction. The unlock is done with a stlr instructions which prevents
any memory accesses inside the locked region to be observed after this
instruction.
--
Catalin
next parent reply other threads:[~2013-01-29 11:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CALZhoSTsmmsBgT2CtpC1uN9DQM5NTftA024FsyRitCFhPa7LpQ@mail.gmail.com>
2013-01-29 11:03 ` Catalin Marinas [this message]
2012-09-07 16:26 [PATCH v3 00/31] AArch64 Linux kernel port Catalin Marinas
2012-09-07 16:26 ` [PATCH v3 15/31] arm64: SMP support Catalin Marinas
2012-09-07 19:39 ` Arnd Bergmann
2015-08-06 0:46 ` Timur Tabi
2015-08-06 9:56 ` Catalin Marinas
2015-08-10 11:00 ` Hanjun Guo
2015-08-10 17:05 ` Timur Tabi
2015-08-21 16:45 ` Timur Tabi
2015-08-24 12:14 ` Hanjun Guo
2015-08-27 22:15 ` Timur Tabi
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=20130129110311.GD25983@arm.com \
--to=catalin.marinas@arm.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).