Re: [PATCH 10/19] sched/fair: Prioritize tasks preferring destination LLC during balancing

From: Peter Zijlstra

Date: Wed Oct 15 2025 - 11:10:32 EST


On Sat, Oct 11, 2025 at 11:24:47AM -0700, Tim Chen wrote:

> +static inline bool llc_balance(struct lb_env *env, struct sg_lb_stats *sgs,
> + struct sched_group *group)
> +{
> + struct sched_domain *child = env->sd->child;
> + int llc;
> +
> + if (!sched_cache_enabled())
> + return false;
> +
> + if (env->sd->flags & SD_SHARE_LLC)
> + return false;
> +
> + /* only care about task migration among LLCs */
> + if (child && !(child->flags & SD_SHARE_LLC))
> + return false;
> +
> + llc = llc_idx(env->dst_cpu);
> + if (sgs->nr_pref_llc[llc] > 0 &&

Robot says llc can be -1 here, and it don't like doing out of bound
array access.

> + can_migrate_llc(env->src_cpu, env->dst_cpu, 0, true) == mig_llc)
> + return true;
> +
> + return false;
> +}