Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1000056imu; Thu, 13 Dec 2018 07:52:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/VzV6FLbJvccjYagpk//mgohFRqXmeL5hV3kOqu1/wjwS93UkyMzigSqAfbDZFazW4uzBsu X-Received: by 2002:a17:902:76cb:: with SMTP id j11mr16981786plt.179.1544716365198; Thu, 13 Dec 2018 07:52:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544716365; cv=none; d=google.com; s=arc-20160816; b=CfJ4J1jmtWzjyDaND3TetyDCWzN3p1DWTe1o3t8UK5fkNDQ2O1ILD6+BOySsR65/LT 4zwpreDTgpSKBsCcLIW3BAbmrTj/3C2/7cICYj4s4Bo+cLkwF3npxrmwvEfQivNPGmLX YAGZXHJ/xHaLlc0JjVs+kkd3Aidv89wsL7iH1jm5Wfq5ENbyUeEsz5DShslWPYTbxldJ f60tfo2pYqUARrRnzMYru9CO5gmOpCjOvHV4fi3DVt572QS+GruRrhiQNYx4UelhQGKS OQ9lJqdf0V69B9osrIUJUUPwiPphGw2oBIMiUE5b7T6SB9EMB0X6gcZXnm/kj53Bf8bs kt4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=o4lAe8U1EllMFs3Zo9i2pptaVdfPxBffUk2h308UaK4=; b=BkD/VIr8J0NcfWlymkD44PenRnRlpDgC98uMpTakuDBCR+hVpA3pTIghDpHCFNS1C0 zs1s8aZfGUSusePkmRvLZDsGJbCwmlW+UyDgh5iV7qrlcDJi1jKMiGYzGpuIRWz5CN7s rbaX/sVghYlXPrguBlnrbqBue5pDk8oFzv72P+zbYeWhbL0DNxCjgBRGMkl+xZ610t1y H1HiYZuX+y8F5O3Ohhj3x8VfVsvci6OaD7LuZJxLBCplntM/wHediK4HXVwfE6idSXPo eA8pdTIM3oaCNOy460FvjrmE0+RNzzISym1nRR+HYhBn6ma902gvdX3mz0qiZtp0dRzj /0dw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j14si1860180pgi.354.2018.12.13.07.52.25; Thu, 13 Dec 2018 07:52:45 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729035AbeLMPtv (ORCPT + 99 others); Thu, 13 Dec 2018 10:49:51 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:41182 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1728965AbeLMPtu (ORCPT ); Thu, 13 Dec 2018 10:49:50 -0500 Received: (qmail 2270 invoked by uid 2102); 13 Dec 2018 10:49:49 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 13 Dec 2018 10:49:49 -0500 Date: Thu, 13 Dec 2018 10:49:49 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: "Paul E. McKenney" cc: David Goldblatt , , Florian Weimer , , , , , , , , , , , , , , Subject: Re: [PATCH] Linux: Implement membarrier function In-Reply-To: <20181212224931.GD4170@linux.ibm.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 12 Dec 2018, Paul E. McKenney wrote: > > Well, what are you trying to accomplish? Do you want to find an > > argument similar to the one I posted for the 6-CPU test to show that > > this test should be forbidden? > > I am trying to check odd corner cases. Your sys_membarrier() model > is quite nice and certainly fits nicely with the rest of the model, > but where I come from, that is actually reason for suspicion. ;-) > > All kidding aside, your argument for the 6-CPU test was extremely > valuable, as it showed me a way to think of that test from an > implementation viewpoint. Then the question is whether or not that > viewpoint actually matches the model, which seems to be the case thus far. It should, since I formulated the reasoning behind that viewpoint directly from the model. The basic idea is this: By induction, show that whenever we have A ->rcu-fence B then anything po-before A executes before anything po-after B, and furthermore, any write which propagates to A's CPU before A executes will propagate to every CPU before B finishes (i.e., before anything po-after B executes). Using this, show that whenever X ->rb Y holds then X must execute before Y. That's what the 6-CPU argument did. In that litmus test we have mb2 ->rcu-fence mb23, Rc ->rb Re, mb1 ->rcu-fence mb14, Rb ->rb Rf, mb0 ->rcu-fence mb05, and lastly Ra ->rb Ra. The last one is what shows that the test is forbidden. > A good next step would be to automatically generate random tests along > with an automatically generated prediction, like I did for RCU a few > years back. I should be able to generalize my time-based cheat for RCU to > also cover SRCU, though sys_membarrier() will require a bit more thought. > (The time-based cheat was to have fixed duration RCU grace periods and > RCU read-side critical sections, with the grace period duration being > slightly longer than that of the critical sections. The number of > processes is of course limited by the chosen durations, but that limit > can easily be made insanely large.) Imagine that each sys_membarrier call takes a fixed duration and each other instruction takes slightly less (the idea being that each instruction is a critical section). Instructions can be reordered (although not across a sys_membarrier call), but no matter how the reordering is done, the result is disallowed. > I guess that I still haven't gotten over being a bit surprised that the > RCU counting rule also applies to sys_membarrier(). ;-) Why not? They are both synchronization mechanisms with heavy-weight write sides and light-weight read sides, and most importantly, they provide the same Guarantee. Alan