Skip to content

Commit

Permalink
sched/fair: Do not compute NUMA Balancing stats unnecessarily during lb
Browse files Browse the repository at this point in the history
Aggregate nr_numa_running and nr_preferred_running when load balancing
at NUMA domains only. While at it, also move the aggregation below the
idle_cpu() check since an idle CPU cannot have any preferred tasks.

Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://lore.kernel.org/r/20241223043407.1611-7-kprateek.nayak@amd.com
  • Loading branch information
K Prateek Nayak authored and Peter Zijlstra committed Jan 13, 2025
1 parent e1bc026 commit 0ac1ee9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions kernel/sched/fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -10409,7 +10409,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,
bool *sg_overloaded,
bool *sg_overutilized)
{
int i, nr_running, local_group;
int i, nr_running, local_group, sd_flags = env->sd->flags;

memset(sgs, 0, sizeof(*sgs));

Expand All @@ -10433,10 +10433,6 @@ static inline void update_sg_lb_stats(struct lb_env *env,
if (cpu_overutilized(i))
*sg_overutilized = 1;

#ifdef CONFIG_NUMA_BALANCING
sgs->nr_numa_running += rq->nr_numa_running;
sgs->nr_preferred_running += rq->nr_preferred_running;
#endif
/*
* No need to call idle_cpu() if nr_running is not 0
*/
Expand All @@ -10446,10 +10442,17 @@ static inline void update_sg_lb_stats(struct lb_env *env,
continue;
}

#ifdef CONFIG_NUMA_BALANCING
/* Only fbq_classify_group() uses this to classify NUMA groups */
if (sd_flags & SD_NUMA) {
sgs->nr_numa_running += rq->nr_numa_running;
sgs->nr_preferred_running += rq->nr_preferred_running;
}
#endif
if (local_group)
continue;

if (env->sd->flags & SD_ASYM_CPUCAPACITY) {
if (sd_flags & SD_ASYM_CPUCAPACITY) {
/* Check for a misfit task on the cpu */
if (sgs->group_misfit_task_load < rq->misfit_task_load) {
sgs->group_misfit_task_load = rq->misfit_task_load;
Expand Down

0 comments on commit 0ac1ee9

Please sign in to comment.