All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Josh Triplett <josh@joshtriplett.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,
	tglx@linutronix.de, peterz@infradead.org, 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 1/6] rcu: Abstract the dynticks momentary-idle operation
Date: Mon, 16 Jan 2017 03:22:39 -0800	[thread overview]
Message-ID: <20170116112239.GL5238@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170116073951.ipupoxcjnv42dwop@x>

On Sun, Jan 15, 2017 at 11:39:51PM -0800, Josh Triplett wrote:
> On Sat, Jan 14, 2017 at 12:54:40AM -0800, Paul E. McKenney wrote:
> > This commit is the first step towards full abstraction of all accesses to
> > the ->dynticks counter, implementing the previously open-coded atomic add
> > of two in a new rcu_dynticks_momentary_idle() function.  This abstraction
> > will ease changes to the ->dynticks counter operation.
> > 
> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> 
> This change has an additional effect not documented in the commit
> message: it eliminates the smp_mb__before_atomic and
> smp_mb__after_atomic calls.  Can you please document that in the commit
> message, and explain why that doesn't cause a problem?

The trick is that the old code used the non-value-returning atomic_add(),
which does not imply ordering, hence the smp_mb__before_atomic() and
smp_mb__after_atomic() calls.  The new code uses atomic_add_return(),
which does return a value, and therefore implies full ordering in and
of itself.

How would you like me to proceed?

							Thanx, Paul

> > --- a/kernel/rcu/tree.c
> > +++ b/kernel/rcu/tree.c
> > @@ -281,6 +281,19 @@ static DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = {
> >  #endif /* #ifdef CONFIG_NO_HZ_FULL_SYSIDLE */
> >  };
> >  
> > +/*
> > + * Do a double-increment of the ->dynticks counter to emulate a
> > + * momentary idle-CPU quiescent state.
> > + */
> > +static void rcu_dynticks_momentary_idle(void)
> > +{
> > +	struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks);
> > +	int special = atomic_add_return(2, &rdtp->dynticks);
> > +
> > +	/* It is illegal to call this from idle state. */
> > +	WARN_ON_ONCE(!(special & 0x1));
> > +}
> > +
> >  DEFINE_PER_CPU_SHARED_ALIGNED(unsigned long, rcu_qs_ctr);
> >  EXPORT_PER_CPU_SYMBOL_GPL(rcu_qs_ctr);
> >  
> > @@ -300,7 +313,6 @@ EXPORT_PER_CPU_SYMBOL_GPL(rcu_qs_ctr);
> >  static void rcu_momentary_dyntick_idle(void)
> >  {
> >  	struct rcu_data *rdp;
> > -	struct rcu_dynticks *rdtp;
> >  	int resched_mask;
> >  	struct rcu_state *rsp;
> >  
> > @@ -327,10 +339,7 @@ static void rcu_momentary_dyntick_idle(void)
> >  		 * quiescent state, with no need for this CPU to do anything
> >  		 * further.
> >  		 */
> > -		rdtp = this_cpu_ptr(&rcu_dynticks);
> > -		smp_mb__before_atomic(); /* Earlier stuff before QS. */
> > -		atomic_add(2, &rdtp->dynticks);  /* QS. */
> > -		smp_mb__after_atomic(); /* Later stuff after QS. */
> > +		rcu_dynticks_momentary_idle();
> >  		break;
> >  	}
> >  }
> > -- 
> > 2.5.2
> > 
> 

  reply	other threads:[~2017-01-16 11:22 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-14  8:54 [PATCH tip/core/rcu 0/6] Dynticks updates for 4.11 Paul E. McKenney
2017-01-14  8:54 ` [PATCH tip/core/rcu 1/6] rcu: Abstract the dynticks momentary-idle operation Paul E. McKenney
2017-01-16  7:39   ` Josh Triplett
2017-01-16 11:22     ` Paul E. McKenney [this message]
2017-01-16 18:57       ` Josh Triplett
2017-01-16 23:48         ` Paul E. McKenney
2017-01-14  8:54 ` [PATCH tip/core/rcu 2/6] rcu: Abstract the dynticks snapshot operation Paul E. McKenney
2017-01-14  8:54 ` [PATCH tip/core/rcu 3/6] rcu: Abstract dynticks extended quiescent state enter/exit operations Paul E. McKenney
2017-01-16  7:47   ` Josh Triplett
2017-01-16 11:34     ` Paul E. McKenney
2017-01-16 19:25       ` Josh Triplett
2017-01-17  0:12         ` Paul E. McKenney
2017-01-16 16:43   ` Peter Zijlstra
2017-01-16 21:01     ` Paul E. McKenney
2017-01-17  0:06       ` Paul E. McKenney
2017-01-14  8:54 ` [PATCH tip/core/rcu 4/6] rcu: Abstract extended quiescent state determination Paul E. McKenney
2017-01-14  8:54 ` [PATCH tip/core/rcu 5/6] rcu: Check cond_resched_rcu_qs() state less often to reduce GP overhead Paul E. McKenney
2017-01-14  8:54 ` [PATCH tip/core/rcu 6/6] rcu: Adjust FQS offline checks for exact online-CPU detection Paul E. McKenney
2017-01-16  7:50 ` [PATCH tip/core/rcu 0/6] Dynticks updates for 4.11 Josh Triplett
2017-01-18  2:44 ` Paul E. McKenney
2017-01-18  2:45   ` [PATCH v2 tip/core/rcu 1/6] rcu: Abstract the dynticks momentary-idle operation Paul E. McKenney
2017-01-18  2:45   ` [PATCH v2 tip/core/rcu 2/6] rcu: Abstract the dynticks snapshot operation Paul E. McKenney
2017-01-18  2:45   ` [PATCH v2 tip/core/rcu 3/6] rcu: Abstract dynticks extended quiescent state enter/exit operations Paul E. McKenney
2017-01-21 20:49     ` Josh Triplett
2017-01-23 19:45       ` Paul E. McKenney
2017-01-18  2:45   ` [PATCH v2 tip/core/rcu 4/6] rcu: Abstract extended quiescent state determination Paul E. McKenney
2017-01-18  2:45   ` [PATCH v2 tip/core/rcu 5/6] rcu: Check cond_resched_rcu_qs() state less often to reduce GP overhead Paul E. McKenney
2017-01-18  2:45   ` [PATCH v2 tip/core/rcu 6/6] rcu: Adjust FQS offline checks for exact online-CPU detection Paul E. McKenney
2017-01-24 21:46   ` [PATCH v3 tip/core/rcu 0/6] Dynticks updates for 4.11 Paul E. McKenney
2017-01-24 21:46     ` [PATCH v3 tip/core/rcu 1/6] rcu: Abstract the dynticks momentary-idle operation Paul E. McKenney
2017-01-24 21:46     ` [PATCH v3 tip/core/rcu 2/6] rcu: Abstract the dynticks snapshot operation Paul E. McKenney
2017-01-24 21:46     ` [PATCH v3 tip/core/rcu 3/6] rcu: Abstract dynticks extended quiescent state enter/exit operations Paul E. McKenney
2017-01-24 21:46     ` [PATCH v3 tip/core/rcu 4/6] rcu: Abstract extended quiescent state determination Paul E. McKenney
2017-01-24 21:46     ` [PATCH v3 tip/core/rcu 5/6] rcu: Check cond_resched_rcu_qs() state less often to reduce GP overhead Paul E. McKenney
2017-01-24 21:46     ` [PATCH v3 tip/core/rcu 6/6] rcu: Adjust FQS offline checks for exact online-CPU detection 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=20170116112239.GL5238@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.