From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751872AbdHCQ75 (ORCPT ); Thu, 3 Aug 2017 12:59:57 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42439 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751932AbdHCQ6V (ORCPT ); Thu, 3 Aug 2017 12:58:21 -0400 Date: Thu, 3 Aug 2017 09:58:16 -0700 From: "Paul E. McKenney" To: Will Deacon Cc: Boqun Feng , Peter Zijlstra , linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner , Randy Dunlap Subject: Re: [RFC][PATCH v3]: documentation,atomic: Add new documents Reply-To: paulmck@linux.vnet.ibm.com References: <20170731174345.GL3730@linux.vnet.ibm.com> <20170801090121.edo7mekhw3sann4h@hirez.programming.kicks-ass.net> <20170801101900.GB8702@arm.com> <20170801114744.evjjfviqhu5kgu7v@hirez.programming.kicks-ass.net> <20170801121713.GH8702@arm.com> <20170801161412.GW3730@linux.vnet.ibm.com> <20170802094531.GA15748@arm.com> <20170803135718.wx2lwlm5aglvhyh5@tardis> <20170803145514.GS3730@linux.vnet.ibm.com> <20170803161223.GF20783@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170803161223.GF20783@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17080316-2213-0000-0000-000002043261 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000216; SDB=6.00897042; UDB=6.00448809; IPR=6.00677226; BA=6.00005509; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016516; XFM=3.00000015; UTC=2017-08-03 16:58:18 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17080316-2214-0000-0000-000057192BC8 Message-Id: <20170803165816.GY3730@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-03_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-1706020000 definitions=main-1708030260 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 03, 2017 at 05:12:24PM +0100, Will Deacon wrote: > On Thu, Aug 03, 2017 at 07:55:14AM -0700, Paul E. McKenney wrote: > > On Thu, Aug 03, 2017 at 10:05:16PM +0800, Boqun Feng wrote: > > > Hi Will, > > > > > > On Wed, Aug 02, 2017 at 10:45:32AM +0100, Will Deacon wrote: > > > [...] > > > > > > > > It's worth noting that we don't have the problem with any value-returning > > > > atomics, so all flavours of xchg in this test would be forbidden on arm64 > > > > too. > > > > > > > > > C C-WillDeacon-MP+o-r+ai-rmb-o.litmus > > > > > > > > > > (* > > > > > * Expected result: Never. > > > > > * > > > > > * Desired litmus test, with atomic_inc() emulated by xchg_relaxed(): > > > > > * > > > > > * WRITE_ONCE(x, 1); atomic_inc(&y); > > > > > * r0 = xchg_release(&y, 5); smp_rmb(); > > > > > * r1 = READ_ONCE(x); > > > > > * > > > > > * > > > > > * WARN_ON(r0 == 0 && r1 == 0); > > > > > *) > > > > > > > > > > { > > > > > } > > > > > > > > > > P0(int *x, int *y) > > > > > { > > > > > WRITE_ONCE(*x, 1); > > > > > r0 = xchg_release(y, 5); > > > > > } > > > > > > > > > > P1(int *x, int *y) > > > > > { > > > > > r2 = xchg_relaxed(y, 1); > > > > > smp_rmb(); > > > > > r1 = READ_ONCE(*x); > > > > > } > > > > > > > > > > exists > > > > > (0:r0=0 /\ 1:r1=0) > > > > > > > > > > > How about a litmus test like this? > > > > > > C C-AMO-global-transitivity.litmus > > > > > > { > > > } > > > > > > P0(int *x, int *y) > > > { > > > WRITE_ONCE(*x, 1); > > > r0 = xchg_release(y, 5); > > > } > > > > > > P1(int *y, int *z) > > > { > > > atomic_inc(y); > > > smp_mb(); > > > > I am going to guess that the smp_mb() enforces the needed ordering, > > but Will will let me know. ;-) > > Yup, that would be forbidden on arm64, and would also be forbidden if > you used WRITE_ONCE instead of atomic_inc (remember that we recently > became multi-copy atomic). Thank you for the confirmation! Thanx, Paul