Received: by 10.223.164.202 with SMTP id h10csp1125162wrb; Wed, 15 Nov 2017 13:41:15 -0800 (PST) X-Google-Smtp-Source: AGs4zMapXFcdJq0OmNEFQceeBouMMj/Jy4t2qSyrm1eWZFHBlz71qXv756Uqk2jOPV6havcwgKNe X-Received: by 10.98.198.138 with SMTP id x10mr19092656pfk.55.1510782075859; Wed, 15 Nov 2017 13:41:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510782075; cv=none; d=google.com; s=arc-20160816; b=GGQDnRlc7R3dgNEP92CbZobPGejoGNgaG742JNCV+sd4D6f43SY9vn6yZoZxx0Q/vG +QSVpqfrjlPy5jh8jdwtN3SdEijiJACjMAyEFWADRQfwAU2Ue2zsduXe2LHko5D7D+RI jPMBquaCoRdLoZlxLTwXiHlcyjT/IHRAGTHVrGODgb+Th5Qivw3O+VUusVXSN5nxHe1r 768a+kWki8lnQO/BFJGeFrd35GC8qJ11gC1eVrpKw4pqtIl8o6Ej3NFFWmOK/2+umEHS Y60y8BcVaZ/ntYr9fWS6fjni0m34Wp62evWf4qrDyNEnvrWoMBjW9SMfsOcg52tVVkK1 cLMA== 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=faUBRahy/EzJgGUpeHRlGziPH2FlXJWkhmze3sqY+Ns=; b=besdCwd+XF4kAfwIpACXpuT//DnGWU2+rLNbMRhplRjtX8QBb+15EIOywj41m1FZok mioyWUr5qp+8uQM4dLvN9SEMaobuWdoBQ3chC7SniIUVBQZXzIyaNVX126wf270qnBSU 8xOf4u8DzdadD+cFXucquQix1vfrqYTFZZIprvEObJNXJmHeNIKWgELDA38zaFx1tCFg mgmy9VrQB0s9PVNrHdb9wo5iiChb3VpJ1gpFau0hQoTw5mDiYhGAzzBb1sHELUfDqm27 h5DOxC3UAyK/E+RZsKmLYb7WUjxHrccO/MXuQBzQZgKuDxu54daZfDymWy14YWvIYuce KCcw== 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 g1si997556plb.679.2017.11.15.13.41.03; Wed, 15 Nov 2017 13:41:15 -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; 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 S933702AbdKOUWu (ORCPT + 89 others); Wed, 15 Nov 2017 15:22:50 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:33524 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S933317AbdKOUWf (ORCPT ); Wed, 15 Nov 2017 15:22:35 -0500 Received: (qmail 3375 invoked by uid 2102); 15 Nov 2017 15:22:33 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 15 Nov 2017 15:22:33 -0500 Date: Wed, 15 Nov 2017 15:22:33 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Peter Zijlstra cc: Will Deacon , "Reshetova, Elena" , "linux-kernel@vger.kernel.org" , "gregkh@linuxfoundation.org" , "keescook@chromium.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "ishkamiel@gmail.com" , Paul McKenney , , , , Subject: Re: [PATCH] refcount: provide same memory ordering guarantees as in atomic_t In-Reply-To: <20171115200307.ns4ja7xjwhunen65@hirez.programming.kicks-ass.net> 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 Wed, 15 Nov 2017, Peter Zijlstra wrote: > On Wed, Nov 15, 2017 at 02:15:19PM -0500, Alan Stern wrote: > > On Wed, 15 Nov 2017, Will Deacon wrote: > > > > > On Thu, Nov 02, 2017 at 04:21:56PM -0400, Alan Stern wrote: > > > > I was trying to think of something completely different. If you have a > > > > release/acquire to the same address, it creates a happens-before > > > > ordering: > > > > > > > > Access x > > > > Release a > > > > Acquire a > > > > Access y > > > > > > > > Here is the access to x happens-before the access to y. This is true > > > > even on x86, even in the presence of forwarding -- the CPU still has to > > > > execute the instructions in order. But if the release and acquire are > > > > to different addresses: > > > > > > > > Access x > > > > Release a > > > > Acquire b > > > > Access y > > > > > > > > then there is no happens-before ordering for x and y -- the CPU can > > > > execute the last two instructions before the first two. x86 and > > > > PowerPC won't do this, but I believe ARMv8 can. (Please correct me if > > > > it can't.) > > > > > > Release/Acquire are RCsc on ARMv8, so they are ordered irrespective of > > > address. > > > > Ah, okay, thanks. > > > > In any case, we have considered removing this ordering constraint > > (store-release followed by load-acquire for the same location) from the > > Linux-kernel memory model. > > Why? Its a perfectly sensible construct. > > > I'm not aware of any code in the kernel that depends on it. Do any of > > you happen to know of any examples? > > All locks? Something like: > > spin_lock(&x) > /* foo */ > spin_unlock(&x) > spin_lock(&x) > /* bar */ > spin_unlock(&x); > > Has a fairly high foo happens-before bar expectation level. > > And in specific things like: > > 135e8c9250dd5 > ecf7d01c229d1 > > which use the release of rq->lock paired with the next acquire of the > same rq->lock to match with an smp_rmb(). You know, sometimes I feel like I'm losing my mind. Yes, of course -- this was in fact the original reason for adding that constraint to the memory model in the first place! An unlock-to-lock link between two CPUs would naturally create an ordering relation, and we wanted the same to be true when everything occurred on a single CPU. I'll shut up now... Alan From 1584165588498534214@xxx Wed Nov 15 20:33:54 +0000 2017 X-GM-THRID: 1582046402032606032 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread