Messages in this thread |  | | From | Vincent Guittot <> | | Date | Wed, 6 May 2026 14:59:07 +0200 | | Subject | Re: [PATCH 5/5] sched/fair: Add SIS_UTIL support to select_idle_capacity() |
| |
On Tue, 28 Apr 2026 at 16:44, Andrea Righi <arighi@nvidia.com> wrote: > > From: K Prateek Nayak <kprateek.nayak@amd.com> > > Add to select_idle_capacity() the same SIS_UTIL-controlled idle-scan > mechanism, already used by select_idle_cpu(): when sched_feat(SIS_UTIL) > is enabled and the LLC domain has sched_domain_shared data, derive the > per-attempt scan limit from sd->shared->nr_idle_scan. > > That bounds the walk on large LLCs and allows an early return once the > scan limit is reached, if we already picked a sufficiently strong > idle-core candidate (best_fits == ASYM_IDLE_CORE_UCLAMP_MISFIT). > > Co-developed-by: Andrea Righi <arighi@nvidia.com> > Signed-off-by: Andrea Righi <arighi@nvidia.com> > Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com> > --- > kernel/sched/fair.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index a1f4d70f6b3d9..1cde3a9b1e0f5 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -8018,6 +8018,7 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) > int fits, best_fits = ASYM_IDLE_COMPLETE_MISFIT; > int cpu, best_cpu = -1; > struct cpumask *cpus; > + int nr = INT_MAX; > > cpus = this_cpu_cpumask_var_ptr(select_rq_mask); > cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr); > @@ -8026,10 +8027,28 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) > util_min = uclamp_eff_value(p, UCLAMP_MIN); > util_max = uclamp_eff_value(p, UCLAMP_MAX); > > + 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; > + } > + > for_each_cpu_wrap(cpu, cpus, target) { > bool preferred_core = !prefers_idle_core || is_core_idle(cpu); > unsigned long cpu_cap = capacity_of(cpu); > > + /* > + * Good-enough early exit (mirrors select_idle_cpu() logic). > + */ > + if (!prefers_idle_core && > + --nr <= 0 && best_fits == ASYM_IDLE_CORE_UCLAMP_MISFIT)
With SMT, !prefers_idle_core implies that there is no idle core; Is best_fits == ASYM_IDLE_CORE_UCLAMP_MISFIT really expected in such case ?
With !SMT, !prefers_idle_core is always true and we will bail out early as expected
> + return best_cpu; > + > if (!choose_idle_cpu(cpu, p)) > continue; > > -- > 2.54.0 >
|  |