Skip to content

Commit c6377a1

Browse files
kudureranganatharighi
authored andcommitted
NVIDIA: SAUCE: sched/fair: Add SIS_UTIL support to select_idle_capacity()
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> (cherry picked from https://lore.kernel.org/all/20260428051720.3180182-1-arighi@nvidia.com) Signed-off-by: Andrea Righi <arighi@nvidia.com>
1 parent f2269e2 commit c6377a1

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

kernel/sched/fair.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7644,6 +7644,7 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
76447644
int fits, best_fits = ASYM_IDLE_COMPLETE_MISFIT;
76457645
int cpu, best_cpu = -1;
76467646
struct cpumask *cpus;
7647+
int nr = INT_MAX;
76477648

76487649
cpus = this_cpu_cpumask_var_ptr(select_rq_mask);
76497650
cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr);
@@ -7652,10 +7653,29 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
76527653
util_min = uclamp_eff_value(p, UCLAMP_MIN);
76537654
util_max = uclamp_eff_value(p, UCLAMP_MAX);
76547655

7656+
if (sched_feat(SIS_UTIL) && sd->shared) {
7657+
/*
7658+
* Same nr_idle_scan hint as select_idle_cpu(), nr only limits
7659+
* the scan when not preferring an idle core.
7660+
*/
7661+
nr = READ_ONCE(sd->shared->nr_idle_scan) + 1;
7662+
/* overloaded domain is unlikely to have idle cpu/core */
7663+
if (nr == 1)
7664+
return -1;
7665+
}
7666+
76557667
for_each_cpu_wrap(cpu, cpus, target) {
76567668
bool preferred_core = !prefers_idle_core || is_core_idle(cpu);
76577669
unsigned long cpu_cap = capacity_of(cpu);
76587670

7671+
/*
7672+
* Good-enough early exit (mirrors select_idle_cpu() without
7673+
* has_idle_core).
7674+
*/
7675+
if (!prefers_idle_core &&
7676+
--nr <= 0 && best_fits == ASYM_IDLE_CORE_UCLAMP_MISFIT)
7677+
return best_cpu;
7678+
76597679
if (!available_idle_cpu(cpu) && !sched_idle_cpu(cpu))
76607680
continue;
76617681

0 commit comments

Comments
 (0)