All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
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
Date: Wed, 15 Jun 2016 15:41:39 -0700	[thread overview]
Message-ID: <20160615224139.GA3923@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160615221258.GE30927@twins.programming.kicks-ass.net>

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 <hch@infradead.org>
> > > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > > ---
> > >  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/20140909094235.GD19379@twins.programming.kicks-ass.net

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	other threads:[~2016-06-15 22:41 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15 21:45 [PATCH tip/core/rcu 0/12] Miscellaneous RCU fixes for 4.8 Paul E. McKenney
2016-06-15 21:46 ` [PATCH tip/core/rcu 01/12] rcu: Fix outdated rcu_scheduler_active comment Paul E. McKenney
2016-06-15 21:46 ` [PATCH tip/core/rcu 02/12] rcu: Fix outdated hotplug-exclusion comment in rcu_gp_init() Paul E. McKenney
2016-06-15 21:46 ` [PATCH tip/core/rcu 03/12] rcu: Remove some superfluous lines Paul E. McKenney
2016-06-15 21:46 ` [PATCH tip/core/rcu 04/12] rcu: Move expedited code from tree.c to tree_exp.h Paul E. McKenney
2016-06-15 22:05   ` Peter Zijlstra
2016-06-15 22:16     ` Paul E. McKenney
2016-06-17 15:48   ` Pranith Kumar
2016-06-17 17:46     ` Paul E. McKenney
2016-06-15 21:46 ` [PATCH tip/core/rcu 05/12] rcu: Move expedited code from tree_plugin.h " Paul E. McKenney
2016-06-15 21:46 ` [PATCH tip/core/rcu 06/12] rcu: Document RCU_NONIDLE() restrictions in comment header Paul E. McKenney
2016-06-15 21:46 ` [PATCH tip/core/rcu 07/12] rcu: No ordering for rcu_assign_pointer() of NULL Paul E. McKenney
2016-06-15 22:03   ` Peter Zijlstra
2016-06-15 22:12     ` Peter Zijlstra
2016-06-15 22:41       ` Paul E. McKenney [this message]
2016-06-15 21:46 ` [PATCH tip/core/rcu 08/12] rcu: Disable TASKS_RCU for usermode Linux Paul E. McKenney
2016-06-15 21:47   ` Richard Weinberger
2016-06-15 21:46 ` [PATCH tip/core/rcu 09/12] rcu: Make call_rcu_tasks() tolerate first call with irqs disabled Paul E. McKenney
2016-06-15 22:15   ` Peter Zijlstra
2016-06-15 22:54     ` Paul E. McKenney
2016-06-15 22:16   ` Peter Zijlstra
2016-06-15 22:58     ` Paul E. McKenney
2016-06-15 21:46 ` [PATCH tip/core/rcu 10/12] rcu: Fix a typo in a comment Paul E. McKenney
2016-06-15 21:46 ` [PATCH tip/core/rcu 11/12] rcu: sysctl: Panic on RCU Stall Paul E. McKenney
2016-06-15 21:46 ` [PATCH tip/core/rcu 12/12] rcu: Correctly handle sparse possible cpus Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160615224139.GA3923@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=bobby.prani@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=dvhart@linux.intel.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.