sched/fair: Do not compute overloaded status unnecessarily during lb

Only set sg_overloaded when computing sg_lb_stats() at the highest sched
domain since rd->overloaded status is updated only when load balancing
at the highest domain. While at it, move setting of sg_overloaded below
idle_cpu() check since an idle CPU can never be overloaded.

Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Link: https://lore.kernel.org/r/20241223043407.1611-8-kprateek.nayak@amd.com
This commit is contained in:
K Prateek Nayak
2024-12-23 04:34:06 +00:00
committed by Peter Zijlstra
parent 0ac1ee9ebf
commit 3229adbe78

View File

@@ -10410,6 +10410,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,
bool *sg_overutilized)
{
int i, nr_running, local_group, sd_flags = env->sd->flags;
bool balancing_at_rd = !env->sd->parent;
memset(sgs, 0, sizeof(*sgs));
@@ -10427,9 +10428,6 @@ static inline void update_sg_lb_stats(struct lb_env *env,
nr_running = rq->nr_running;
sgs->sum_nr_running += nr_running;
if (nr_running > 1)
*sg_overloaded = 1;
if (cpu_overutilized(i))
*sg_overutilized = 1;
@@ -10442,6 +10440,10 @@ static inline void update_sg_lb_stats(struct lb_env *env,
continue;
}
/* Overload indicator is only updated at root domain */
if (balancing_at_rd && nr_running > 1)
*sg_overloaded = 1;
#ifdef CONFIG_NUMA_BALANCING
/* Only fbq_classify_group() uses this to classify NUMA groups */
if (sd_flags & SD_NUMA) {