[tip:,sched/core] sched/nohz: Update comments about NEWILB_KICK

Message ID 169778892143.3135.5766512330437156531.tip-bot2@tip-bot2
State New
Headers
Series [tip:,sched/core] sched/nohz: Update comments about NEWILB_KICK |

Commit Message

tip-bot2 for Thomas Gleixner Oct. 20, 2023, 8:02 a.m. UTC
  The following commit has been merged into the sched/core branch of tip:

Commit-ID:     fb064e5ae1657595c090ebbc5b15787a3ef603e9
Gitweb:        https://git.kernel.org/tip/fb064e5ae1657595c090ebbc5b15787a3ef603e9
Author:        Joel Fernandes (Google) <joel@joelfernandes.org>
AuthorDate:    Fri, 20 Oct 2023 01:40:27 
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Fri, 20 Oct 2023 09:56:21 +02:00

sched/nohz: Update comments about NEWILB_KICK

How ILB is triggered without IPIs is cryptic. Out of mercy for future
code readers, document it in code comments.

The comments are derived from a discussion with Vincent in a past
review.

Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20231020014031.919742-2-joel@joelfernandes.org
---
 kernel/sched/fair.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
  

Patch

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9ae2208..8c486ff 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -12005,8 +12005,19 @@  static bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
 }
 
 /*
- * Check if we need to run the ILB for updating blocked load before entering
- * idle state.
+ * Check if we need to directly run the ILB for updating blocked load before
+ * entering idle state. Here we run ILB directly without issuing IPIs.
+ *
+ * Note that when this function is called, the tick may not yet be stopped on
+ * this CPU yet. nohz.idle_cpus_mask is updated only when tick is stopped and
+ * cleared on the next busy tick. In other words, nohz.idle_cpus_mask updates
+ * don't align with CPUs enter/exit idle to avoid bottlenecks due to high idle
+ * entry/exit rate (usec). So it is possible that _nohz_idle_balance() is
+ * called from this function on (this) CPU that's not yet in the mask. That's
+ * OK because the goal of nohz_run_idle_balance() is to run ILB only for
+ * updating the blocked load of already idle CPUs without waking up one of
+ * those idle CPUs and outside the preempt disable / irq off phase of the local
+ * cpu about to enter idle, because it can take a long time.
  */
 void nohz_run_idle_balance(int cpu)
 {