Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751970AbdGaLED (ORCPT ); Mon, 31 Jul 2017 07:04:03 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:34359 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750979AbdGaLEB (ORCPT ); Mon, 31 Jul 2017 07:04:01 -0400 Date: Mon, 31 Jul 2017 19:04:03 +0800 From: Boqun Feng To: Peter Zijlstra Cc: Will Deacon , Paul McKenney , linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner , Randy Dunlap Subject: Re: [RFC][PATCH v3]: documentation,atomic: Add new documents Message-ID: <20170731110403.ou3zqsp3uviqorkz@tardis> References: <20170609092450.jwmldgtli57ozxgq@hirez.programming.kicks-ass.net> <20170609154442.GB9236@arm.com> <20170609193604.ncw3hhgvewzc3h5u@hirez.programming.kicks-ass.net> <20170611135632.sl72klbeklelupej@tardis> <20170612144929.3wiwtbqopsfpm3qk@hirez.programming.kicks-ass.net> <20170726115328.2sxiitivlnlq64dk@hirez.programming.kicks-ass.net> <20170726124750.vktrn5zi2gmpzfru@tardis> <20170731090535.rjgnoewqg7mhzr55@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="haur2sczzbhe6hhg" Content-Disposition: inline In-Reply-To: <20170731090535.rjgnoewqg7mhzr55@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2514 Lines: 83 --haur2sczzbhe6hhg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 31, 2017 at 11:05:35AM +0200, Peter Zijlstra wrote: > On Wed, Jul 26, 2017 at 08:47:50PM +0800, Boqun Feng wrote: >=20 > > > + > > > +Further, while something like: > > > + > > > + smp_mb__before_atomic(); > > > + atomic_dec(&X); > > > + > > > +is a 'typical' RELEASE pattern, the barrier is strictly stronger than > > > +a RELEASE. Similarly for something like: > > > + > >=20 > > .. at here. Maybe you planned to put stronger ACQUIRE pattern? >=20 > Yes, although I struggled to find a sensible one. The problem is that > ACQUIRE is on loads and value returning atomics have an ACQUIRE variant, > so why would you ever want to use smp_mb__after_atomic() for this. >=20 >=20 > That is, the best I could come up with is something like: >=20 > val =3D atomic_fetch_or_relaxed(1, &var); > smp_mb__after_atomic(); >=20 > But in that case we should've just written: >=20 > val =3D atomic_fetch_or_acquire(1, &var); >=20 Agreed. And besides, in memory-barriers.txt, the wording is: (*) smp_mb__before_atomic(); (*) smp_mb__after_atomic(); These are for use with atomic (such as add, subtract, increment and decrement) functions that don't return a value, especially when used f= or reference counting.=20 So actually, using smp_mb__after_atomic() for ACQUIRE is a misuse. >=20 > Suggestions? As a result, I think it's better we say smp_mb__{before,after}_atomic() are only for 1) non-value-returning RmW atomic ops, 2) {set,clear,change}_bit and 3) internal use of atomic primitives(e.g. the generic version of fully ordered atomics). 1) prevents people to use it for an ACQUIRE, but allows for a RELEASE. 1) & 2) makes atomic_t.txt consistent with memory-barriers.txt 3) explains our usage of those barriers internally. Thoughts? Regards, Boqun --haur2sczzbhe6hhg Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEj5IosQTPz8XU1wRHSXnow7UH+rgFAll/Dp8ACgkQSXnow7UH +rjiuggAj+Iv5pq2qq1ua8IFhoZb4KUSg649UQER+PwfiWLpXwcpzOPvBPG7hZ7E Zd/JE+nGYjq+5myhD38dK3hKAk9LjHeM7Lk5eZJI55M4fA/YJGTTFBz3wCPsuiSH xKucZp9cCc4GlM/O/u3vqqSdMjbViBmDeQGYwvwDol+cSRHCJNMtY3SvGzEHqmdC Qa/kygKsIFkcgVj2cGXq7R7pVuwSW5cTy3EApkPkeua36vMhasZGQwS8YLQR+r03 BoQVBVGpMM/J9HqvCYKoVENCLku/2LGPCDqbGxvcNapnISGK2XP9LG09LLiElz2I TXkdTRGmx6yvd50/M0+9FFlpyuWY8g== =pI9p -----END PGP SIGNATURE----- --haur2sczzbhe6hhg--