From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752347AbdK1Jo6 (ORCPT ); Tue, 28 Nov 2017 04:44:58 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:52736 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752303AbdK1Joy (ORCPT ); Tue, 28 Nov 2017 04:44:54 -0500 Date: Tue, 28 Nov 2017 10:44:40 +0100 From: Peter Zijlstra To: Daniel Lustig Cc: Alan Stern , "Paul E. McKenney" , Andrea Parri , Luc Maranget , Jade Alglave , Boqun Feng , Nicholas Piggin , Will Deacon , David Howells , Palmer Dabbelt , Kernel development list Subject: Re: Unlock-lock questions and the Linux Kernel Memory Model Message-ID: <20171128094440.z32ieyh72xt64jhw@hirez.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 27, 2017 at 03:28:03PM -0800, Daniel Lustig wrote: > On 11/27/2017 1:16 PM, Alan Stern wrote:> C rel-acq-write-ordering-3 > > > > {} > > > > P0(int *x, int *s, int *y) > > { > > WRITE_ONCE(*x, 1); > > smp_store_release(s, 1); > > r1 = smp_load_acquire(s); > > WRITE_ONCE(*y, 1); > > } > > > > P1(int *x, int *y) > > { > > r2 = READ_ONCE(*y); > > smp_rmb(); > > r3 = READ_ONCE(*x); > > } > > > > exists (1:r2=1 /\ 1:r3=0) > > > > > > > And going to extremes... > > Sorry if I'm missing something obvious, but before going to extremes... > what about this one? > > "SB+rel-acq" (or please rename if you have a different scheme) > > {} > > P0(int *x, int *s, int *y) > { > WRITE_ONCE(*x, 1); > smp_store_release(s, 1); > r1 = smp_load_acquire(s); > r2 = READ_ONCE(*y); > } Yes, this one doesn't work on TSO and Power. Ideally it would work for locks though, but that would mean mandating RCsc lock implementations and currently Power is holding out on that.