From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752919AbdJLPRT (ORCPT ); Thu, 12 Oct 2017 11:17:19 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37756 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752532AbdJLPRS (ORCPT ); Thu, 12 Oct 2017 11:17:18 -0400 Date: Thu, 12 Oct 2017 08:17:12 -0700 From: "Paul E. McKenney" To: Will Deacon 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 Reply-To: paulmck@linux.vnet.ibm.com References: <1507818377-7546-1-git-send-email-will.deacon@arm.com> <1507818377-7546-4-git-send-email-will.deacon@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1507818377-7546-4-git-send-email-will.deacon@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17101215-0052-0000-0000-000002710ADA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007886; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000236; SDB=6.00930115; UDB=6.00468194; IPR=6.00710382; BA=6.00005635; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017508; XFM=3.00000015; UTC=2017-10-12 15:17:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101215-0053-0000-0000-0000524C6FB2 Message-Id: <20171012151712.GA3521@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-12_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710120201 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Paul E. McKenney > --- > 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 >