From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751066AbeBQDZq (ORCPT ); Fri, 16 Feb 2018 22:25:46 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53321 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750763AbeBQDZo (ORCPT ); Fri, 16 Feb 2018 22:25:44 -0500 X-Google-Smtp-Source: AH8x224hWxrHG5utxMGHsadJMJSgz1bscAYKkCgLS1ERgkagsgOTZivk/uyItW1AkZ42gn5DfOG2lg== Date: Sat, 17 Feb 2018 04:25:35 +0100 From: Andrea Parri To: Alan Stern Cc: "Paul E. McKenney" , Akira Yokosawa , Kernel development list , mingo@kernel.org, Will Deacon , peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, Jade Alglave , Luc Maranget , Patrick Bellasi Subject: Re: [PATCH] tools/memory-model: remove rb-dep, smp_read_barrier_depends, and lockless_dereference Message-ID: <20180217032535.GA1125@andrea> References: <20180216165301.GF3617@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 16, 2018 at 05:22:55PM -0500, Alan Stern wrote: > Since commit 76ebbe78f739 ("locking/barriers: Add implicit > smp_read_barrier_depends() to READ_ONCE()") was merged for the 4.15 > kernel, it has not been necessary to use smp_read_barrier_depends(). > Similarly, commit 59ecbbe7b31c ("locking/barriers: Kill > lockless_dereference()") removed lockless_dereference() from the > kernel. > > Since these primitives are no longer part of the kernel, they do not > belong in the Linux Kernel Memory Consistency Model. This patch > removes them, along with the internal rb-dep relation, and updates the > revelant documentation. > > Signed-off-by: Alan Stern > > --- [...] > Index: usb-4.x/tools/memory-model/linux-kernel.def > =================================================================== > --- usb-4.x/tools/memory-model.orig/linux-kernel.def > +++ usb-4.x/tools/memory-model/linux-kernel.def > @@ -13,14 +13,12 @@ WRITE_ONCE(X,V) { __store{once}(X,V); } > smp_store_release(X,V) { __store{release}(*X,V); } > smp_load_acquire(X) __load{acquire}(*X) > rcu_assign_pointer(X,V) { __store{release}(X,V); } > -lockless_dereference(X) __load{lderef}(X) > rcu_dereference(X) __load{deref}(X) ^^^ __load{once} > > // Fences > smp_mb() { __fence{mb} ; } > smp_rmb() { __fence{rmb} ; } > smp_wmb() { __fence{wmb} ; } > -smp_read_barrier_depends() { __fence{rb_dep}; } > smp_mb__before_atomic() { __fence{before-atomic} ; } > smp_mb__after_atomic() { __fence{after-atomic} ; } > smp_mb__after_spinlock() { __fence{after-spinlock} ; } > Index: usb-4.x/tools/memory-model/Documentation/cheatsheet.txt > =================================================================== > --- usb-4.x/tools/memory-model.orig/Documentation/cheatsheet.txt > +++ usb-4.x/tools/memory-model/Documentation/cheatsheet.txt > @@ -6,8 +6,7 @@ > Store, e.g., WRITE_ONCE() Y Y > Load, e.g., READ_ONCE() Y Y Y > Unsuccessful RMW operation Y Y Y > -smp_read_barrier_depends() Y Y Y > -*_dereference() Y Y Y Y > +rcu_dereference() Y Y Y Y > Successful *_acquire() R Y Y Y Y Y Y > Successful *_release() C Y Y Y W Y > smp_rmb() Y R Y Y R Akira's observation about READ_ONCE extends to all (annotated) loads. In fact, it also applies to loads corresponding to unsuccessful RMW operations; consider, for example, the following variation of MP+onceassign+derefonce: C T { y=z; z=0; } P0(int *x, int **y) { WRITE_ONCE(*x, 1); smp_store_release(y, x); } P1(int **y, int *z) { int *r0; int r1; r0 = cmpxchg_relaxed(y, z, z); r1 = READ_ONCE(*r0); } exists (1:r0=x /\ 1:r1=0) The final state is allowed w/o the patch, and forbidden w/ the patch. This also reminds me of 5a8897cc7631fa544d079c443800f4420d1b173f ("locking/atomics/alpha: Add smp_read_barrier_depends() to _release()/_relaxed() atomics") (that we probably want to mention in the commit message). Andrea > >