Received: by 10.223.185.116 with SMTP id b49csp2435925wrg; Thu, 22 Feb 2018 13:48:30 -0800 (PST) X-Google-Smtp-Source: AH8x225RJFFc/eIcgIaEJvkUteWPZA+gocrSszLwP7SfSZK8x2KfddwksWQ9bC1PLu79KwZRJKvO X-Received: by 2002:a17:902:b613:: with SMTP id b19-v6mr3702876pls.173.1519336110835; Thu, 22 Feb 2018 13:48:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519336110; cv=none; d=google.com; s=arc-20160816; b=F4hYBFQnAeZjb3rNMnZLJGy+AWbch9vCeyT100Dp6LKMDgxFzqNPANhgb0rkb/ftaM 2vXXEGqNylmq+blwPNtAu+6jf1fTL+uBATYUdDKM2M2WCWw4wXJaDsuhNY/BgAxMj2Fq LUYx+P1Oo4b/tn5XeyB5/7um/g54Q8ajaa7hBzQeVb1/jvRwOD2uYiNIV/p4n1fAuHE0 +ripVQs6i3fzIgGBMGtpCxQsLTJHs5W0Sj4tAQjEWuOjaMMvBXeMC73CHPvJM5MUaGmd EMaacrvcNq2GgnZ/5R9C9sj3mewBODvKY0HDBBjRR/8b5pNWmBAWLRenhIDGbN7G1IgT ZJBQ== 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=7Cv+DZgihs2ry/WV0eRt0oJe7i9pqrhjDigot1l4NGE=; b=cTJFp1LF7RIF9PeRGlCrzpNUXhc1TtCe869wOBRqXnSjoHT4CrvIlsLkOTm80CXm9b I2qEipg569zBMgj6KbcZ+Clo2EkJHK2PEBSbDmrFy2Td73yuxLIf5Szyj7ZVVtlOqhSg 6YARZgJO2teyrxxIto7Vdjr0q1t3Cfw/UNipjmhwRhSv1fiVFwY0PYeAephCaGEt30M6 VWH1mtoPcg/wU1VyZbDeON/Azw0Ol0ppIKW5nJdCZLx0VayjvWeTLIE3fCiYTKcTGQOs 06W5HDapweoO72PBSb9Q6n4LtBERYZOrWeQb2ppzAMM9Wvqacl2L1e82j3Xxi51K/vXY yeag== 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 g63si664414pfb.52.2018.02.22.13.48.16; Thu, 22 Feb 2018 13:48:30 -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 S1751522AbeBVVqK (ORCPT + 99 others); Thu, 22 Feb 2018 16:46:10 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39532 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751330AbeBVVqH (ORCPT ); Thu, 22 Feb 2018 16:46:07 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1MLgIwx129273 for ; Thu, 22 Feb 2018 16:46:07 -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 2ga25u12ny-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Feb 2018 16:46:06 -0500 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Feb 2018 16:46:05 -0500 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 22 Feb 2018 16:46:01 -0500 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1MLk0Tl48234606; Thu, 22 Feb 2018 21:46:00 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 92BA9B2056; Thu, 22 Feb 2018 17:48:18 -0500 (EST) Received: from paulmck-ThinkPad-W541 (unknown [9.85.154.79]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 3F825B2046; Thu, 22 Feb 2018 17:48:18 -0500 (EST) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id 7500616C86CD; Thu, 22 Feb 2018 13:46:25 -0800 (PST) Date: Thu, 22 Feb 2018 13:46:25 -0800 From: "Paul E. McKenney" To: Andrea Parri Cc: Ingo Molnar , Peter Zijlstra , Alan Stern , Ivan Kokshaysky , Matt Turner , Richard Henderson , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] locking/xchg/alpha: Use smp_mb() in place of __ASM__MB Reply-To: paulmck@linux.vnet.ibm.com References: <1519291469-5702-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: <1519291469-5702-1-git-send-email-parri.andrea@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18022221-0040-0000-0000-000003FBA110 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008578; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.00993612; UDB=6.00504897; IPR=6.00772952; MB=3.00019694; MTD=3.00000008; XFM=3.00000015; UTC=2018-02-22 21:46:04 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022221-0041-0000-0000-000007FCA824 Message-Id: <20180222214625.GM2855@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-22_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=18 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-1802220269 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 22, 2018 at 10:24:29AM +0100, Andrea Parri wrote: > Replace each occurrence of __ASM__MB with a (trailing) smp_mb() in > xchg(), cmpxchg(), and remove the now unused __ASM__MB definitions; > this improves readability, with no additional synchronization cost. > > Suggested-by: Will Deacon > Signed-off-by: Andrea Parri I am a bit confused by the use of out-of-line branches to do a backwards branch, but those were in place to start with. Maybe the point is to defeat backwards-branch prediction or some such. Regardless... Acked-by: Paul E. McKenney > Cc: Peter Zijlstra > Cc: Paul E. McKenney > Cc: Alan Stern > Cc: Ivan Kokshaysky > Cc: Matt Turner > Cc: Richard Henderson > Cc: linux-alpha@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > --- > arch/alpha/include/asm/cmpxchg.h | 6 ------ > arch/alpha/include/asm/xchg.h | 16 ++++++++-------- > 2 files changed, 8 insertions(+), 14 deletions(-) > > diff --git a/arch/alpha/include/asm/cmpxchg.h b/arch/alpha/include/asm/cmpxchg.h > index 46ebf14aed4e5..8a2b331e43feb 100644 > --- a/arch/alpha/include/asm/cmpxchg.h > +++ b/arch/alpha/include/asm/cmpxchg.h > @@ -6,7 +6,6 @@ > * Atomic exchange routines. > */ > > -#define __ASM__MB > #define ____xchg(type, args...) __xchg ## type ## _local(args) > #define ____cmpxchg(type, args...) __cmpxchg ## type ## _local(args) > #include > @@ -33,10 +32,6 @@ > cmpxchg_local((ptr), (o), (n)); \ > }) > > -#ifdef CONFIG_SMP > -#undef __ASM__MB > -#define __ASM__MB "\tmb\n" > -#endif > #undef ____xchg > #undef ____cmpxchg > #define ____xchg(type, args...) __xchg ##type(args) > @@ -64,7 +59,6 @@ > cmpxchg((ptr), (o), (n)); \ > }) > > -#undef __ASM__MB > #undef ____cmpxchg > > #endif /* _ALPHA_CMPXCHG_H */ > diff --git a/arch/alpha/include/asm/xchg.h b/arch/alpha/include/asm/xchg.h > index e2660866ce972..e1facf6fc2446 100644 > --- a/arch/alpha/include/asm/xchg.h > +++ b/arch/alpha/include/asm/xchg.h > @@ -28,12 +28,12 @@ ____xchg(_u8, volatile char *m, unsigned long val) > " or %1,%2,%2\n" > " stq_c %2,0(%3)\n" > " beq %2,2f\n" > - __ASM__MB > ".subsection 2\n" > "2: br 1b\n" > ".previous" > : "=&r" (ret), "=&r" (val), "=&r" (tmp), "=&r" (addr64) > : "r" ((long)m), "1" (val) : "memory"); > + smp_mb(); > > return ret; > } > @@ -52,12 +52,12 @@ ____xchg(_u16, volatile short *m, unsigned long val) > " or %1,%2,%2\n" > " stq_c %2,0(%3)\n" > " beq %2,2f\n" > - __ASM__MB > ".subsection 2\n" > "2: br 1b\n" > ".previous" > : "=&r" (ret), "=&r" (val), "=&r" (tmp), "=&r" (addr64) > : "r" ((long)m), "1" (val) : "memory"); > + smp_mb(); > > return ret; > } > @@ -72,12 +72,12 @@ ____xchg(_u32, volatile int *m, unsigned long val) > " bis $31,%3,%1\n" > " stl_c %1,%2\n" > " beq %1,2f\n" > - __ASM__MB > ".subsection 2\n" > "2: br 1b\n" > ".previous" > : "=&r" (val), "=&r" (dummy), "=m" (*m) > : "rI" (val), "m" (*m) : "memory"); > + smp_mb(); > > return val; > } > @@ -92,12 +92,12 @@ ____xchg(_u64, volatile long *m, unsigned long val) > " bis $31,%3,%1\n" > " stq_c %1,%2\n" > " beq %1,2f\n" > - __ASM__MB > ".subsection 2\n" > "2: br 1b\n" > ".previous" > : "=&r" (val), "=&r" (dummy), "=m" (*m) > : "rI" (val), "m" (*m) : "memory"); > + smp_mb(); > > return val; > } > @@ -150,12 +150,12 @@ ____cmpxchg(_u8, volatile char *m, unsigned char old, unsigned char new) > " stq_c %2,0(%4)\n" > " beq %2,3f\n" > "2:\n" > - __ASM__MB > ".subsection 2\n" > "3: br 1b\n" > ".previous" > : "=&r" (prev), "=&r" (new), "=&r" (tmp), "=&r" (cmp), "=&r" (addr64) > : "r" ((long)m), "Ir" (old), "1" (new) : "memory"); > + smp_mb(); > > return prev; > } > @@ -177,12 +177,12 @@ ____cmpxchg(_u16, volatile short *m, unsigned short old, unsigned short new) > " stq_c %2,0(%4)\n" > " beq %2,3f\n" > "2:\n" > - __ASM__MB > ".subsection 2\n" > "3: br 1b\n" > ".previous" > : "=&r" (prev), "=&r" (new), "=&r" (tmp), "=&r" (cmp), "=&r" (addr64) > : "r" ((long)m), "Ir" (old), "1" (new) : "memory"); > + smp_mb(); > > return prev; > } > @@ -200,12 +200,12 @@ ____cmpxchg(_u32, volatile int *m, int old, int new) > " stl_c %1,%2\n" > " beq %1,3f\n" > "2:\n" > - __ASM__MB > ".subsection 2\n" > "3: br 1b\n" > ".previous" > : "=&r"(prev), "=&r"(cmp), "=m"(*m) > : "r"((long) old), "r"(new), "m"(*m) : "memory"); > + smp_mb(); > > return prev; > } > @@ -223,12 +223,12 @@ ____cmpxchg(_u64, volatile long *m, unsigned long old, unsigned long new) > " stq_c %1,%2\n" > " beq %1,3f\n" > "2:\n" > - __ASM__MB > ".subsection 2\n" > "3: br 1b\n" > ".previous" > : "=&r"(prev), "=&r"(cmp), "=m"(*m) > : "r"((long) old), "r"(new), "m"(*m) : "memory"); > + smp_mb(); > > return prev; > } > -- > 2.7.4 >