]> git.baikalelectronics.ru Git - kernel.git/commitdiff
rcu: Decrease FQS scan wait time in case of callback overloading
authorPaul E. McKenney <paulmck@kernel.org>
Tue, 12 Apr 2022 22:08:14 +0000 (15:08 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 19 Jul 2022 18:39:59 +0000 (11:39 -0700)
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>
Reviewed-by: Neeraj Upadhyay <quic_neeraju@quicinc.com>
kernel/rcu/tree.c

index c25ba442044a6e9452a43f617a93abd4a8b6ab08..52094e72866e514dbf0b112bdc868c2ed13724d7 100644 (file)
@@ -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