Commit fb77dccf authored by Paul E. McKenney's avatar Paul E. McKenney
Browse files

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: default avatarPaul E. McKenney <paulmck@kernel.org>
Reviewed-by: default avatarNeeraj Upadhyay <quic_neeraju@quicinc.com>
parent 4f2bfd94
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -1983,7 +1983,12 @@ static noinline_for_stack void rcu_gp_fqs_loop(void)
		gf = RCU_GP_FLAG_OVLD;
		gf = RCU_GP_FLAG_OVLD;
	ret = 0;
	ret = 0;
	for (;;) {
	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);
			WRITE_ONCE(rcu_state.jiffies_force_qs, jiffies + j);
			/*
			/*
			 * jiffies_force_qs before RCU_GP_WAIT_FQS state
			 * jiffies_force_qs before RCU_GP_WAIT_FQS state