Received: by 10.223.164.221 with SMTP id h29csp2582572wrb; Thu, 2 Nov 2017 13:30:42 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T7E6pysgVje2j9s+Z5bqYqasBWQ9Tedh+6PsQA25aRc8tpcsF09XMLaY19cNn57qvuRVDd X-Received: by 10.84.174.4 with SMTP id q4mr4567984plb.233.1509654642111; Thu, 02 Nov 2017 13:30:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509654642; cv=none; d=google.com; s=arc-20160816; b=EjsnNwDrVrJr/bXxaPwrKGUIw7+pLyr4wuH2RnUenO92uRvo3YE+sFcYpLKPbB67RE 2kvp/x8bxIgyxnMhPC7hEr1g0vWcTF5BVX77F3EZ+HpX4vEvQ9/aXYp0HzwkBI+YALQT 1Zc3ege4DjFSld1RwnjDd0VU1vqy3/9SxzfDB2Y3bgBVWd2CQNSr4rfYtnYCEkSwLvPF +YG3pctpgmW97U9FRDAgsgH942YpcT4mecE3kloJrx6cBtycVj8nlQuvKBYecB9xG36G U4C5zBP0NfqEiCbT+p5qEUP/ClhpjWNkiHlKaiW8wClBYuvQ/LxjhWrbJm0hllWpA0Fu WrsQ== 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:arc-authentication-results; bh=OdmYkvTjREqATbE5fS58c60stYT56wZFcwwrXw2pLJI=; b=u1Ee4Dq9V+mP3Kc89/9HQyjFXeyim2sSNJ5R7VHw16/oi7ByGRf6TqL3Z1QAM1uenT WmI81tKOpyOkHT4cOiQ+6A+EYroIwRKQNTNKpxWkBlYAOlxmgasmLitwSzywFkiTKZDS xwaobM0lSOD25wXXx+RA3yxUvfbmUWKtLcb5QvF6YnKici/BBhZrmvFKBbdLUUBCXpym MhuoJqQv9jaYWr4gLWG77vijc3nROp6C0drLPL5rRrTJyD9E4ry1I3IzTRvBKRCKWokm mQQqJLgd/O3pJA8J03gRod4eOdLLtpPRXYxT2pGsKXcxJtQT3PtbmvHB2WWn6RNkisAv 6bbA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r7si4189153pgf.713.2017.11.02.13.30.28; Thu, 02 Nov 2017 13:30:42 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934471AbdKBU2r (ORCPT + 99 others); Thu, 2 Nov 2017 16:28:47 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:33362 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S934115AbdKBU2q (ORCPT ); Thu, 2 Nov 2017 16:28:46 -0400 Received: (qmail 3327 invoked by uid 2102); 2 Nov 2017 16:28:45 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 2 Nov 2017 16:28:45 -0400 Date: Thu, 2 Nov 2017 16:28:45 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Andrea Parri cc: Peter Zijlstra , "Reshetova, Elena" , "linux-kernel@vger.kernel.org" , "gregkh@linuxfoundation.org" , "keescook@chromium.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "ishkamiel@gmail.com" , Will Deacon , Paul McKenney , , , Subject: Re: [PATCH] refcount: provide same memory ordering guarantees as in atomic_t In-Reply-To: <20171102174504.GA19833@andrea> 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 Thu, 2 Nov 2017, Andrea Parri wrote: > > This is forbidden. It would remain forbidden even if the smp_mb in P1 > > were replaced by a similar release/acquire pair for the same memory > > location. > > Hopefully, the LKMM does not agree with this assessment... ;-) No, it doesn't. > Here's a two-threads example showing that "(w)mb is _not_ rfi-rel-acq": > > C rfi-rel-acq-is-not-mb > > {} > > P0(int *x, int *y, int *a) > { > WRITE_ONCE(*x, 1); > smp_store_release(a, 1); > r1 = smp_load_acquire(a); > WRITE_ONCE(*y, 1); > } > > P1(int *x, int *y) > { > int r0; > int r1; > > r0 = READ_ONCE(*y); > smp_rmb(); > r1 = READ_ONCE(*x); > } > > exists (1:r0=1 /\ 1:r1=0) Right. There is a happens-before edge between the two WRITE_ONCE calls in P0 but no cumul-fence edge, and therefore the test is allowed. Here is an example where a happens-before edge suffices to provide ordering: P0(int *x, int *y) { WRITE_ONCE(*x, 1); smp_wmb(); WRITE_ONCE(*y, 1); } P1(int *x, int *y, int *a) { int rx, ry, ra; ry = READ_ONCE(*y); smp_store_release(a, 1); ra = smp_load_acquire(a); rx = READ_ONCE(*x); } exists (1:rx=0 /\ 1:ry=1) This test is forbidden, but it would be allowed if the release and acquire accessed different locations. Alan Stern From 1582987160255460536@xxx Thu Nov 02 20:23:17 +0000 2017 X-GM-THRID: 1582046402032606032 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread