From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Paul E. McKenney" Subject: Re: [RFC][PATCH 0/5] arch: atomic rework Date: Mon, 17 Feb 2014 10:18:15 -0800 Message-ID: <20140217181815.GA1934@linux.vnet.ibm.com> References: <20140207165028.GO4250@linux.vnet.ibm.com> <20140207165548.GR5976@mudshark.cambridge.arm.com> <20140207180216.GP4250@linux.vnet.ibm.com> <1391992071.18779.99.camel@triegel.csb> <20140211155941.GU4250@linux.vnet.ibm.com> <1392185194.18779.2239.camel@triegel.csb> <20140212091907.GA3545@laptop.programming.kicks-ass.net> <20140212174209.GA4250@linux.vnet.ibm.com> <20140212181205.GD27965@twins.programming.kicks-ass.net> Reply-To: paulmck@linux.vnet.ibm.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from e31.co.us.ibm.com ([32.97.110.149]:50011 "EHLO e31.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752036AbaBQSSV (ORCPT ); Mon, 17 Feb 2014 13:18:21 -0500 Received: from /spool/local by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Feb 2014 11:18:20 -0700 Content-Disposition: inline In-Reply-To: <20140212181205.GD27965@twins.programming.kicks-ass.net> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Peter Zijlstra Cc: Torvald Riegel , Linus Torvalds , Will Deacon , Ramana Radhakrishnan , David Howells , "linux-arch@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "akpm@linux-foundation.org" , "mingo@kernel.org" , "gcc@gcc.gnu.org" On Wed, Feb 12, 2014 at 07:12:05PM +0100, Peter Zijlstra wrote: > On Wed, Feb 12, 2014 at 09:42:09AM -0800, Paul E. McKenney wrote: > > You need volatile semantics to force the compiler to ignore any proofs > > it might otherwise attempt to construct. Hence all the ACCESS_ONCE() > > calls in my email to Torvald. (Hopefully I translated your example > > reasonably.) > > My brain gave out for today; but it did appear to have the right > structure. I can relate. ;-) > I would prefer it C11 would not require the volatile casts. It should > simply _never_ speculate with atomic writes, volatile or not. I agree with not needing volatiles to prevent speculated writes. However, they will sometimes be needed to prevent excessive load/store combining. The compiler doesn't have the runtime feedback mechanisms that the hardware has, and thus will need help from the developer from time to time. Or maybe the Linux kernel simply waits to transition to C11 relaxed atomics until the compiler has learned to be sufficiently conservative in its load-store combining decisions. Thanx, Paul