On Thu, Jun 16, 2016 at 12:12:58AM +0200, Peter Zijlstra wrote:
> On Thu, Jun 16, 2016 at 12:03:39AM +0200, Peter Zijlstra wrote:
> > On Wed, Jun 15, 2016 at 02:46:08PM -0700, Paul E. McKenney wrote:
> > > This commit does a compile-time check for rcu_assign_pointer() of NULL,
> > > and uses WRITE_ONCE() rather than smp_store_release() in that case.
> > > 
> > > Reported-by: Christoph Hellwig <[email protected]>
> > > Signed-off-by: Paul E. McKenney <[email protected]>
> > > ---
> > >  include/linux/rcupdate.h | 11 ++++++++++-
> > >  1 file changed, 10 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> > > index c61b6b9506e7..9be61e47badc 100644
> > > --- a/include/linux/rcupdate.h
> > > +++ b/include/linux/rcupdate.h
> > > @@ -650,7 +650,16 @@ static inline void rcu_preempt_sleep_check(void)
> > >   * please be careful when making changes to rcu_assign_pointer() and the
> > >   * other macros that it invokes.
> > >   */
> > > -#define rcu_assign_pointer(p, v) smp_store_release(&p, 
> > > RCU_INITIALIZER(v))
> > > +#define rcu_assign_pointer(p, v) \
> > > +({ \
> > > + uintptr_t _r_a_p__v = (uintptr_t)(v); \
> > > + \
> > > + if (__builtin_constant_p(v) && (_r_a_p__v) == (uintptr_t)NULL) \
> > > +         WRITE_ONCE((p), (typeof(p))(_r_a_p__v)); \
> > > + else \
> > > +         smp_store_release(&p, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
> > > + _r_a_p__v; \
> > > +})
> > 
> > Can we pretty please right align the '\'s ?

If you insist...  ;-)

Done.

> > Also, didn't we used to do this and then reverted it again for some
> > obscure reason?
> 
> lkml.kernel.org/r/[email protected]

There was indeed a compiler bug long ago that could generate spurious
warnings:

https://groups.google.com/forum/#!topic/linux.kernel/y2FIhJ-WVJc

> What changed since then? And can we now pretty please get rid of that
> RCU_INIT_POINTER() nonsense?

Five years has passed, the structure of rcu_assign_pointer() has
completely changed, and someone asked for the old behavior.  Seemed
worth a try, given the very visible nature of the gcc complaint.

No complaints thus far, but then again there probably aren't that
many people running -rcu.  That said, I am encouraged by the lack
of reports from the 0day test robot.

If this goes in and there aren't any problems for some time, then
I agree that shrinking the RCU API would be worthwhile.  My idea of
"some time" is about a year, given that it would be a real pain to
push a bunch of changes throughout the kernel only to have to revert
them if the old compiler bug managed to crop up again.  :-/

                                                        Thanx, Paul

Reply via email to