Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751824AbbETB5F (ORCPT ); Tue, 19 May 2015 21:57:05 -0400 Received: from mail-ie0-f180.google.com ([209.85.223.180]:33198 "EHLO mail-ie0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751006AbbETB5D (ORCPT ); Tue, 19 May 2015 21:57:03 -0400 MIME-Version: 1.0 In-Reply-To: <20150520005510.GA23559@linux.vnet.ibm.com> References: <20150520005510.GA23559@linux.vnet.ibm.com> Date: Tue, 19 May 2015 18:57:02 -0700 X-Google-Sender-Auth: F80aGY0hhydeu3ra3lcwc8FDy7I Message-ID: Subject: Re: Compilers and RCU readers: Once more unto the breach! From: Linus Torvalds To: Paul McKenney 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 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2260 Lines: 47 On Tue, May 19, 2015 at 5:55 PM, Paul E. McKenney wrote: > > http://www.rdrop.com/users/paulmck/RCU/consume.2015.05.18a.pdf >From a very quick read-through, the restricted dependency chain in 7.9 seems to be reasonable, and essentially covers "thats' what hardware gives us anyway", making compiler writers happy. I would clarify the language somewhat: - it says that the result of a cast of a pointer is a dependency. You need to make an exception for casting to bool, methinks (because that's effectively just a test-against-NULL, which you later describe as terminating the dependency). Maybe get rid of the "any type", and just limit it to casts to types of size intptr_t, ie ones that don't drop significant bits. All the other rules talk about [u]intptr_t anyway. - you clarify that the trivial "& 0" and "| ~0" kill the dependency chain, but if you really want to be a stickler, you might want to extend it to a few more cases. Things like "& 1" (to extract a tag from the lot bit of a tagged pointer) should likely also drop the dependency, since a compiler would commonly end up using the end result as a conditional even if the code was written to then use casting etc to look like a dereference. - 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). But I think limiting it to mostly pointer ops (and a _few_ integer operations to do offsets and remove tag bits) is otherwise a good approach. Linus -- 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/