From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757111AbbFQSCm (ORCPT ); Wed, 17 Jun 2015 14:02:42 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:44076 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752901AbbFQSCl (ORCPT ); Wed, 17 Jun 2015 14:02:41 -0400 X-Helo: d03dlp01.boulder.ibm.com X-MailFrom: paulmck@linux.vnet.ibm.com X-RcptTo: linux-kernel@vger.kernel.org Date: Wed, 17 Jun 2015 11:02:14 -0700 From: "Paul E. McKenney" To: Peter Zijlstra Cc: umgwanakikbuti@gmail.com, mingo@elte.hu, ktkhai@parallels.com, rostedt@goodmis.org, tglx@linutronix.de, juri.lelli@gmail.com, pang.xunlei@linaro.org, oleg@redhat.com, wanpeng.li@linux.intel.com, linux-kernel@vger.kernel.org, Al Viro , Linus Torvalds Subject: Re: [PATCH 11/18] seqcount: Introduce raw_write_seqcount_barrier() Message-ID: <20150617180214.GJ3913@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <20150611124636.448700267@infradead.org> <20150611124743.374180021@infradead.org> <20150611153341.GK3913@linux.vnet.ibm.com> <20150611214557.GA4249@linux.vnet.ibm.com> <20150617122924.GP3644@twins.programming.kicks-ass.net> <20150617145712.GZ3913@linux.vnet.ibm.com> <20150617154926.GE19282@twins.programming.kicks-ass.net> <20150617163731.GD3913@linux.vnet.ibm.com> <20150617171140.GG19282@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150617171140.GG19282@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15061718-0017-0000-0000-00000BBB5633 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 17, 2015 at 07:11:40PM +0200, Peter Zijlstra wrote: > On Wed, Jun 17, 2015 at 09:37:31AM -0700, Paul E. McKenney wrote: > > The point of std::atomic<> (and of the equivalent C11 syntax) is to > > force the compiler to suppress optimizations that are unsafe for shared > > variables. We get more or less the same effect with volatile, protests > > from compiler people notwithstanding. > > > > I often tell the compiler guys that they have to expect make -some- > > concessions for being 30 years late to the concurrency party, but > > it nevertheless makes sense to future-proof our code where it is > > reasonable to do so. > > Right, so in that regards I would request the compiler option (and or > #pragma) that disables all the out-of-thin-air nonsense. OK. What is the form of the #pragma? If it focuses on a specific access, we are likely to get a lot of pushback. > Because while they hide behind their undefined behaviour, the fact is > that all of their machines for the past 30 odd years have been relying > on this 'undefined' behaviour to work. This being the machines they've > been typing their useless specs on :-) Maybe I can scare them into doing all their work on UP systems. ;-) Interestingly enough, LLVM is taking a slightly different approach. Rather than invoke undefined behavior, they say that data races result in random bits being loaded. Not that it makes much difference to the health and well-being of the software, mind you... > I doubt there's a single OS kernel (that supports SMP configurations) > that does not rely on a whole host of 'undefined' behaviour. An alternative approach would be a compiler switch (or similar) that changed the default atomic access from SC to relaxed. Then shared variables could be marked atomic, and normal C code could be used to access them, but without the compiler emitting memory barriers all over the place (yes, even on x86). Thanx, Paul