From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751699AbdHCOzu (ORCPT ); Thu, 3 Aug 2017 10:55:50 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52167 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751010AbdHCOzq (ORCPT ); Thu, 3 Aug 2017 10:55:46 -0400 Date: Thu, 3 Aug 2017 07:55:14 -0700 From: "Paul E. McKenney" To: Boqun Feng Cc: Will Deacon , 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: <20170731090535.rjgnoewqg7mhzr55@hirez.programming.kicks-ass.net> <20170731110403.ou3zqsp3uviqorkz@tardis> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170803135718.wx2lwlm5aglvhyh5@tardis> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17080314-0056-0000-0000-000003B1291C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007477; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000216; SDB=6.00897002; UDB=6.00448784; IPR=6.00677185; 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 14:55:16 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17080314-0057-0000-0000-000007E75399 Message-Id: <20170803145514.GS3730@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-1708030230 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. ;-) Thanx, Paul > r1 = READ_ONCE(*z); > } > > P2(int *x, int *z) > { > WRITE_ONCE(*z, 1); > smp_mb(); > r2 = READ_ONCE(*x); > } > > exists > (0:r0=0 /\ 1:r1=0 /\ 2:r2=0 ) > > Should we forbid the outcome in the exists-clause? I ask because I want > to know whether we can just treat atomic_inc() as a store, because if I > replace atomic_inc() with a WRITE(*y, 6), IIUC, the current model says > this could happen. > > Thoughts? > > Regards, > Boqun