Re: [PATCH 8/8] sched/eevdf: Add min slice check when selecting CPU
From: Christian Loehle
Date: Thu Oct 01 2026 - 11:24:30 EST
On 9/21/26 16:22, Vincent Guittot wrote:
> Add a new level for selecting CPU when select_task_rq_fair() fails to find
> an idle CPU. This last level will compare the slice to select a CPU where
> the task could run 1st.
> This helps a waking task to select a CPU where a longer slice runs
> instead of one where a task with the same or shorter slice already runs.
>
> Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> ---
> kernel/sched/fair.c | 63 ++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 62 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 452da94289fe..5c9add3e853c 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9023,6 +9023,59 @@ static inline bool asym_fits_cpu(unsigned long util,
> return true;
> }
>
> +static int select_slice_cpu(struct task_struct *p, struct sched_domain *sd, int target)
> +{
> + unsigned long task_util, util_min, util_max;
> + int cpu, nr = INT_MAX;
> + u64 slice = p->se.slice;
> + struct cpumask *cpus;
> +
> + if (sched_feat(SIS_UTIL) && sd->shared) {
> + /*
> + * Same nr_idle_scan hint as select_idle_cpu(), nr only limits
> + * the scan when not preferring an idle core.
> + */
> + nr = READ_ONCE(sd->shared->nr_idle_scan) + 1;
> + /* overloaded domain is unlikely to have idle cpu/core */
> + if (nr == 1)
> + return -1;
> + }
> +
> + cpus = this_cpu_cpumask_var_ptr(select_rq_mask);
> + cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr);
> +
> + if (sched_asym_cpucap_active()) {
> + task_util = task_util_est(p);
> + util_min = uclamp_eff_value(p, UCLAMP_MIN);
> + util_max = uclamp_eff_value(p, UCLAMP_MAX);
> + }
> +
> + /* Those CPUs have been tested not being idle and fiting */
> + for_each_cpu_wrap(cpu, cpus, target) {
> + /*
> + * Stop when the nr_idle_scan is exhausted (mirrors
> + * select_idle_cpu() logic).
> + */
> + if (--nr <= 0)
> + return -1;
> +
> + if (slice >= get_rq_min_slice(cpu_rq(cpu)))
> + continue;
Maybe even additionally look for the rq with smallest
current->vprot - current->vruntime?
It's an interesting approach, OTOH of course it disincentivizes longer slice
tasks again. I'd be interested what this looks like on a full workload
with different slice lengths.