Re: [PATCH 10/19] sched/fair: Prioritize tasks preferring destination LLC during balancing
From: K Prateek Nayak
Date: Mon Oct 27 2025 - 02:30:07 EST
Hello Tim,
On 10/11/2025 11:54 PM, Tim Chen wrote:
> +/*
> + * Do LLC balance on sched group that contains LLC, and have tasks preferring
> + * to run on LLC in idle dst_cpu.
> + */
> +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))
nit. You can just check group->flags here.
> + return false;
> +
> + llc = llc_idx(env->dst_cpu);
> + if (sgs->nr_pref_llc[llc] > 0 &&
> + can_migrate_llc(env->src_cpu, env->dst_cpu, 0, true) == mig_llc)
> + return true;
> +
> + return false;
> +}
> #else
> static inline void record_sg_llc_stats(struct lb_env *env, struct sg_lb_stats *sgs,
> struct sched_group *group)
> {
> }
> +
> +static inline bool llc_balance(struct lb_env *env, struct sg_lb_stats *sgs,
> + struct sched_group *group)
> +{
> + return false;
> +}
> #endif
>
> /**
> @@ -10954,6 +10988,11 @@ static inline void update_sg_lb_stats(struct lb_env *env,
> sgs->group_type = group_classify(env->sd->imbalance_pct, group, sgs);
>
> record_sg_llc_stats(env, sgs, group);
Okay, I see the intention of recording this based on group stats.
Sorry for the noise on Patch 2.
> +
> + /* Check for tasks in this group can be moved to their preferred LLC */
> + if (!local_group && llc_balance(env, sgs, group))
> + sgs->group_llc_balance = 1;
> +
> /* Computing avg_load makes sense only when group is overloaded */
> if (sgs->group_type == group_overloaded)
> sgs->avg_load = (sgs->group_load * SCHED_CAPACITY_SCALE) /
--
Thanks and Regards,
Prateek