From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161215AbcFOWNM (ORCPT ); Wed, 15 Jun 2016 18:13:12 -0400 Received: from merlin.infradead.org ([205.233.59.134]:38496 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932842AbcFOWNF (ORCPT ); Wed, 15 Jun 2016 18:13:05 -0400 Date: Thu, 16 Jun 2016 00:12:58 +0200 From: Peter Zijlstra To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, dvhart@linux.intel.com, fweisbec@gmail.com, oleg@redhat.com, bobby.prani@gmail.com Subject: Re: [PATCH tip/core/rcu 07/12] rcu: No ordering for rcu_assign_pointer() of NULL Message-ID: <20160615221258.GE30927@twins.programming.kicks-ass.net> References: <20160615214550.GA4931@linux.vnet.ibm.com> <1466027173-5501-7-git-send-email-paulmck@linux.vnet.ibm.com> <20160615220339.GZ30921@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160615220339.GZ30921@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > Signed-off-by: Paul E. McKenney > > --- > > 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 ? > > Also, didn't we used to do this and then reverted it again for some > obscure reason? lkml.kernel.org/r/20140909094235.GD19379@twins.programming.kicks-ass.net What changed since then? And can we now pretty please get rid of that RCU_INIT_POINTER() nonsense?