From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751985AbdHCQMb (ORCPT ); Thu, 3 Aug 2017 12:12:31 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:42980 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751948AbdHCQMY (ORCPT ); Thu, 3 Aug 2017 12:12:24 -0400 Date: Thu, 3 Aug 2017 17:12:24 +0100 From: Will Deacon To: "Paul E. McKenney" 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 Message-ID: <20170803161223.GF20783@arm.com> References: <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> <20170803145514.GS3730@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170803145514.GS3730@linux.vnet.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). Will