Received: by 10.223.164.202 with SMTP id h10csp1663058wrb; Thu, 16 Nov 2017 02:04:39 -0800 (PST) X-Google-Smtp-Source: AGs4zMYq6yhxOduy0baUnFQR9/BmpiuRol/W70RVqWftcUikDdvz4vGZeoMqb+qFBEj9E5X4ycDs X-Received: by 10.84.128.197 with SMTP id a63mr1171646pla.212.1510826679355; Thu, 16 Nov 2017 02:04:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510826679; cv=none; d=google.com; s=arc-20160816; b=ZjFxd46rJyujgUui6ArFXmzkRiT2XeVCn6ubBma+rvLdZT9389xsk8sW+us+KMtA9f HplYoWb3WAXdDWwSDNiqpoq8GmANE49f3KA+IPA/EVV44rCm+Iv/43TmHF1F22UBpbCh VfwpU833DgtUt38aLiZ9c4Y87Od8wYISNNxw8abpcV1lp8Kq9T89ymAvj0xobXrf6zKH Eo6skzlQVA/1Cj0hDIZJUxSsIhMIIdbUF/pkU7/0/4ujzAVty3dOPBVVKSd8UN8eyAUA bNEaL0JU464y+fIyJSise00w2dQ9uP2wPNOvdygdGbhiM3TFqTleNPngtiD57G3VEBsf 9hkg== 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:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=slIHZmoSthBw9I2WJjt0te3h6YXsgXUp3vhWTxud7NE=; b=0KkOANj+SQNAiNe7UY5N2b1DSnGbGMJFVO0bdaZkIyNSL2f7FJFp3kLj+wrWkW+qH2 d5+TySTZW9CliuXqszjKWs4RF46Z0GwJ3fDCVLBzy9R0v6MOG28qHrgkHvmNKj1y/wwS 36/248f/jT1EpGlvbP/3JM/e51MBU6zgEJHuPIuxA+amLswypxloVe97Y/KnvLLJ3pFu yrEYVCOBU+emeWPtraO37bFaU382WDV2m6shs1vEZ4Zgs8gt4sgIbQI3HmwsEJU2lqZC 6AhnXQaHn0whQ/l7TUwz9afRx+I5hWo9NC+Tm2ghQTM8qu64r7yso8a/8PPPNsGFy7t8 bOFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YhG/85ii; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q74si662942pfg.13.2017.11.16.02.04.26; Thu, 16 Nov 2017 02:04:39 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YhG/85ii; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934040AbdKPKBU (ORCPT + 91 others); Thu, 16 Nov 2017 05:01:20 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:44218 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933052AbdKPKBG (ORCPT ); Thu, 16 Nov 2017 05:01:06 -0500 Received: by mail-wr0-f195.google.com with SMTP id u97so22929526wrc.1 for ; Thu, 16 Nov 2017 02:01:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=slIHZmoSthBw9I2WJjt0te3h6YXsgXUp3vhWTxud7NE=; b=YhG/85iiH8V1b1MDf0ELphec9usdh5xpD3s7A7y+RUZJ1r7sMmHXNtdvDASUNJnUNL xaBrZy6a/XPqPorRHYAjk0Nm5hG5KRYomx8k5LY+o+F84a+epDP8rbfC2buvCIIa0BvC Y47qV1rIeQBrZRPC1nCew77vwyxTrZ7uJ4UM/9olwC6Cr3btIotJrY9nZBT+r0htGItT MpUTBm55nCgqqi6OpFsT5EwgGsdBUPoK9A8fKeoEDgFL7x4OSBETk4VgdjOOYSbYVpps RchZvB+YSLTWFrLnssDtow4+WMFOrGYwOIQNU3IjK/g4I817q07LcR7rRDWECojcwARY Itrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=slIHZmoSthBw9I2WJjt0te3h6YXsgXUp3vhWTxud7NE=; b=VFovYrtBZ4D6v6OPgLSOLCWXwDcoQeP+W6hVEjQVaG4oJoUdYvlMyRuz6IuqrVR7K9 WZXqZH+XSIidHvpl0PRK/d8TYSJAY1bdh+RH7JLLdtDh7t5GsnVAw3i7HqjiTgbk3vXJ UTwjeCDqP0Tqf8guR9O7RStOHspTszru97GgRU2lQ9jIt9dwPJ8Eky0qLpNsYeNVseSR IIRjFCVb11sbITsFhsKNZO677QM5o5kCxevHIU0TSLhW0LyJR+80O9BZJDBEAIQqyi7x 7ElgJUwWlo4u3glb4ZMgcM+YAds83iN4MlU1alCE+KKvZbBeP7fp/t6le+GLOHq71OLM uwHQ== X-Gm-Message-State: AJaThX4vod4OWmGORH2qWfyOzcBWiG311HAYKJJbcihTkQdOOgfXt/1/ DcJsSoGehgdHdeeMLoJ1OZc= X-Received: by 10.223.181.131 with SMTP id c3mr970115wre.198.1510826465360; Thu, 16 Nov 2017 02:01:05 -0800 (PST) Received: from andrea (host175-4-dynamic.61-82-r.retail.telecomitalia.it. [82.61.4.175]) by smtp.gmail.com with ESMTPSA id u5sm1143372wmf.44.2017.11.16.02.01.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Nov 2017 02:01:04 -0800 (PST) Date: Thu, 16 Nov 2017 11:00:58 +0100 From: Andrea Parri To: Peter Zijlstra Cc: Alan Stern , 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 , boqun.feng@gmail.com, dhowells@redhat.com, david@fromorbit.com Subject: Re: [PATCH] refcount: provide same memory ordering guarantees as in atomic_t Message-ID: <20171116100058.GA5625@andrea> References: <20171115180540.GQ19071@arm.com> <20171115200307.ns4ja7xjwhunen65@hirez.programming.kicks-ass.net> <20171115205823.GA2608@andrea> <20171116085804.ixw4x7ssf2ruooqg@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171116085804.ixw4x7ssf2ruooqg@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 16, 2017 at 09:58:04AM +0100, Peter Zijlstra wrote: > On Wed, Nov 15, 2017 at 10:01:11PM +0100, Andrea Parri wrote: > > > > 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(). > > > > Those cycles are currently forbidden by LKMM _when_ you consider the > > smp_mb__after_spinlock() from schedule(). See rfi-rel-acq-is-not-mb > > from my previous email and Alan's remarks about cumul-fence. > > I'm not sure I get your point; and you all seem to forget I do not in > fact speak the ordering lingo. So I have no idea what > rfi-blah-blah or cumul-fence mean. I expand on my comment. Consider the following test: C T1 {} P0(int *x, int *y, spinlock_t *s) { spin_lock(s); WRITE_ONCE(*x, 1); spin_unlock(s); spin_lock(s); WRITE_ONCE(*y, 1); spin_unlock(s); } 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) According to LKMM, the store to x happens before the store to y but there is no guarantee that the former store propagate (to P1) before the latter (which is what we need to forbid that state). As a result, that state in the "exists" clause is _allowed_ by LKMM. The LKMM encodes happens-before (or execution) ordering with a relation named "hb", while it encodes "propagation ordering" with "cumul-fence". Andrea > > I know rel-acq isn't smp_mb() and I don't think any of the above patches > need it to be. They just need it do be a local ordering, no? > > Even without smp_mb__after_spinlock() we get that: > > spin_lock(&x) > x = 1 > spin_unlock(&x) > spin_lock(&x) > y = 1 > spin_unlock(&x) > > guarantees that x happens-before y, right? > > And that should be sufficient to then order something else against, like > for example: > > r2 = y > smp_rmb() > r1 = x > > no? > > From 1584215047007658452@xxx Thu Nov 16 09:40:01 +0000 2017 X-GM-THRID: 1582046402032606032 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread