Re: [PATCH 5/6] sched/fair: Consider the idle state of the whole core for load balance

From: Peter Zijlstra
Date: Fri May 05 2023 - 09:24:48 EST


On Thu, May 04, 2023 at 09:09:55AM -0700, Tim Chen wrote:

> @@ -10709,11 +10709,26 @@ static int should_we_balance(struct lb_env *env)
> for_each_cpu_and(cpu, group_balance_mask(sg), env->cpus) {
> if (!idle_cpu(cpu))
> continue;
> + else {
> + /*
> + * Don't balance to idle SMT in busy core right away when
> + * balancing cores, but remember the first idle SMT CPU for
> + * later consideration. Find CPU on an idle core first.
> + */
> + if (!(env->sd->flags & SD_SHARE_CPUCAPACITY) && !is_core_idle(cpu)) {
> + if (idle_smt == -1)
> + idle_smt = cpu;
> + continue;
> + }
> + }

Not only does that bust CodingStyle, it's also entirely daft. What
exactly is the purpose of that else statement?

>
> /* Are we the first idle CPU? */
> return cpu == env->dst_cpu;
> }