This is the mail archive of the
mailing list for the GCC project.
Re: Compilers and RCU readers: Once more unto the breach!
- From: "Paul E. McKenney" <paulmck at linux dot vnet dot ibm dot com>
- To: linux-kernel at vger dot kernel dot org, c++std-parallel at accu dot org, linux-arch at vger dot kernel dot org, gcc at gcc dot gnu dot org
- Cc: Peter dot Sewell at cl dot cam dot ac dot uk, torvalds at linux-foundation dot org, Mark dot Batty at cl dot cam dot ac dot uk, peterz at infradead dot org, will dot deacon at arm dot com, Ramana dot Radhakrishnan at arm dot com, dhowells at redhat dot com, akpm at linux-foundation dot org, mingo at kernel dot org, michaelw at ca dot ibm dot com
- Date: Tue, 22 Sep 2015 10:00:31 -0700
- Subject: Re: Compilers and RCU readers: Once more unto the breach!
- Authentication-results: sourceware.org; auth=none
- References: <20150520005510 dot GA23559 at linux dot vnet dot ibm dot com> <20150714004459 dot GA3090 at linux dot vnet dot ibm dot com>
- Reply-to: paulmck at linux dot vnet dot ibm dot com
On Mon, Jul 13, 2015 at 05:44:59PM -0700, Paul E. McKenney wrote:
> On Tue, May 19, 2015 at 05:55:10PM -0700, Paul E. McKenney wrote:
> > Hello!
> > Following up on last year's discussion (https://lwn.net/Articles/586838/,
> > https://lwn.net/Articles/588300/), I believe that we have a solution. If
> > I am wrong, I am sure you all will let me know, and in great detail. ;-)
> > The key simplification is to "just say no" to RCU-protected array indexes:
> > https://lkml.org/lkml/2015/5/12/827, as was suggested by several people.
> > This simplification means that rcu_dereference (AKA memory_order_consume)
> > need only return pointers. This in ture avoids things like (x-x),
> > (x*0), and (x%1) because if "x" is a pointer, these expressions either
> > return non-pointers are compilation errors. With a very few exceptions,
> > dependency chains can lead -to- non-pointers, but cannot pass -through-
> > them.
> > The result is that dependencies are carried only by operations for
> > which the compiler cannot easily optimize the away those dependencies,
> > these operations including simple assignment, integer offset (including
> > indexing), dereferencing, casts, passing as a function argument, return
> > values from functions and so on. A complete list with commentary starts
> > on page 28 of:
> > http://www.rdrop.com/users/paulmck/RCU/consume.2015.05.18a.pdf
> And an update is available here:
> Among other things, this update addresses the points about equality
> comparisons introduced by the compiler, and outlines some of the
> issues head-/tail-marked alternatives face with respect to abstraction.
> The updated "Restricted Dependency Chains" section starts on page 28.
This is updated based on many offline discussions. Section 7.9 has
been updated accordingly, but still starts on page 28. This approach is
again intended for large existing RCU code bases such as the Linux kernel.
A new Section 7.10 starting on page 35 describes a possible longer-term
solution for new-to-RCU code bases. This approach adds a storage class
that indicates that the marked object carries dependencies. This allows
better diagnostics (and arguably better code self-documentation) as well
as providing something that formal-verification tools can handle while
avoiding the need for compilers to trace dependency chains.