From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Will Deacon <will.deacon@arm.com>
Cc: linux-kernel@vger.kernel.org, mcree@orcon.net.nz,
peterz@infradead.org, rth@twiddle.net, ink@jurassic.park.msu.ru,
mattst88@gmail.com, linux-alpha@vger.kernel.org
Subject: Re: [PATCH 3/3] alpha: atomics: Add smp_read_barrier_depends() to release/relaxed atomics
Date: Thu, 12 Oct 2017 08:17:12 -0700 [thread overview]
Message-ID: <20171012151712.GA3521@linux.vnet.ibm.com> (raw)
In-Reply-To: <1507818377-7546-4-git-send-email-will.deacon@arm.com>
On Thu, Oct 12, 2017 at 03:26:17PM +0100, Will Deacon wrote:
> As part of the fight against smp_read_barrier_depends(), we require
> dependency ordering to be preserved when a dependency is headed by a load
> performed using an atomic operation.
>
> This patch adds smp_read_barrier_depends() to the _release and _relaxed
> atomics on alpha, which otherwise lack anything to enforce dependency
> ordering.
>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
> arch/alpha/include/asm/atomic.h | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
> index 498933a7df97..16961a3f45ba 100644
> --- a/arch/alpha/include/asm/atomic.h
> +++ b/arch/alpha/include/asm/atomic.h
> @@ -13,6 +13,15 @@
> * than regular operations.
> */
>
> +/*
> + * To ensure dependency ordering is preserved for the _relaxed and
> + * _release atomics, an smp_read_barrier_depends() is unconditionally
> + * inserted into the _relaxed variants, which are used to build the
> + * barriered versions. To avoid redundant back-to-back fences, we can
> + * define the _acquire and _fence versions explicitly.
> + */
> +#define __atomic_op_acquire(op, args...) op##_relaxed(args)
> +#define __atomic_op_fence __atomic_op_release
>
> #define ATOMIC_INIT(i) { (i) }
> #define ATOMIC64_INIT(i) { (i) }
> @@ -60,6 +69,7 @@ static inline int atomic_##op##_return_relaxed(int i, atomic_t *v) \
> ".previous" \
> :"=&r" (temp), "=m" (v->counter), "=&r" (result) \
> :"Ir" (i), "m" (v->counter) : "memory"); \
> + smp_read_barrier_depends(); \
> return result; \
> }
>
> @@ -77,6 +87,7 @@ static inline int atomic_fetch_##op##_relaxed(int i, atomic_t *v) \
> ".previous" \
> :"=&r" (temp), "=m" (v->counter), "=&r" (result) \
> :"Ir" (i), "m" (v->counter) : "memory"); \
> + smp_read_barrier_depends(); \
> return result; \
> }
>
> @@ -111,6 +122,7 @@ static __inline__ long atomic64_##op##_return_relaxed(long i, atomic64_t * v) \
> ".previous" \
> :"=&r" (temp), "=m" (v->counter), "=&r" (result) \
> :"Ir" (i), "m" (v->counter) : "memory"); \
> + smp_read_barrier_depends(); \
> return result; \
> }
>
> @@ -128,6 +140,7 @@ static __inline__ long atomic64_fetch_##op##_relaxed(long i, atomic64_t * v) \
> ".previous" \
> :"=&r" (temp), "=m" (v->counter), "=&r" (result) \
> :"Ir" (i), "m" (v->counter) : "memory"); \
> + smp_read_barrier_depends(); \
> return result; \
> }
>
> --
> 2.1.4
>
prev parent reply other threads:[~2017-10-12 15:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-12 14:26 [PATCH 0/3] Remove lockless_dereference Will Deacon
2017-10-12 14:26 ` [PATCH 1/3] linux/compiler.h: Split into compiler.h and compiler-types.h Will Deacon
2017-10-12 14:26 ` [PATCH 2/3] locking/barriers: Kill lockless_dereference Will Deacon
2017-10-12 15:16 ` Paul E. McKenney
2017-10-12 14:26 ` [PATCH 3/3] alpha: atomics: Add smp_read_barrier_depends() to release/relaxed atomics Will Deacon
2017-10-12 15:17 ` Paul E. McKenney [this message]
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=20171012151712.GA3521@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=ink@jurassic.park.msu.ru \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mattst88@gmail.com \
--cc=mcree@orcon.net.nz \
--cc=peterz@infradead.org \
--cc=rth@twiddle.net \
--cc=will.deacon@arm.com \
/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).