From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Joel Fernandes <joel@joelfernandes.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, peterz@infradead.org,
rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com,
fweisbec@gmail.com, oleg@redhat.com, joel.opensrc@gmail.com,
torvalds@linux-foundation.org, npiggin@gmail.com
Subject: Re: [tip/core/rcu, 05/21] rcu: Make rcu_gp_cleanup() more accurately predict need for new GP
Date: Thu, 10 May 2018 06:15:46 -0700 [thread overview]
Message-ID: <20180510131546.GN26088@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180510072133.GA122810@joelaf.mtv.corp.google.com>
On Thu, May 10, 2018 at 12:21:33AM -0700, Joel Fernandes wrote:
> Hi Paul,
>
> On Sun, Apr 22, 2018 at 08:03:28PM -0700, Paul E. McKenney wrote:
> > Currently, rcu_gp_cleanup() scans the rcu_node tree in order to reset
> > state to reflect the end of the grace period. It also checks to see
> > whether a new grace period is needed, but in a number of cases, rather
> > than directly cause the new grace period to be immediately started, it
> > instead leaves the grace-period-needed state where various fail-safes
> > can find it. This works fine, but results in higher contention on the
> > root rcu_node structure's ->lock, which is undesirable, and contention
> > on that lock has recently become noticeable.
> >
> > This commit therefore makes rcu_gp_cleanup() immediately start a new
> > grace period if there is any need for one.
> >
> > It is quite possible that it will later be necessary to throttle the
> > grace-period rate, but that can be dealt with when and if.
> >
> > Reported-by: Nicholas Piggin <npiggin@gmail.com>
> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > ---
> > kernel/rcu/tree.c | 16 ++++++++++------
> > kernel/rcu/tree.h | 1 -
> > kernel/rcu/tree_plugin.h | 17 -----------------
> > 3 files changed, 10 insertions(+), 24 deletions(-)
> >
> > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > index 497f139056c7..afc5e32f0da4 100644
> > --- a/kernel/rcu/tree.c
> > +++ b/kernel/rcu/tree.c
> > @@ -1763,14 +1763,14 @@ rcu_start_future_gp(struct rcu_node *rnp, struct rcu_data *rdp,
> > * Clean up any old requests for the just-ended grace period. Also return
> > * whether any additional grace periods have been requested.
> > */
> > -static int rcu_future_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp)
> > +static bool rcu_future_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp)
> > {
> > int c = rnp->completed;
> > - int needmore;
> > + bool needmore;
> > struct rcu_data *rdp = this_cpu_ptr(rsp->rda);
> >
> > need_future_gp_element(rnp, c) = 0;
> > - needmore = need_future_gp_element(rnp, c + 1);
> > + needmore = need_any_future_gp(rnp);
> > trace_rcu_future_gp(rnp, rdp, c,
> > needmore ? TPS("CleanupMore") : TPS("Cleanup"));
> > return needmore;
> > @@ -2113,7 +2113,6 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
> > {
> > unsigned long gp_duration;
> > bool needgp = false;
> > - int nocb = 0;
> > struct rcu_data *rdp;
> > struct rcu_node *rnp = rcu_get_root(rsp);
> > struct swait_queue_head *sq;
> > @@ -2152,7 +2151,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
> > if (rnp == rdp->mynode)
> > needgp = __note_gp_changes(rsp, rnp, rdp) || needgp;
> > /* smp_mb() provided by prior unlock-lock pair. */
> > - nocb += rcu_future_gp_cleanup(rsp, rnp);
> > + needgp = rcu_future_gp_cleanup(rsp, rnp) || needgp;
> > sq = rcu_nocb_gp_get(rnp);
> > raw_spin_unlock_irq_rcu_node(rnp);
> > rcu_nocb_gp_cleanup(sq);
> > @@ -2162,13 +2161,18 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
> > }
> > rnp = rcu_get_root(rsp);
> > raw_spin_lock_irq_rcu_node(rnp); /* Order GP before ->completed update. */
> > - rcu_nocb_gp_set(rnp, nocb);
> >
> > /* Declare grace period done. */
> > WRITE_ONCE(rsp->completed, rsp->gpnum);
> > trace_rcu_grace_period(rsp->name, rsp->completed, TPS("end"));
> > rsp->gp_state = RCU_GP_IDLE;
> > + /* Check for GP requests since above loop. */
> > rdp = this_cpu_ptr(rsp->rda);
> > + if (need_any_future_gp(rnp)) {
> > + trace_rcu_future_gp(rnp, rdp, rsp->completed - 1,
> > + TPS("CleanupMore"));
> > + needgp = true;
>
> Patch makes sense to me.
>
> I didn't get the "rsp->completed - 1" bit in the call to trace_rcu_future_gp.
> The grace period that just completed is in rsp->completed. The future one
> should be completed + 1. What is meaning of the third argument 'c' to the
> trace event?
The thought was that the grace period must have been requested while
rsp->completed was one less than it is now.
In the current code, it uses rnp->gp_seq_needed, which is instead the
grace period that is being requested.
> Also in rcu_future_gp_cleanup, we call:
> trace_rcu_future_gp(rnp, rdp, c,
> needmore ? TPS("CleanupMore") : TPS("Cleanup"));
> For this case, in the final trace event record, rnp->completed and c will be
> the same, since c is set to rnp->completed before calling
> trace_rcu_future_gp. I was thinking they should be different, do you expect
> them to be the same?
Hmmm... That does look a bit inconsistent. And it currently uses
rnp->gp_seq instead of rnp->gp_seq_needed despite having the same
"CleanupMore" name.
Looks like a review of the calls to trace_rcu_this_gp() is in order.
Or did you have suggestions for name/gp assocations for this trace
message type?
Thanx, Paul
next prev parent reply other threads:[~2018-05-10 13:14 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-23 3:02 [PATCH tip/core/rcu 0/21] Contention reduction for v4.18 Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 01/21] rcu: Improve non-root rcu_cbs_completed() accuracy Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 02/21] rcu: Make rcu_start_future_gp()'s grace-period check more precise Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 03/21] rcu: Add accessor macros for the ->need_future_gp[] array Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 04/21] rcu: Make rcu_gp_kthread() check for early-boot activity Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 05/21] rcu: Make rcu_gp_cleanup() more accurately predict need for new GP Paul E. McKenney
2018-05-10 7:21 ` [tip/core/rcu, " Joel Fernandes
2018-05-10 13:15 ` Paul E. McKenney [this message]
2018-05-10 17:22 ` Joel Fernandes
2018-05-11 16:22 ` Paul E. McKenney
2018-05-10 17:37 ` Joel Fernandes
2018-05-11 16:24 ` Paul E. McKenney
2018-05-11 16:27 ` Joel Fernandes
2018-04-23 3:03 ` [PATCH tip/core/rcu 06/21] rcu: Avoid losing ->need_future_gp[] values due to GP start/end races Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 07/21] rcu: Make rcu_future_needs_gp() check all ->need_future_gps[] elements Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 08/21] rcu: Convert ->need_future_gp[] array to boolean Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 09/21] rcu: Make rcu_migrate_callbacks wake GP kthread when needed Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 10/21] rcu: Avoid __call_rcu_core() root rcu_node ->lock acquisition Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 11/21] rcu: Switch __rcu_process_callbacks() to rcu_accelerate_cbs() Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 12/21] rcu: Cleanup, don't put ->completed into an int Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 13/21] rcu: Clear request other than RCU_GP_FLAG_INIT at GP end Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 14/21] rcu: Inline rcu_start_gp_advanced() into rcu_start_future_gp() Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 15/21] rcu: Make rcu_start_future_gp() caller select grace period Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 16/21] rcu: Add funnel locking to rcu_start_this_gp() Paul E. McKenney
2018-05-12 6:03 ` [tip/core/rcu,16/21] " Joel Fernandes
2018-05-12 14:40 ` Paul E. McKenney
2018-05-12 14:44 ` Paul E. McKenney
2018-05-12 23:53 ` Joel Fernandes
2018-05-13 15:38 ` Paul E. McKenney
2018-05-13 16:49 ` Joel Fernandes
2018-05-13 19:09 ` Paul E. McKenney
2018-05-13 19:51 ` Joel Fernandes
2018-05-14 2:22 ` Paul E. McKenney
2018-05-14 5:00 ` Joel Fernandes
2018-05-14 13:23 ` Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 17/21] rcu: Make rcu_start_this_gp() check for out-of-range requests Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 18/21] rcu: The rcu_gp_cleanup() function does not need cpu_needs_another_gp() Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 19/21] rcu: Simplify and inline cpu_needs_another_gp() Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 20/21] rcu: Drop early GP request check from rcu_gp_kthread() Paul E. McKenney
2018-04-23 3:03 ` [PATCH tip/core/rcu 21/21] rcu: Update list of rcu_future_grace_period() trace events Paul E. McKenney
2018-05-14 6:42 ` [PATCH tip/core/rcu 0/21] Contention reduction for v4.18 Nicholas Piggin
2018-05-14 16:09 ` Paul E. McKenney
2018-05-14 22:21 ` Nicholas Piggin
2018-05-14 22:42 ` 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=20180510131546.GN26088@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=joel.opensrc@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=npiggin@gmail.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).