Re: [PATCH 15/19] sched/fair: Respect LLC preference in task migration and detach
From: K Prateek Nayak
Date: Tue Oct 28 2025 - 02:03:40 EST
Hello Tim,
On 10/11/2025 11:54 PM, Tim Chen wrote:
> @@ -9969,6 +9969,12 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
> if (env->flags & LBF_ACTIVE_LB)
> return 1;
>
> +#ifdef CONFIG_SCHED_CACHE
> + if (sched_cache_enabled() &&
> + can_migrate_llc_task(env->src_cpu, env->dst_cpu, p) == mig_forbid)
> + return 0;
> +#endif
> +
> degrades = migrate_degrades_locality(p, env);
> if (!degrades)
> hot = task_hot(p, env);
Should we care for task_hot() w.r.t. migration cost if a task is being
moved to a preferred LLC?
Also, should we leave out tasks under core scheduling from the llc
aware lb? Even discount them when calculating "mm->nr_running_avg"?
> @@ -10227,6 +10233,20 @@ static int detach_tasks(struct lb_env *env)
> if (env->imbalance <= 0)
> break;
>
> +#ifdef CONFIG_SCHED_CACHE
> + /*
> + * Don't detach more tasks if the remaining tasks want
> + * to stay. We know the remaining tasks all prefer the
> + * current LLC, because after order_tasks_by_llc(), the
> + * tasks that prefer the current LLC are at the tail of
> + * the list. The inhibition of detachment is to avoid too
> + * many tasks being migrated out of the preferred LLC.
> + */
> + if (sched_cache_enabled() && detached && p->preferred_llc != -1 &&
> + llc_id(env->src_cpu) == p->preferred_llc)
> + break;
In all cases? Should we check can_migrate_llc() wrt to util migrated and
then make a call if we should move the preferred LLC tasks or not?
Perhaps disallow it the first time if "nr_balance_failed" is 0 but
subsequent failed attempts should perhaps explore breaking the preferred
llc restriction if there is an imbalance and we are under
"mig_unrestricted" conditions.
> +#endif
> +
> continue;
> next:
> if (p->sched_task_hot)
--
Thanks and Regards,
Prateek