Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp23355imu; Fri, 14 Dec 2018 13:40:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/UZsJ7U7SXs5mxiePQVrVn/X1lY3LA1qqBrdanBKLedpxlpwiKlwk9XgZUQXAB9AhOb2JBG X-Received: by 2002:a17:902:50e:: with SMTP id 14mr4322213plf.141.1544823646619; Fri, 14 Dec 2018 13:40:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544823646; cv=none; d=google.com; s=arc-20160816; b=s+bF+OoAhVNHP8JJ3FHjGRPc0hOsxVA5lJUsRvksLLFNBDv0e4799nHF+z4hyyMM/2 zSWDKTfG+kX6mvs3n0SBtsXxPFJDGhBRCDS4AAWRmvdQDJVkft31fldqkYQkWlxEc1C0 q+RHtQH0wh8dROr50wh+OLLKPooXdPtKkBou1+A7T090VVSKOT8Er+SPeflbkd+x89wR mRjcU3UBq0gWD3h2C6xOcC5P5Rb2etkPq/2V20YFrvvlYzoxKzWeNVWVeTNe5f4FKXo7 doEq6I/Pw+TwQzvYeJXPL295inqSZ3s/YFcEYNH5DuBc/lDFDfEMyG28OfHpvA8O+d+b fXCw== 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=W0QRQxiCXKzXGycbb24FSyVGhsCdlOE85vmq9ppgoVo=; b=cXSLziBbwpo6/zxnnWRhHprjjeIPDZdE8NIUwj9K+S0K3mzdbXIUsGo5ZwovRcJvH0 KmvkmaSBnq0q9JwtkGRMzd8rJOdU7T4MBV6V+x6L4hdtWFmrp+uvrPfepNPZRlCUhYSU Zc72c1+xJp1ld1yrNigMZ/RTTTzCcZ280R42mrFfpgfwvzfgdEacbsFrqKHhq/Lo2adX pl0BfNutx7I6kdoqurI89srRLAK1OKy8XftvNDhuH2XMsxScMw81xyRe2A7WaUFn2uhs KMdB2Tiu6NlPlpGPil1LdbJESXHlLk9RIAYw1iFHKHH4t0bFMx1chV/EdN0p6h4Y8sKY +R1A== 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 133si5217918pfw.64.2018.12.14.13.40.31; Fri, 14 Dec 2018 13:40:46 -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 S1730987AbeLNVjf (ORCPT + 99 others); Fri, 14 Dec 2018 16:39:35 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:60414 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1730887AbeLNVjf (ORCPT ); Fri, 14 Dec 2018 16:39:35 -0500 Received: (qmail 6090 invoked by uid 2102); 14 Dec 2018 16:39:34 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 14 Dec 2018 16:39:34 -0500 Date: Fri, 14 Dec 2018 16:39:34 -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: <20181214184344.GW4170@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 Fri, 14 Dec 2018, Paul E. McKenney wrote: > I would say that sys_membarrier() has zero-sized read-side critical > sections, either comprising a single instruction (as is the case for > synchronize_sched(), actually), preempt-disable regions of code > (which are irrelevant to userspace execution), or the spaces between > consecutive pairs of instructions (as is the case for the newer > IPI-based implementation). > > The model picks the single-instruction option, and I haven't yet found > a problem with this -- which is no surprise given that, as you say, > an actual implementation makes this same choice. I believe that for RCU tests the LKMM gives the same results for length-zero critical sections interspersed between all the instructions and length-one critical sections surrounding all instructions (except synchronize_rcu). But the proof is tricky and I haven't checked it carefully. > > > The other thing that took some time to get used to is the possibility > > > of long delays during sys_membarrier() execution, allowing significant > > > execution and reordering between different CPUs' IPIs. This was key > > > to my understanding of the six-process example, and probably needs to > > > be clearly called out, including in an example or two. > > > > In all the examples I'm aware of, no more than one of the IPIs > > generated by each sys_membarrier call really matters. (Of course, > > there's no way to know in advance which one it will be, so you have to > > send an IPI to every CPU.) The execution delays and reordering > > between different CPUs' IPIs don't appear to be significant. > > Well, there are litmus tests that are allowed in which the allowed > execution is more easily explained in terms of delays between different > CPUs' IPIs, so it seems worth keeping track of. > > There might be a litmus test that can tell the difference between > simultaneous and non-simultaneous IPIs, but I cannot immediately think of > one that matters. Might be a failure of imagination on my part, though. P0 P1 P2 Wc=1 [mb01] Rb=1 memb Wa=1 Rc=0 Ra=0 Wb=1 [mb02] The IPIs have to appear in the positions shown, which means they cannot be simultaneous. The test is allowed because P2's reads can be reordered. Alan