Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1712357pxv; Fri, 23 Jul 2021 15:31:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7MbF3zIBPDkg1IlpHNkRTnDcI9cBfh3fF/iZSMekCanKb564i4FdI83xSHRNwVd1VniXl X-Received: by 2002:aa7:c9d8:: with SMTP id i24mr8136719edt.79.1627079514641; Fri, 23 Jul 2021 15:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627079514; cv=none; d=google.com; s=arc-20160816; b=g6mUrjaWJqodKZsIBHV8h4YM1cuYXada4qeUVhurHhRQNfkSbufwvJw4cdtUu5lMWN lxP0O4ELApNZSgvo+iVkq5f36dFci1Q2bBNOKWjgLi5BpLJqItoY0HtMw+kLfhuswbH8 gfjpR4ShJAbRKKdn6zo/T7ZI0hVqDSALIOPy59mTfbrjS2OMY/YAH1JYL5rjTo6gr5rA mNOvjA58qY7MuiWTeWnV7iWQE2IvcLP5ZPBBkrAFvwS2T8LE45GpWiTXyRfFCnWaYhAd wFn9KiK7+TXf9fcjQCql+LWZwP/lTt9gsMJ04NRkOlh+OR2swVpCvdQHylSRaUC3zVNX 37Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=T49pnXWhRheS13k/AxtZJoYTG7pwBVrscoOVMyER+/o=; b=sH/GzMLMQxyBnpUtDWOBNTSQHy3pci4lrn/kzNVe5RM4VirNiXAgQB8P7CCygbIWLN XRtF0wtJO+A3Khl788a6mKuFHp+ggrwK17q8Lv8q7nDY5Sqe+nGKOND7AIuBpDB5mj4w XwbjwpwiakG5fXnLqh+GWhBp88Sh2xCSEs8zCA+cVlx9VPuuH+mz6ErVnWlAbXaSbF6T +Qu0Dj/2DA6/u48YBXU/ENkQnV/eOjTGuId1MF3lDrYv2H9blA8Y6qEUOoy1qvMaaShI 8eZlACYQrVY3Lmv1dJeYnH04IdcTXD3QIiQ9htnDJeXvXXwYl4pgLlgUeV4PtyiqZp6X o/rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J7fL4Y9X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id si7si35693159ejb.102.2021.07.23.15.31.31; Fri, 23 Jul 2021 15:31:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J7fL4Y9X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232902AbhGWVtE (ORCPT + 99 others); Fri, 23 Jul 2021 17:49:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:41416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231742AbhGWVtE (ORCPT ); Fri, 23 Jul 2021 17:49:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3979E60EB4; Fri, 23 Jul 2021 22:29:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627079377; bh=qRJyfh+7D09m8pZJaY6uYPKV4tneuGptPCd6fBQITO0=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=J7fL4Y9XWaJAJM908DMygHSgOSixUqnI2OOybMonGeG/hb0YI3Um8h3x1K1GU+bur QjGUAqJOXzOgj5xLxbJ8pS2jAUMKJgSVs6VvMwdFK66VhHW/y5bw5xHI9wmHJIGah6 r/BglaDD0HmV/8dXy4t4Mkz9PxvxqvbF9eLfLc3ntLU2FvxyzY597yIf4zd0hNZ3oV PhBOfaKerLn6bH9E5RUpoRDaDtM8aVZYGjweolJoqXI7ZeIugQNK3vSIiczNA6uOSm MFpcDKsivjI8zzoDPCyYqEoKnHEc7I7d0/Asb/CrdHIgReKOt5esON5EIJoYSfOfDD 9r1w/a8dcUvpA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 0C0785C0611; Fri, 23 Jul 2021 15:29:37 -0700 (PDT) Date: Fri, 23 Jul 2021 15:29:37 -0700 From: "Paul E. McKenney" To: Alan Stern Cc: Manfred Spraul , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, 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 Subject: Re: [PATCH memory-model 2/4] tools/memory-model: Add example for heuristic lockless reads Message-ID: <20210723222937.GM4397@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20210721210726.GA828672@paulmck-ThinkPad-P17-Gen-1> <20210721211003.869892-2-paulmck@kernel.org> <20210723020846.GA26397@rowland.harvard.edu> <20210723130554.GA38923@rowland.harvard.edu> <20210723163008.GG4397@paulmck-ThinkPad-P17-Gen-1> <20210723170820.GB46562@rowland.harvard.edu> <20210723203248.GL4397@paulmck-ThinkPad-P17-Gen-1> <20210723210347.GA53526@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210723210347.GA53526@rowland.harvard.edu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 23, 2021 at 05:03:47PM -0400, Alan Stern wrote: > On Fri, Jul 23, 2021 at 01:28:11PM -0700, Paul E. McKenney wrote: > > On Fri, Jul 23, 2021 at 02:11:38PM -0400, Alan Stern wrote: > > > In other words, if the second read races with the WRITE_ONCE, it needs > to > > > get either the value before the write or the value after the write; > > > nothing else will do because it isn't a heuristic here. Fair point. > > > > > > > (If the value changes immediately after being read, the fact that > > > > ->f_lock is held prevents begin_global() from completing.) > > > > > > This seems like something worth explaining in the document. That > > > "IMPORTANT" comment doesn't really get the full point across. > > > > How about this comment instead? > > > > /* This works even if data_race() returns nonsense. */ > > That's somewhat better. > > > On Fri, Jul 23, 2021 at 01:32:48PM -0700, Paul E. McKenney wrote: > > On Fri, Jul 23, 2021 at 01:08:20PM -0400, Alan Stern wrote: > > > This doesn't mention the reason for the acquire-release > > > synchronization of global_flag. It's needed because work done between > > > begin_global() and end_global() can affect a foo structure without > > > holding its private f_lock member, and we want all such work to be > > > visible to other threads when they call do_something_locked() later. > > > > Like this added paragraph at the end? > > > > The smp_load_acquire() and smp_store_release() are required > > because changes to a foo structure between calls to begin_global() > > and end_global() are carried out without holding that structure's > > ->f_lock. The smp_load_acquire() and smp_store_release() > > ensure that the next invocation of do_something() from the call > > to do_something_locked() that acquires that ->f_lock will see > > those changes. > > I'd shorten the last sentence: > > The smp_load_acquire() and smp_store_release() ensure that the > next invocation of do_something() from do_something_locked() > will see those changes. Sold! ;-) Thanx, Paul