Callback-overload update for v5.7
Subsystems (2)
Paul E. McKenney
maintainercover Callback-overload update for v5.7
Hello!
This series contains updates to handling of callback-overload condiitons.
1. Clear ->core_needs_qs at GP end or self-reported QS.
2. React to callback overload by aggressively seeking quiescent
states.
3. React to callback overload by boosting RCU readers.
4. Fix spelling mistake "leval" -> "level".
5. Update __call_rcu() comments.
Thanx, Paul
------------------------------------------------------------------------
Documentation/admin-guide/kernel-parameters.txt | 9 ++ kernel/rcu/tree.c | 97 ++++++++++++++++++++---- kernel/rcu/tree.h | 4 kernel/rcu/tree_plugin.h | 6 - 4 files changed, 99 insertions(+), 17 deletions(-)
[email protected]
maintainerPATCH 1/5 rcu: Clear ->core_needs_qs at GP end or self-reported QS
From: "Paul E. McKenney" <[email protected]>
The rcu_data structure's ->core_needs_qs field does not necessarily get cleared in a timely fashion after the corresponding CPUs' quiescent state has been reported. From a functional viewpoint, no harm done, but this can result in excessive invocation of RCU core processing, as witnessed by the kernel test robot, which saw greatly increased softirq overhead.
This commit therefore restores the rcu_report_qs_rdp() function's clearing of this field, but only when running on the corresponding CPU. Cases where some other CPU reports the quiescent state (for example, on behalf of an idle CPU) are handled by setting this field appropriately within the __note_gp_changes() function's end-of-grace-period checks. This handling is carried out regardless of whether the end of a grace period actually happened, thus handling the case where a CPU goes non-idle after a quiescent state is reported on its behalf, but before the grace period ends. This fix also avoids cross-CPU updates to ->core_needs_qs,
While in the area, this commit changes the __note_gp_changes() need_gp variable's name to need_qs because it is a quiescent state that is needed from the CPU in question.
--- kernel/rcu/tree.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
kernel/rcu/tree.c +9 -4
@@ -1386,7 +1386,7 @@ static void __maybe_unused rcu_advance_cbs_nowake(struct rcu_node *rnp,static bool __note_gp_changes (struct rcu_node *rnp,struct rcu_data *rdp) {bool ret = false; -bool need_gp; +bool need_qs;const bool offloaded =IS_ENABLED (CONFIG_RCU_NOCB_CPU ) &&rcu_segcblist_is_offloaded (&rdp->cblist);
@@ -1400,10 +1400,13 @@ static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp) unlikely(READ_ONCE(rdp->gpwrap))) { if (!offloaded) ret = rcu_advance_cbs(rnp, rdp); /* Advance CBs. */ + rdp->core_needs_qs = false; trace_rcu_grace_period(rcu_state.name, rdp->gp_seq, TPS("cpuend")); } else {if (!offloaded) ret =rcu_accelerate_cbs (rnp, rdp);/* Recent CBs. */ +if (rdp->core_needs_qs) + rdp->core_needs_qs = !!(rnp->qsmask & rdp->grpmask); }/* Now handle the beginnings of any new-to-this-CPU grace periods. */
@@ -1415,9 +1418,9 @@ static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp)* go looking for one. */ trace_rcu_grace_period (rcu_state.name, rnp->gp_seq,TPS ("cpustart" )); - need_gp = !!(rnp->qsmask & rdp->grpmask); - rdp->cpu_no_qs.b.norm = need_gp; - rdp->core_needs_qs = need_gp; + need_qs = !!(rnp->qsmask & rdp->grpmask); + rdp->cpu_no_qs.b.norm = need_qs; + rdp->core_needs_qs = need_qs;zero_cpu_stall_ticks (rdp); } rdp->gp_seq = rnp->gp_seq;/* Remember new grace-period state. */
@@ -1987,6 +1990,8 @@ rcu_report_qs_rdp(int cpu, struct rcu_data *rdp)return ; } mask = rdp->grpmask; +if (rdp->cpu ==smp_processor_id ()) + rdp->core_needs_qs = false;if ((rnp->qsmask & mask) ==0 ) {raw_spin_unlock_irqrestore_rcu_node (rnp, flags); }else {
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 2/5 rcu: React to callback overload by aggressively seeking quiescent states
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
In default configutions, RCU currently waits at least 100 milliseconds before asking cond_resched() and/or resched_rcu() for help seeking quiescent states to end a grace period. But 100 milliseconds can be one good long time during an RCU callback flood, for example, as can happen when user processes repeatedly open and close files in a tight loop. These 100-millisecond gaps in successive grace periods during a callback flood can result in excessive numbers of callbacks piling up, unnecessarily increasing memory footprint.
This commit therefore asks cond_resched() and/or resched_rcu() for help as early as the first FQS scan when at least one of the CPUs has more than 20,000 callbacks queued, a number that can be changed using the new rcutree.qovld kernel boot parameter. An auxiliary qovld_calc variable is used to avoid acquisition of locks that have not yet been initialized. Early tests indicate that this reduces the RCU-callback memory footprint during rcutorture floods by from 50% to 4x, depending on configuration.
--- Documentation/admin-guide/kernel-parameters.txt | 9 +++ kernel/rcu/tree.c | 75 +++++++++++++++++++++++-- kernel/rcu/tree.h | 4 ++ kernel/rcu/tree_plugin.h | 2 + 4 files changed, 86 insertions(+), 4 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +9 -0
@@ -3980,6 +3980,15 @@ Set threshold of queued RCU callbacks below which batch limiting is re-enabled. + rcutree.qovld= [KNL] + Set threshold of queued RCU callbacks beyond which + RCU's force-quiescent-state scan will aggressively + enlist help from cond_resched() and sched IPIs to + help CPUs more quickly reach quiescent states. + Set to less than zero to make this be set based + on rcutree.qhimark at boot time and to zero to + disable more aggressive help enlistment. + rcutree.rcu_idle_gp_delay= [KNL] Set wakeup interval for idle CPUs that have RCU callbacks (RCU_FAST_NO_HZ=y).
kernel/rcu/tree.c +71 -4
144 lines not on this page · raw message
kernel/rcu/tree.h +4 -0
@@ -68,6 +68,8 @@ struct rcu_node {/* Online CPUs for next expedited GP. */ /* Any CPU that has ever been online will */ /* have its bit set. */ +unsigned long cbovldmask; +/* CPUs experiencing callback overload. */ unsigned long ffmask;/* Fully functional CPUs. */ unsigned long grpmask;/* Mask to apply to parent qsmask. */ /* Only one bit will be set in this mask. */
@@ -321,6 +323,8 @@ struct rcu_state {atomic_t expedited_need_qs;/* # CPUs left to check in. */ struct swait_queue_head expedited_wq;/* Wait for check-ins. */ int ncpus_snap;/* # CPUs seen last time. */ +u8 cbovld;/* Callback overload now? */ +u8 cbovldnext;/* ^ ^ next time? */ unsigned long jiffies_force_qs;/* Time at which to invoke */ /* force_quiescent_state(). */
kernel/rcu/tree_plugin.h +2 -0
@@ -56,6 +56,8 @@ static void __init rcu_bootup_announce_oddness(void)pr_info ("\tBoot-time adjustment of callback high-water mark to %ld.\n" , qhimark);if (qlowmark !=DEFAULT_RCU_QLOMARK )pr_info ("\tBoot-time adjustment of callback low-water mark to %ld.\n" , qlowmark); +if (qovld !=DEFAULT_RCU_QOVLD ) +pr_info ("\tBoot-time adjustment of callback overload leval to %ld.\n" , qovld);if (jiffies_till_first_fqs !=ULONG_MAX )pr_info ("\tBoot-time adjustment of first FQS scan delay to %ld jiffies.\n" , jiffies_till_first_fqs);if (jiffies_till_next_fqs !=ULONG_MAX )
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 3/5 rcu: React to callback overload by boosting RCU readers
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
RCU priority boosting currently is not applied until the grace period is at least 250 milliseconds old (or the number of milliseconds specified by the CONFIG_RCU_BOOST_DELAY Kconfig option). Although this has worked well, it can result in OOM under conditions of RCU callback flooding. One can argue that the real-time systems using RCU priority boosting should carefully avoid RCU callback flooding, but one can just as well argue that an OOM is a rather obnoxious error message.
This commit therefore disables the RCU priority boosting delay when there are excessive numbers of callbacks queued.
--- kernel/rcu/tree_plugin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree_plugin.h +1 -1
@@ -1079,7 +1079,7 @@ static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags) (rnp->gp_tasks != NULL && rnp->boost_tasks == NULL && rnp->qsmask == 0 && - ULONG_CMP_GE(jiffies, rnp->boost_time))) { + (ULONG_CMP_GE(jiffies, rnp->boost_time) || rcu_state.cbovld))) {if (rnp->exp_tasks ==NULL ) rnp->boost_tasks = rnp->gp_tasks;raw_spin_unlock_irqrestore_rcu_node (rnp, flags);
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 4/5 rcu: Fix spelling mistake "leval" -> "level"
In reply to Paul E. McKenneyFrom: Colin Ian King <[email protected]>
This commit fixes a spelling mistake in a pr_info() message.
--- kernel/rcu/tree_plugin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree_plugin.h +1 -1
@@ -57,7 +57,7 @@ static void __init rcu_bootup_announce_oddness(void)if (qlowmark !=DEFAULT_RCU_QLOMARK )pr_info ("\tBoot-time adjustment of callback low-water mark to %ld.\n" , qlowmark);if (qovld !=DEFAULT_RCU_QOVLD ) -pr_info ("\tBoot-time adjustment of callback overload leval to %ld.\n" , qovld); +pr_info ("\tBoot-time adjustment of callback overload level to %ld.\n" , qovld);if (jiffies_till_first_fqs !=ULONG_MAX )pr_info ("\tBoot-time adjustment of first FQS scan delay to %ld jiffies.\n" , jiffies_till_first_fqs);if (jiffies_till_next_fqs !=ULONG_MAX )
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 5/5 rcu: Update __call_rcu() comments
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The __call_rcu() function's header comment refers to a cpu argument that no longer exists, and the comment of the return path from rcu_nocb_try_bypass() ignores the non-no-CBs CPU case. This comit therefore update both comments.
--- kernel/rcu/tree.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
kernel/rcu/tree.c +2 -7
@@ -2642,12 +2642,7 @@ static void check_cb_ovld(struct rcu_data *rdp)raw_spin_unlock_rcu_node (rnp); } -/* -* Helper function for call_rcu() and friends. The cpu argument will -* normally be -1, indicating "currently running CPU". It may specify -* a CPU only if that CPU is a no-CBs CPU. Currently, only rcu_barrier() -* is expected to specify a CPU. -*/ +/* Helper function for call_rcu() and friends. */ static void __call_rcu (struct rcu_head *head,rcu_callback_t func) {
@@ -2688,7 +2683,7 @@ __call_rcu(struct rcu_head *head, rcu_callback_t func)check_cb_ovld (rdp);if (rcu_nocb_try_bypass (rdp, head, &was_alldone, flags))return ;// Enqueued onto ->nocb_bypass, so just leave. -/* If we get here, rcu_nocb_try_bypass() acquired ->nocb_lock. */ +// If no-CBs CPU gets here, rcu_nocb_try_bypass() acquired ->nocb_lock. rcu_segcblist_enqueue (&rdp->cblist, head);if (__is_kfree_rcu_offset ((unsigned long )func)) trace_rcu_kfree_callback(rcu_state.name, head,
Signature · 1 line
2.9.5