Received: by 10.223.185.116 with SMTP id b49csp1886335wrg; Sat, 17 Feb 2018 07:25:33 -0800 (PST) X-Google-Smtp-Source: AH8x226P2MzfGeeu3KXvTmgFgxm393dTqI/ZQSPZj6B+b9AdkpuqiJHC3wo8zLxIFpkaXkNkoQsS X-Received: by 10.99.123.92 with SMTP id k28mr7980786pgn.167.1518881133274; Sat, 17 Feb 2018 07:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518881133; cv=none; d=google.com; s=arc-20160816; b=Y3e1uv5xvsGeQzQY0eHpOgNdkCP/QygmCx6QGrzDx1immHlVYaSuY01PVOwV1VOkG0 i6F3NX8TTbHVPcrx2CjYdXEV23Arp3hw32EG4WQCfEr5j3Krg8CuZALlNVqASYq5c3mq 0YkmAbFNhUsBv5aqjiUMudnoym7h1WjjJktqwrnRsw5YEptHtL5m4whygp0CqQgSw3WA JSO+DU8LcFV4kD1HnrVN98Laf2k3jhkXkbST5kQOXZvG0zgUHccrqyGeYLtILVwRmEjT 1JW85ldotiddAbOMGjwC/Hn75y9GaR2gflNYNQMwEEfNREd+WzQu5IoEZbIlThf7D1Bm 9ysQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=FJg5ZesPDS9Kv0JNbFLKZeSueB6QjdGllN7SXgeJKu8=; b=Wqqcqvb4Z4o/nhrwrnZs3biygmtGChQ529DPw2+Qt/j2VI1+tnbz51puh0y8rliP8G d/4najGZoNdj0rtf9sMQq3AnwT4aAKCo/LVnOoZBrvUOrO708SOiFHV7yroSZZL5G7DG P4EbQJo2tHXwxC1IDuplpn9UiTJ1YACbD8tpRVdvGnFYHIaYlVy6F+QqNTbU3TkDo0gc hKXJDv+1ZJwm0oLa3JsTYKOtfAqL7JMzKV6h7egs4aHVB0aK6ky3uqvk6S3SaOHUPB7S mUeb28X6GFKe6w8G+HsqgsU2DCuH7+cVK0IyfoIXJ6Gu8PQVWZj6dcf7CxogTRs/mKQp RBRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=P/NDVVDq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a185si7233524pgc.69.2018.02.17.07.25.05; Sat, 17 Feb 2018 07:25:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=P/NDVVDq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751073AbeBQPOW (ORCPT + 99 others); Sat, 17 Feb 2018 10:14:22 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:36308 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750977AbeBQPOV (ORCPT ); Sat, 17 Feb 2018 10:14:21 -0500 Received: by mail-wr0-f193.google.com with SMTP id u15so5560445wrg.3 for ; Sat, 17 Feb 2018 07:14:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=FJg5ZesPDS9Kv0JNbFLKZeSueB6QjdGllN7SXgeJKu8=; b=P/NDVVDqPsaKLfw3aIuZuZJ/jn0pu6j69dPybUjVFTH1ORb0B3vVuaMiIr0jt+puch bj3nlxSyV7U/1H9J9IOXKXPHtelIeyVHinvzWm+5tiTWjh0x7ocQsgINurGNMwavzywC IJIesvIPSd/3JFsChHwXv8UfR9nT2Bpoyi0pXGQATewczDKdxrKkTZ90kL6iHrMMoaYD FfP/o8g3WT00dP3tkU84ckWNPssZ4ReiJUY9WU+1DzaXIxXLa6rtmcR7HmNdCpEoNQjZ hNpWgFs2xp6S/JWurUOfnWwVQfdwZN69tYKCyrpY1xVusum+yd6kW9HopW0P0MbcnufZ rpPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FJg5ZesPDS9Kv0JNbFLKZeSueB6QjdGllN7SXgeJKu8=; b=YkJo797GfjQN22cTmEaX4CDqxNW65zXu62fmmyXW5gRQLmUFNcyMYbyVfnyTTRp0Z6 7KbMq5eRpSV1ZDV2HhYNKVulEqPWCb70KnEbvqMJj15hrbbDnFoShi3MiYNEjJiWPkW+ M1dZOUPrrBmNAIJDOze5r40nvmcNRRuZUGh8uX7GNFkdBPsBsK72V8awMtvhznT5xO61 ft124nhn3PWNq9lmVtFNUJrfZFE822L9QrU/qF9YhXjyz3hhriJGkh1XARXZHFXwU2HT HbM7oo1ERkpmzbXci4Q6HO2af5yRFAQtCkTAbpshj6+x4x9AJ2e5YS2yIf6m3RMjdeG5 Ii1A== X-Gm-Message-State: APf1xPBM4U234m4kaZr5TDUOOG9j26tHs17xvhMxODmq4J9aXm1vwrAx XGil1x498R319fmjB2kc0MIZJXNI X-Received: by 10.223.154.165 with SMTP id a34mr9269828wrc.85.1518880459998; Sat, 17 Feb 2018 07:14:19 -0800 (PST) Received: from andrea (dynamic-2a00-1028-8386-da8a-bdf8-a9ac-68df-debc.ipv6.broadband.iol.cz. [2a00:1028:8386:da8a:bdf8:a9ac:68df:debc]) by smtp.gmail.com with ESMTPSA id q15sm22070285wra.54.2018.02.17.07.14.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Feb 2018 07:14:19 -0800 (PST) Date: Sat, 17 Feb 2018 16:14:13 +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: <20180217151413.GA3785@andrea> References: <20180216165301.GF3617@linux.vnet.ibm.com> <20180217032535.GA1125@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180217032535.GA1125@andrea> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 17, 2018 at 04:25:35AM +0100, Andrea Parri wrote: > 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). Please also notice that 5a8897cc7631f only touched alpha's atomic.h: I see no corresponding commit/change on {,cmp}xchg.h (where the "mb" is currently conditionally executed). Andrea > > Andrea > > > > > >