Received: by 10.223.185.116 with SMTP id b49csp1015410wrg; Tue, 20 Feb 2018 11:40:27 -0800 (PST) X-Google-Smtp-Source: AH8x225pybnwCTFNskze2Jl4QN9aecwawBZSK8AOH8LpIBmx9uxr7xD/R03wXAegQCPmgc24sIkC X-Received: by 2002:a17:902:1683:: with SMTP id h3-v6mr639888plh.433.1519155626928; Tue, 20 Feb 2018 11:40:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519155626; cv=none; d=google.com; s=arc-20160816; b=iiPvMVOh/VhuRqyC5zpMLBwOjH5DGtzKz9NKiSlkbKVoF7UHYxVsTy8pvaWqcCcTtV 1Zs/2LSELsBquZNAmdS6sxHdxKT637LmWJx9FAQXF8nUV5CbALfCRYXfMwMRqMd704ij QPoN8srleFiA5pJ2OFP3OYsN7pET9b+m0gHOPzVpH5+KNO2D13p01+7pfb4L2a0keidZ d2GJWis/UzjEvp41OJ9AjMrXAuHU7bIjTezUZmGfQFW9AvVX7hpMD9U31rsesKeV6CW5 NfPc4iii36sE4yuiwe0MSko0wJ7F0PKPSgnVK+8QT45JvqTusBXSvW57VCx2vJfvzS1A 6cKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=k8MjiiswFCNPDpBb3d2FS3q6L1Om+oG1ga8pe+5myUA=; b=AgaOUEJVgqKEmF1lgLBHckXqdtsRQyhEyGLgtsFanXTgpKDD+cgkfeBlzTtOrdIqmR nqKEw3caXfQWG8gDHpt+GovbIZ7QNTtZqRLVICYJn0gOf+QtxKbIzIoHED+ENZy6ZN0s 9+ttx/EPW4RF3CS3IZFd7h0SW2AB+e8x51JwoyPSCW+h9jw9UrMB+b8oS/fSc2TkwBYP uRNSDH1/FUtEzIaDzaPg3XmQdXmVIwYTd9jrqHL/5QwNKY+8fOlk/KkzSq8wtAYApewj OO+EAVicw/3lYvlEsvHlkNAQdhhWMEgp746GGUsq79x11axdZwFZLVz73GgvM8O1yhd5 71Dg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7-v6si8106461pll.581.2018.02.20.11.40.12; Tue, 20 Feb 2018 11:40:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752441AbeBTTig (ORCPT + 99 others); Tue, 20 Feb 2018 14:38:36 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50196 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752047AbeBTTif (ORCPT ); Tue, 20 Feb 2018 14:38:35 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1KJZviC027891 for ; Tue, 20 Feb 2018 14:38:35 -0500 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g8qtk5evu-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 20 Feb 2018 14:38:31 -0500 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 Feb 2018 14:38:31 -0500 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 20 Feb 2018 14:38:28 -0500 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1KJcRxb41615392; Tue, 20 Feb 2018 19:38:27 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 63895B2050; Tue, 20 Feb 2018 15:40:46 -0500 (EST) Received: from paulmck-ThinkPad-W541 (unknown [9.85.154.79]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 11C03B204E; Tue, 20 Feb 2018 15:40:46 -0500 (EST) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id B887D16C2E7F; Tue, 20 Feb 2018 11:38:50 -0800 (PST) Date: Tue, 20 Feb 2018 11:38:50 -0800 From: "Paul E. McKenney" To: Andrea Parri Cc: Ingo Molnar , Will Deacon , Alan Stern , Richard Henderson , Ivan Kokshaysky , Matt Turner , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] xchg/alpha: Add unconditional memory barrier to cmpxchg Reply-To: paulmck@linux.vnet.ibm.com References: <1519152356-4804-1-git-send-email-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1519152356-4804-1-git-send-email-parri.andrea@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18022019-0040-0000-0000-000003FA18A9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008565; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.00992609; UDB=6.00504297; IPR=6.00771955; MB=3.00019659; MTD=3.00000008; XFM=3.00000015; UTC=2018-02-20 19:38:30 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022019-0041-0000-0000-000007FB1DEE Message-Id: <20180220193850.GV3617@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-20_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=60 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802200235 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 20, 2018 at 07:45:56PM +0100, Andrea Parri wrote: > Continuing along with the fight against smp_read_barrier_depends() [1] > (or rather, against its improper use), add an unconditional barrier to > cmpxchg. This guarantees that dependency ordering is preserved when a > dependency is headed by an unsuccessful cmpxchg. As it turns out, the > change could enable further simplification of LKMM as proposed in [2]. > > [1] https://marc.info/?l=linux-kernel&m=150884953419377&w=2 > https://marc.info/?l=linux-kernel&m=150884946319353&w=2 > https://marc.info/?l=linux-kernel&m=151215810824468&w=2 > https://marc.info/?l=linux-kernel&m=151215816324484&w=2 > > [2] https://marc.info/?l=linux-kernel&m=151881978314872&w=2 > > Signed-off-by: Andrea Parri > Acked-by: Peter Zijlstra > Cc: Will Deacon > Cc: "Paul E. McKenney" Acked-by: "Paul E. McKenney" > Cc: Alan Stern > Cc: Richard Henderson > Cc: Ivan Kokshaysky > Cc: Matt Turner > Cc: linux-alpha@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > --- > arch/alpha/include/asm/xchg.h | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/arch/alpha/include/asm/xchg.h b/arch/alpha/include/asm/xchg.h > index 68dfb3cb71454..e2660866ce972 100644 > --- a/arch/alpha/include/asm/xchg.h > +++ b/arch/alpha/include/asm/xchg.h > @@ -128,10 +128,9 @@ ____xchg(, volatile void *ptr, unsigned long x, int size) > * store NEW in MEM. Return the initial value in MEM. Success is > * indicated by comparing RETURN with OLD. > * > - * The memory barrier should be placed in SMP only when we actually > - * make the change. If we don't change anything (so if the returned > - * prev is equal to old) then we aren't acquiring anything new and > - * we don't need any memory barrier as far I can tell. > + * The memory barrier is placed in SMP unconditionally, in order to > + * guarantee that dependency ordering is preserved when a dependency > + * is headed by an unsuccessful operation. > */ > > static inline unsigned long > @@ -150,8 +149,8 @@ ____cmpxchg(_u8, volatile char *m, unsigned char old, unsigned char new) > " or %1,%2,%2\n" > " stq_c %2,0(%4)\n" > " beq %2,3f\n" > - __ASM__MB > "2:\n" > + __ASM__MB > ".subsection 2\n" > "3: br 1b\n" > ".previous" > @@ -177,8 +176,8 @@ ____cmpxchg(_u16, volatile short *m, unsigned short old, unsigned short new) > " or %1,%2,%2\n" > " stq_c %2,0(%4)\n" > " beq %2,3f\n" > - __ASM__MB > "2:\n" > + __ASM__MB > ".subsection 2\n" > "3: br 1b\n" > ".previous" > @@ -200,8 +199,8 @@ ____cmpxchg(_u32, volatile int *m, int old, int new) > " mov %4,%1\n" > " stl_c %1,%2\n" > " beq %1,3f\n" > - __ASM__MB > "2:\n" > + __ASM__MB > ".subsection 2\n" > "3: br 1b\n" > ".previous" > @@ -223,8 +222,8 @@ ____cmpxchg(_u64, volatile long *m, unsigned long old, unsigned long new) > " mov %4,%1\n" > " stq_c %1,%2\n" > " beq %1,3f\n" > - __ASM__MB > "2:\n" > + __ASM__MB > ".subsection 2\n" > "3: br 1b\n" > ".previous" > -- > 2.7.4 >