Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752105AbbETCl5 (ORCPT ); Tue, 19 May 2015 22:41:57 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:34336 "EHLO e37.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751958AbbETCly (ORCPT ); Tue, 19 May 2015 22:41:54 -0400 Date: Tue, 19 May 2015 19:41:48 -0700 From: "Paul E. McKenney" To: Linus Torvalds Cc: Linux Kernel Mailing List , c++std-parallel@accu.org, "linux-arch@vger.kernel.org" , "gcc@gcc.gnu.org" , p796231 , "mark.batty@cl.cam.ac.uk" , Peter Zijlstra , Will Deacon , Ramana Radhakrishnan , David Howells , Andrew Morton , Ingo Molnar , michaelw@ca.ibm.com Subject: Re: Compilers and RCU readers: Once more unto the breach! Message-ID: <20150520024148.GD6776@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <20150520005510.GA23559@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15052002-0025-0000-0000-00000ABED33F Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2497 Lines: 56 On Tue, May 19, 2015 at 07:10:12PM -0700, Linus Torvalds wrote: > On Tue, May 19, 2015 at 6:57 PM, Linus Torvalds > wrote: > > > > - the "you can add/subtract integral values" still opens you up to > > language lawyers claiming "(char *)ptr - (intptr_t)ptr" preserving the > > dependency, which it clearly doesn't. But language-lawyering it does, > > since all those operations (cast to pointer, cast to integer, > > subtracting an integer) claim to be dependency-preserving operations. > > > > So I think you want to limit the logical operators to things that > > don't mask off too many bits, and you should probably limit the > > add/subtract operations some way (maybe specify that the integer value > > you add/subtract cannot be related to the pointer). > > Actually, "not related" doesn't work. For some buddy allocator thing, > you very much might want some of the bits to be related. Good point, you could do the buddy-allocator computations with add and subtract instead of exclusive OR. > So I think you're better off just saying that operations designed to > drop significant bits break the dependency chain, and give things like > "& 1" and "(char *)ptr-(uintptr_t)ptr" as examples of such. > > Making that just an extension of your existing "& 0" language would > seem to be natural. Works for me! I added the following bullet to the list of things that break dependencies: If a pointer is part of a dependency chain, and if the values added to or subtracted from that pointer cancel the pointer value so as to allow the compiler to precisely determine the resulting value, then the resulting value will not be part of any dependency chain. For example, if p is part of a dependency chain, then ((char *)p-(uintptr_t)p)+65536 will not be. Seem reasonable? > Humans will understand, and compiler writers won't care. They will > either depend on hardware semantics anyway (and argue that your > language is tight enough that they don't need to do anything special) > or they will turn the consume into an acquire (on platforms that have > too weak hardware). Agreed. Plus Core Working Group will hammer out the exact wording, should this approach meet their approval. Thanx, Paul -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/