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

From: Chen, Yu C

Date: Sun Oct 26 2025 - 22:02:04 EST


Hi Aaron,

On 10/24/2025 5:32 PM, Aaron Lu wrote:
Hi Tim,

On Sat, Oct 11, 2025 at 11:24:47AM -0700, Tim Chen wrote:
@@ -10849,11 +10849,45 @@ static void record_sg_llc_stats(struct lb_env *env,
if (unlikely(READ_ONCE(sd_share->capacity) != sgs->group_capacity))
WRITE_ONCE(sd_share->capacity, sgs->group_capacity);
}
+
+/*
+ * 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))
+ 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)

llc_balance() is called from update_sg_lb_stats() and at that time,
env->src_cpu is not determined yet so should not be used here?


You are right, I think we should check the candidate group's first
CPU rather than the env->src_cpu. Will fix it in the next version.
Thanks a lot!

chenyu
+ return true;
+
+ return false;
+}