Re: [PATCH 8/8] sched/eevdf: Add min slice check when selecting CPU
From: Vincent Guittot
Date: Fri Oct 02 2026 - 11:49:49 EST
On Thu, 1 Oct 2026 at 17:15, Christian Loehle <christian.loehle@xxxxxxx> wrote:
>
> 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?
We don't take any lock so can't use current->vprot or current->vruntime directly
I have merged select_slice_cpu() in select_idle_capacity and
select_idle_cpu() in the next version that I just sent
>
> 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.