From: "Paul E. McKenney" <paulmck@kernel.org>
To: "Joel Fernandes (Google)" <joel@joelfernandes.org>
Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
rushikesh.s.kadam@intel.com, urezki@gmail.com,
neeraj.iitr10@gmail.com, frederic@kernel.org,
rostedt@goodmis.org
Subject: Re: [PATCH rcu/next 2/3] rcu: Fix late wakeup when flush of bypass cblist happens (v6)
Date: Wed, 21 Sep 2022 07:54:15 -0700 [thread overview]
Message-ID: <20220921145415.GC4196@paulmck-ThinkPad-P17-Gen-1> (raw)
In-Reply-To: <20220917164200.511783-3-joel@joelfernandes.org>
On Sat, Sep 17, 2022 at 04:41:59PM +0000, Joel Fernandes (Google) wrote:
> When the bypass cblist gets too big or its timeout has occurred, it is
> flushed into the main cblist. However, the bypass timer is still running
> and the behavior is that it would eventually expire and wake the GP
> thread.
>
> Since we are going to use the bypass cblist for lazy CBs, do the wakeup
> soon as the flush for "too big or too long" bypass list happens.
> Otherwise, long delays can happen for callbacks which get promoted from
> lazy to non-lazy.
>
> This is a good thing to do anyway (regardless of future lazy patches),
> since it makes the behavior consistent with behavior of other code paths
> where flushing into the ->cblist makes the GP kthread into a
> non-sleeping state quickly.
>
> [ Frederic Weisbec: changes to not do wake up GP thread unless needed,
> comment changes ].
>
> Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Queued and pushed this and 1/3, thank you both!
Thanx, Paul
> ---
> kernel/rcu/tree_nocb.h | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
> index 0a5f0ef41484..04c87f250e01 100644
> --- a/kernel/rcu/tree_nocb.h
> +++ b/kernel/rcu/tree_nocb.h
> @@ -433,8 +433,9 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
> if ((ncbs && j != READ_ONCE(rdp->nocb_bypass_first)) ||
> ncbs >= qhimark) {
> rcu_nocb_lock(rdp);
> + *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist);
> +
> if (!rcu_nocb_flush_bypass(rdp, rhp, j)) {
> - *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist);
> if (*was_alldone)
> trace_rcu_nocb_wake(rcu_state.name, rdp->cpu,
> TPS("FirstQ"));
> @@ -447,7 +448,12 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
> rcu_advance_cbs_nowake(rdp->mynode, rdp);
> rdp->nocb_gp_adv_time = j;
> }
> - rcu_nocb_unlock_irqrestore(rdp, flags);
> +
> + // The flush succeeded and we moved CBs into the regular list.
> + // Don't wait for the wake up timer as it may be too far ahead.
> + // Wake up the GP thread now instead, if the cblist was empty.
> + __call_rcu_nocb_wake(rdp, *was_alldone, flags);
> +
> return true; // Callback already enqueued.
> }
>
> --
> 2.37.3.968.ga6b4b080e4-goog
>
next prev parent reply other threads:[~2022-09-21 14:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-17 16:41 [PATCH rcu/next 0/3] Preparatory patches borrowed from lazy rcu v5 Joel Fernandes (Google)
2022-09-17 16:41 ` [PATCH rcu/next 1/3] rcu/tree: Use READ_ONCE() for lockless read of rnp->qsmask Joel Fernandes (Google)
2022-09-17 16:41 ` [PATCH rcu/next 2/3] rcu: Fix late wakeup when flush of bypass cblist happens (v6) Joel Fernandes (Google)
2022-09-21 14:54 ` Paul E. McKenney [this message]
2022-09-17 16:42 ` [PATCH rcu/next 3/3] rcu: Call trace_rcu_callback() also for bypass queuing (v2) Joel Fernandes (Google)
2022-09-17 19:58 ` Frederic Weisbecker
2022-09-17 21:43 ` Joel Fernandes
2022-09-17 22:21 ` Frederic Weisbecker
2022-09-17 22:42 ` Joel Fernandes
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=20220921145415.GC4196@paulmck-ThinkPad-P17-Gen-1 \
--to=paulmck@kernel.org \
--cc=frederic@kernel.org \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neeraj.iitr10@gmail.com \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=rushikesh.s.kadam@intel.com \
--cc=urezki@gmail.com \
/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
all inboxes | Powered by JetHome®