Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2532152ybf; Mon, 2 Mar 2020 10:30:05 -0800 (PST) X-Google-Smtp-Source: ADFU+vu9IrgXSR9JtVuGoTiSLyuBQC+vkb2GtjMXKRttz7SaTyrF743v2XgkFxhJOCq8TD9NG7DU X-Received: by 2002:a9d:7695:: with SMTP id j21mr378994otl.157.1583173804973; Mon, 02 Mar 2020 10:30:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583173804; cv=none; d=google.com; s=arc-20160816; b=B5OWhXWN0KCrpynHEWXVxhZmRx3mbadj1VzyksUCqzeTgeFgre1YDpXMi56xGFD0OR jO33/0m1CO1RWf64S7rWt9FpXFjfvK60ynuIBGeimwlBcL74/qt/Qo+l9ndC+R88ZLcg bfDRYumM0Nip0G9Td14kh2Cgbhf10/X2O1lCdK/MJhSJmo8udL+5g5ri3IhLDL8CZni3 tmkLlqeJ6pwNVV7M/XcjdlI6Sh7u1d7eY1r81KgxqZFc1BF7eQRxY5e/PYfD7XHfu+iJ 5RMhag/5GzvDYSkOBEoQylcQQLFaxVR4nn4VhHJDslHSDYSfQLyITwJ/qpqsYdV9dn7i qiqw== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=WFE07g+KlPJv8299DawKKjQjhqW1Zo+ieRU5MiMCbnI=; b=FE8iUF1tEx8Yi9QX98B8JoQUCKd42l6ySTEnuDjGm/5nDkBTQylebhYMJXcc03YXAx vKMMliBvDrX7W0G2EO8MahkJz1h7pKvTTKOINVnUmxsSCgpACUUF70nwyLE6ZdQyx7Tt qj6r3oxhQwv//2b5yXcAPcAtwZ8EFvo0c9J6J7sng5LCmi+q5gRpgjhRfcheTbeaKiNb ZQz9R2of7Et1D+5UPT4U5s8Usii1NCZGnHNOf1CGsoblCGWUJKmLWQJaJfXYcQLHr3xo 9WK7B9POZtiNAg3/Jlqp2sCi95qFmH77bRxYqfh2KBZmfciDikKzJjaJy7PhK2t222j0 wrwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=A8NiIANr; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y186si6610571oig.241.2020.03.02.10.29.53; Mon, 02 Mar 2020 10:30:04 -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=@kernel.org header.s=default header.b=A8NiIANr; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727461AbgCBS2n (ORCPT + 99 others); Mon, 2 Mar 2020 13:28:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:51480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbgCBS2n (ORCPT ); Mon, 2 Mar 2020 13:28:43 -0500 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2EAD620842; Mon, 2 Mar 2020 18:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583173722; bh=z9zhIT1vPAfrmNBpotFtHXIOWrViALvBVI5P6LPwJo4=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=A8NiIANrs8V+JX1DzQjlfsGUvZ4fkFUjfUaA/kcPUFm2MbTlTdbjE9/2LfwNdZJMY p0AqjCmRzNP85wfdeYrnb9pCmeWMEyWOs/eqBO3GQKG4KBMG1QvTIFzL5LXhvnp5ue 1cjDZOIheRXNqDUcDOhFHtPRJyrfCL3uKozt7rJE= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 073EC35226C8; Mon, 2 Mar 2020 10:28:42 -0800 (PST) Date: Mon, 2 Mar 2020 10:28:42 -0800 From: "Paul E. McKenney" To: David Laight Cc: 'Marco Elver' , "linux-kernel@vger.kernel.org" , "kasan-dev@googlegroups.com" , "stern@rowland.harvard.edu" , "parri.andrea@gmail.com" , "will@kernel.org" , "peterz@infradead.org" , "boqun.feng@gmail.com" , "npiggin@gmail.com" , "dhowells@redhat.com" , "j.alglave@ucl.ac.uk" , "luc.maranget@inria.fr" , "akiyks@gmail.com" , "dlustig@nvidia.com" , "joel@joelfernandes.org" , "linux-arch@vger.kernel.org" Subject: Re: [PATCH v2] tools/memory-model/Documentation: Fix "conflict" definition Message-ID: <20200302182841.GJ2935@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200302141819.40270-1-elver@google.com> <8d5fdc95ed3847508bf0d523f41a5862@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8d5fdc95ed3847508bf0d523f41a5862@AcuMS.aculab.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 02, 2020 at 05:44:11PM +0000, David Laight wrote: > From: Marco Elver > > Sent: 02 March 2020 14:18 > > > > The definition of "conflict" should not include the type of access nor > > whether the accesses are concurrent or not, which this patch addresses. > > The definition of "data race" remains unchanged. > > > > The definition of "conflict" as we know it and is cited by various > > papers on memory consistency models appeared in [1]: "Two accesses to > > the same variable conflict if at least one is a write; two operations > > conflict if they execute conflicting accesses." > > I'm pretty sure that Linux requires that the underlying memory > subsystem remove any possible 'conflicts' by serialising the > requests (in an arbitrary order). > > So 'conflicts' are never relevant. > > There are memory subsystems where conflicts MUST be avoided. > For instance the fpga I use have some dual-ported memory. > Concurrent accesses on the two ports for the same address > must (usually) be avoided if one is a write. > Two writes will generate corrupt memory. > A concurrent write+read will generate a garbage read. > In the special case where the two ports use the same clock > it is possible to force the read to be 'old data' but that > constrains the timings. > > On such systems the code must avoid conflicting cycles. That would be yet another definition of "conflicts". Quite relevant on some older hardware I have worked with. But what we are concerned with here are cases where (as you say) the memory subsystem will do just fine, but where the fact that the memory subsystem is called upon to do the necessary serialization constitutes a bug of some sort. There are unfortunately a wide variety of definitions and opinions as to exactly what sorts of conflicts constitute bugs. The generic pattern for these definitions and opinions is "a concurrent set of insufficiently marked accesses to a given location, at least one of which is a write". The differences in definitions and opinions center around exactly what is meant by the word "insufficiently" in this last sentence. We will probably be tolerating some variety of definitions in the kernel, and given the wide variety of code contained therein, this should be just fine. Thanx, Paul