Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp225610ybh; Mon, 20 Jul 2020 15:07:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKFNRgiQcrQRFvp9S4scrkchTvU2nRASCGa6OJ0F8Vdiifc21iqBwF57cQeR3zJ4Q5oQrE X-Received: by 2002:a17:906:3b83:: with SMTP id u3mr22233562ejf.207.1595282851386; Mon, 20 Jul 2020 15:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595282851; cv=none; d=google.com; s=arc-20160816; b=huhaVke0gN62QJexuIJXl3ojCbugLR7vC1bKfJmWuglogn3Hkku5aKlXT8cW+4ygMg mwXCI7m4YnFYdILvOJa4FZBZJzbhawtkIKPTo5AwGMMfDCm6izuEc5aBmStoenmmOeMK zI4Tyt7t/WydcZVYLX/VsVjKLbIT9IXmydWZp4BL+G/DM/vqX+CsXSBNaQUwEBHyZ2su wc3R35ilNsbIYr5AWkWw/+25MWDiMgJ0VUaesF/bymSTNpYyezAA/Sl0QByoObPsqVuC rMu9A8pJgKTEz/HM/BNxZUldcaf+xM1TY4EOby4zxLffdsqvwMDHoWXRw0bVGEK9wwCu nT3g== 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=Tzw+IueC3NwQR7SAj0gvWv8/mZua76TJ7aoin0NYeR8=; b=wExsbyT0/78zL/3yfaRHoDPpViB0udrbuGdtl2ZrAFz+4CTQM8j6jRNvgQCTuOhDj8 FLwSrK1U7J7ReiuNV5Y6iUQ6JRUIlV+hMwEIhxzS/Wqk5CxqmcENx53/YIZJiMrxAm/K cnojS6GmZ+RhBnYi+z3cjSe28AsdeHUTiHhCPcnnaqPTh/MMTUijQxRBs0M/H53daYAp 2XyPaujWgKrK6TpR0xuOwPwWl2mCe1K+NgCUQeRaOATHA+C1AUzznYljxA+bQnVCKWfW CTSCCywNIm9lJ9ucTWJwbpS2inniENbNctL2uRe0gdjnM+1tLlPkym67Q7V1ZUxatxiV J7dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GfYo84e5; 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 v16si11765328edr.93.2020.07.20.15.07.07; Mon, 20 Jul 2020 15:07:31 -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=default header.b=GfYo84e5; 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 S1726838AbgGTWGx (ORCPT + 99 others); Mon, 20 Jul 2020 18:06:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:33106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726021AbgGTWGw (ORCPT ); Mon, 20 Jul 2020 18:06:52 -0400 Received: from paulmck-ThinkPad-P72.home (50-39-111-31.bvtn.or.frontiernet.net [50.39.111.31]) (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 B425820729; Mon, 20 Jul 2020 22:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595282811; bh=6x2B6tHzk/AK+Gp4nhiVnHJOFQxF6ZQYhvHBPpGLxx8=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=GfYo84e5NH9ySeUlI335uKO6IHp9m/oJPecOGmfcLn7P6RguHpvYx/9GZHtn+Am9+ bMucw9MVP6y/46wsq4bkniwV2aKUaPzLds6Cih4EusxY4SAlt9Pkh3Ol1JcI5nrKUZ k/NpJoetfBLQT8T8U2fLrpiIykP7D2DHzkLU00N0= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 99A843522C1A; Mon, 20 Jul 2020 15:06:51 -0700 (PDT) Date: Mon, 20 Jul 2020 15:06:51 -0700 From: "Paul E. McKenney" To: peterz@infradead.org Cc: Matthew Wilcox , Alan Stern , Dave Chinner , Eric Biggers , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, Akira Yokosawa , Andrea Parri , Boqun Feng , Daniel Lustig , "Darrick J . Wong" , David Howells , Jade Alglave , Luc Maranget , Nicholas Piggin , Will Deacon Subject: Re: [PATCH] tools/memory-model: document the "one-time init" pattern Message-ID: <20200720220651.GV9247@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200717044427.68747-1-ebiggers@kernel.org> <20200718014204.GN5369@dread.disaster.area> <20200718140811.GA1179836@rowland.harvard.edu> <20200720013320.GP5369@dread.disaster.area> <20200720145211.GC1228057@rowland.harvard.edu> <20200720153911.GX12769@casper.infradead.org> <20200720160433.GQ9247@paulmck-ThinkPad-P72> <20200720164850.GF119549@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720164850.GF119549@hirez.programming.kicks-ass.net> 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, Jul 20, 2020 at 06:48:50PM +0200, peterz@infradead.org wrote: > On Mon, Jul 20, 2020 at 09:04:34AM -0700, Paul E. McKenney wrote: > > 2. If we were to say "unlock" instead of "release", consistency > > would demand that we also say "lock" instead of "acquire". > > But "lock" is subtlely different than "acquire", and there is > > a history of people requesting further divergence. > > This, acquire/release are RCpc, while (with the exception of Power) > LOCK/UNLOCK are RCsc. > > ( Or did we settle on RCtso for our release/acquire order? I have vague > memories of a long-ish thread, but seem to have forgotten the outcome, > if any. ) > > Lots of subtlety and head-aches right about there. Anyway, it would be > awesome if we can get Power into the RCsc locking camp :-) I will let you take that one up with the Power folks. But I should give an example of a current difference between lock and acquire, and just to spread the blame, I will pick on an architecture other than Power. ;-) With lock acquisition, the following orders the access to X and Z: WRITE_ONCE(X, 1); spin_lock(&my_lock); smp_mb__after_lock(); r1 = READ_ONCE(Z); But if we replace the lock acquisition with a load acquire, there are no ordering guarantees for the accesses to X and Z: WRITE_ONCE(X, 1); r2 = smp_load_acquire(&Y); smp_mb__after_lock(); // Yeah, there is no lock. ;-) r3 = READ_ONCE(Z); There -is- ordering between the accesses to Y and Z, but not to X and Z. This is not a theoretical issue. The x86 platform really can reorder the access to X to follow that of both Y and Z. So the memory-model divergence between lock acquisition and acquire loads is very real in the here and now. Thanx, Paul