From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx186.postini.com [74.125.245.186]) by kanga.kvack.org (Postfix) with SMTP id 937616B0005 for ; Thu, 4 Apr 2013 15:53:36 -0400 (EDT) Received: by mail-vb0-f51.google.com with SMTP id x19so1578738vbf.38 for ; Thu, 04 Apr 2013 12:53:35 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <3ae9b7e77e8428cfeb34c28ccf4a25708cbea1be.1364938782.git.jstancek@redhat.com> <20130403041447.GC4611@cmpxchg.org> <20130403045814.GD4611@cmpxchg.org> <20130403143302.GL1953@cmpxchg.org> Date: Thu, 4 Apr 2013 12:53:35 -0700 Message-ID: Subject: Re: [patch] compiler: clarify ACCESS_ONCE() relies on compiler implementation From: Linus Torvalds Content-Type: text/plain; charset=UTF-8 Sender: owner-linux-mm@kvack.org List-ID: To: David Rientjes Cc: Andrew Morton , Ian Lance Taylor , Hugh Dickins , Jan Stancek , Paul McKenney , Johannes Weiner , linux-mm On Thu, Apr 4, 2013 at 12:40 PM, David Rientjes wrote: > > I said in the previous email that you'd do this solely to rely on a > well-defined semantic rather than reading paragraphs of comments that > we're developing. What's "well-defined" about it? It's implementation-defined in both cases. IOW, why do you think "__builtin_access_once(x)" is fundamentally different from "(*(volatile type *)&(x))"? Both would be equally dependent on the compiler implementation, and I'd argue that it would be much nicer if gcc just automatically turned the existing volatile code internally into the builtin version (and then didn't even bother to expose that builtin), since if they are willing to do the built-in, they clearly acknowledge the need for this kind of behavior in the first place. See what I'm arguing? If a compiler writer is acknowledging that this kind of "access once with good semantics through a pointer" is needed and useful (and in the presense of IO and threading, a compiler writer that doesn't acknowledge that is a moron), then _why_ would that same compiler writer then argue against just doing that for volatile pointers? What's so magically bad about "volatile" that would be solved by a totally new and nonstandard builtin? Linus -- 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