From: "Paul E. McKenney" <paulmck@kernel.org>
To: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@fb.com, rostedt@goodmis.org
Subject: Re: [PATCH rcu 01/12] rcu: Decrease FQS scan wait time in case of callback overloading
Date: Tue, 21 Jun 2022 15:19:25 -0700 [thread overview]
Message-ID: <20220621221925.GQ1790663@paulmck-ThinkPad-P17-Gen-1> (raw)
In-Reply-To: <87c17e9a-565a-d717-3534-83a4c506b984@quicinc.com>
On Tue, Jun 21, 2022 at 10:59:58AM +0530, Neeraj Upadhyay wrote:
>
>
> On 6/21/2022 3:50 AM, Paul E. McKenney wrote:
> > The force-quiesce-state loop function rcu_gp_fqs_loop() checks for
> > callback overloading and does an immediate initial scan for idle CPUs
> > if so. However, subsequent rescans will be carried out at as leisurely a
> > rate as they always are, as specified by the rcutree.jiffies_till_next_fqs
> > module parameter. It might be tempting to just continue immediately
> > rescanning, but this turns the RCU grace-period kthread into a CPU hog.
> > It might also be tempting to reduce the time between rescans to a single
> > jiffy, but this can be problematic on larger systems.
> >
> > This commit therefore divides the normal time between rescans by three,
> > rounding up. Thus a small system running at HZ=1000 that is suffering
> > from callback overload will wait only one jiffy instead of the normal
> > three between rescans.
> >
> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> > ---
> > kernel/rcu/tree.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > index c25ba442044a6..c19d5926886fb 100644
> > --- a/kernel/rcu/tree.c
> > +++ b/kernel/rcu/tree.c
> > @@ -1993,6 +1993,11 @@ static noinline_for_stack void rcu_gp_fqs_loop(void)
> > WRITE_ONCE(rcu_state.jiffies_kick_kthreads,
> > jiffies + (j ? 3 * j : 2));
> > }
> > + if (rcu_state.cbovld) {
> > + j = (j + 2) / 3;
> > + if (j <= 0)
> > + j = 1;
> > + }
>
> We update 'j' here, after setting rcu_state.jiffies_force_qs
>
> WRITE_ONCE(rcu_state.jiffies_force_qs, jiffies + j)
>
> So, we return from swait_event_idle_timeout_exclusive after 1/3 time
> duration.
>
> swait_event_idle_timeout_exclusive(rcu_state.gp_wq,
> rcu_gp_fqs_check_wake(&gf), j);
>
> This can result in !timer_after check to return false and we will
> enter the 'else' (stray signal block) code?
>
> This might not matter for first 2 fqs loop iterations, where
> RCU_GP_FLAG_OVLD is set in 'gf', but subsequent iterations won't benefit
> from this patch?
>
>
> if (!time_after(rcu_state.jiffies_force_qs, jiffies) ||
> (gf & (RCU_GP_FLAG_FQS | RCU_GP_FLAG_OVLD))) {
> ...
> } else {
> /* Deal with stray signal. */
> }
>
>
> So, do we need to move this calculation above the 'if' block which sets
> rcu_state.jiffies_force_qs?
> if (!ret) {
>
> WRITE_ONCE(rcu_state.jiffies_force_qs, jiffies +
> j);...
> }
Good catch, thank you! How about the updated patch shown below?
Thanx, Paul
------------------------------------------------------------------------
commit 77de092c78f549b5c28075bfee9998a525d21f84
Author: Paul E. McKenney <paulmck@kernel.org>
Date: Tue Apr 12 15:08:14 2022 -0700
rcu: Decrease FQS scan wait time in case of callback overloading
The force-quiesce-state loop function rcu_gp_fqs_loop() checks for
callback overloading and does an immediate initial scan for idle CPUs
if so. However, subsequent rescans will be carried out at as leisurely a
rate as they always are, as specified by the rcutree.jiffies_till_next_fqs
module parameter. It might be tempting to just continue immediately
rescanning, but this turns the RCU grace-period kthread into a CPU hog.
It might also be tempting to reduce the time between rescans to a single
jiffy, but this can be problematic on larger systems.
This commit therefore divides the normal time between rescans by three,
rounding up. Thus a small system running at HZ=1000 that is suffering
from callback overload will wait only one jiffy instead of the normal
three between rescans.
[ paulmck: Apply Neeraj Upadhyay feedback. ]
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index c25ba442044a6..52094e72866e5 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1983,7 +1983,12 @@ static noinline_for_stack void rcu_gp_fqs_loop(void)
gf = RCU_GP_FLAG_OVLD;
ret = 0;
for (;;) {
- if (!ret) {
+ if (rcu_state.cbovld) {
+ j = (j + 2) / 3;
+ if (j <= 0)
+ j = 1;
+ }
+ if (!ret || time_before(jiffies + j, rcu_state.jiffies_force_qs)) {
WRITE_ONCE(rcu_state.jiffies_force_qs, jiffies + j);
/*
* jiffies_force_qs before RCU_GP_WAIT_FQS state
next prev parent reply other threads:[~2022-06-21 22:19 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 22:20 [PATCH rcu 0/12] Miscellaneous fixes for v5.20 Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 01/12] rcu: Decrease FQS scan wait time in case of callback overloading Paul E. McKenney
2022-06-21 5:29 ` Neeraj Upadhyay
2022-06-21 22:19 ` Paul E. McKenney [this message]
2022-06-22 11:46 ` Neeraj Upadhyay
2022-06-20 22:20 ` [PATCH rcu 02/12] rcu: Avoid tracing a few functions executed in stop machine Paul E. McKenney
2022-06-21 5:47 ` Neeraj Upadhyay
2022-06-21 22:21 ` Paul E. McKenney
2022-06-22 11:50 ` Neeraj Upadhyay
2022-06-22 15:35 ` Paul E. McKenney
2022-06-22 15:49 ` Neeraj Upadhyay
2022-06-23 0:29 ` Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 03/12] rcu: Add rnp->cbovldmask check in rcutree_migrate_callbacks() Paul E. McKenney
2022-06-21 5:57 ` Neeraj Upadhyay
2022-06-21 22:22 ` Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 04/12] rcu: Immediately boost preempted readers for strict grace periods Paul E. McKenney
2022-06-21 6:00 ` Neeraj Upadhyay
2022-06-20 22:20 ` [PATCH rcu 05/12] rcu: Forbid RCU_STRICT_GRACE_PERIOD in TINY_RCU kernels Paul E. McKenney
2022-06-21 6:02 ` Neeraj Upadhyay
2022-06-20 22:20 ` [PATCH rcu 06/12] locking/csd_lock: Change csdlock_debug from early_param to __setup Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 07/12] rcu: tiny: Record kvfree_call_rcu() call stack for KASAN Paul E. McKenney
2022-06-21 6:31 ` Neeraj Upadhyay
2022-06-21 19:31 ` Paul E. McKenney
2022-06-21 21:14 ` Marco Elver
2022-06-21 22:17 ` Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 08/12] rcu: Cleanup RCU urgency state for offline CPU Paul E. McKenney
2022-06-21 7:03 ` Neeraj Upadhyay
2022-06-21 22:24 ` Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 09/12] rcu/kvfree: Remove useless monitor_todo flag Paul E. McKenney
2022-06-21 10:02 ` Neeraj Upadhyay
2022-06-20 22:20 ` [PATCH rcu 10/12] rcu: Initialize first_gp_fqs at declaration in rcu_gp_fqs() Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 11/12] rcu/tree: Add comment to describe GP-done condition in fqs loop Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 12/12] srcu: Block less aggressively for expedited grace periods Paul E. McKenney
2022-06-21 2:00 ` Zhangfei Gao
2022-06-21 3:15 ` Paul E. McKenney
2022-06-21 7:43 ` Shameerali Kolothum Thodi
2022-06-21 19:36 ` Paul E. McKenney
2022-06-21 10:13 ` Neeraj Upadhyay
2022-06-21 22:25 ` 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=20220621221925.GQ1790663@paulmck-ThinkPad-P17-Gen-1 \
--to=paulmck@kernel.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_neeraju@quicinc.com \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.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).