From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qa0-f51.google.com (mail-qa0-f51.google.com [209.85.216.51]) by kanga.kvack.org (Postfix) with ESMTP id 402B86B0039 for ; Mon, 25 Nov 2013 18:51:15 -0500 (EST) Received: by mail-qa0-f51.google.com with SMTP id o15so8095233qap.3 for ; Mon, 25 Nov 2013 15:51:15 -0800 (PST) Received: from e33.co.us.ibm.com (e33.co.us.ibm.com. [32.97.110.151]) by mx.google.com with ESMTPS id q6si9343318qag.88.2013.11.25.15.51.13 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 25 Nov 2013 15:51:14 -0800 (PST) Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Nov 2013 16:51:13 -0700 Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id D3BB61FF001F for ; Mon, 25 Nov 2013 16:50:52 -0700 (MST) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by b03cxnp08027.gho.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rAPLnNkX37880056 for ; Mon, 25 Nov 2013 22:49:23 +0100 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id rAPNs6x2021832 for ; Mon, 25 Nov 2013 16:54:08 -0700 Date: Mon, 25 Nov 2013 15:51:06 -0800 From: "Paul E. McKenney" Subject: Re: [PATCH v6 4/5] MCS Lock: Barrier corrections Message-ID: <20131125235106.GZ4138@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <20131121172558.GA27927@linux.vnet.ibm.com> <20131121215249.GZ16796@laptop.programming.kicks-ass.net> <20131121221859.GH4138@linux.vnet.ibm.com> <20131122155835.GR3866@twins.programming.kicks-ass.net> <20131122182632.GW4138@linux.vnet.ibm.com> <20131122185107.GJ4971@laptop.programming.kicks-ass.net> <20131125173540.GK3694@twins.programming.kicks-ass.net> <52939C5A.3070208@zytor.com> <1385420302.11046.539.camel@schen9-DESK> <5293DD20.4020904@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5293DD20.4020904@zytor.com> Sender: owner-linux-mm@kvack.org List-ID: To: "H. Peter Anvin" Cc: Tim Chen , Peter Zijlstra , Will Deacon , Ingo Molnar , Andrew Morton , Thomas Gleixner , "linux-kernel@vger.kernel.org" , linux-mm , "linux-arch@vger.kernel.org" , Linus Torvalds , Waiman Long , Andrea Arcangeli , Alex Shi , Andi Kleen , Michel Lespinasse , Davidlohr Bueso , Matthew R Wilcox , Dave Hansen , Rik van Riel , Peter Hurley , Raghavendra K T , George Spelvin , Arnd Bergmann , Aswin Chandramouleeswaran , Scott J Norton , "Figo.zhang" On Mon, Nov 25, 2013 at 03:28:32PM -0800, H. Peter Anvin wrote: > On 11/25/2013 02:58 PM, Tim Chen wrote: > > > > Peter, > > > > Want to check with you on Paul's example, > > where we are indeed writing and reading to the same > > lock location when passing the lock on x86 with smp_store_release and > > smp_load_acquire. So the unlock and lock sequence looks like: > > > > CPU 0 (releasing) CPU 1 (acquiring) > > ----- ----- > > ACCESS_ONCE(X) = 1; while (ACCESS_ONCE(lock) == 1) > > continue; > > ACCESS_ONCE(lock) = 0; > > r1 = ACCESS_ONCE(Y); > > > > Here we can definitely state that the read from Y must have happened > after X was set to 1 (assuming lock starts out as 1). > > > observer CPU 2: > > > > CPU 2 > > ----- > > ACCESS_ONCE(Y) = 1; > > smp_mb(); > > r2 = ACCESS_ONCE(X); > > > > If the write and read to lock act as a full memory barrier, > > it would be impossible to > > end up with (r1 == 0 && r2 == 0), correct? > > > > It would be impossible to end up with r1 == 1 && r2 == 0, I presume > that's what you meant. Yes, that is the correct impossibility. Thank you, Peter! Thanx, Paul -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org