Skip to content

Commit 6f6d76d

Browse files
kudureranganatharighi
authored andcommitted
NVIDIA: SAUCE: sched/fair: Add SIS_UTIL support to select_idle_capacity()
BugLink: https://bugs.launchpad.net/bugs/2150671 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 4b5ade8 commit 6f6d76d

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

kernel/sched/fair.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7791,6 +7791,7 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
77917791
int fits, best_fits = ASYM_IDLE_COMPLETE_MISFIT;
77927792
int cpu, best_cpu = -1;
77937793
struct cpumask *cpus;
7794+
int nr = INT_MAX;
77947795

77957796
cpus = this_cpu_cpumask_var_ptr(select_rq_mask);
77967797
cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr);
@@ -7799,10 +7800,28 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
77997800
util_min = uclamp_eff_value(p, UCLAMP_MIN);
78007801
util_max = uclamp_eff_value(p, UCLAMP_MAX);
78017802

7803+
if (sched_feat(SIS_UTIL) && sd->shared) {
7804+
/*
7805+
* Same nr_idle_scan hint as select_idle_cpu(), nr only limits
7806+
* the scan when not preferring an idle core.
7807+
*/
7808+
nr = READ_ONCE(sd->shared->nr_idle_scan) + 1;
7809+
/* overloaded domain is unlikely to have idle cpu/core */
7810+
if (nr == 1)
7811+
return -1;
7812+
}
7813+
78027814
for_each_cpu_wrap(cpu, cpus, target) {
78037815
bool preferred_core = !prefers_idle_core || is_core_idle(cpu);
78047816
unsigned long cpu_cap = capacity_of(cpu);
78057817

7818+
/*
7819+
* Good-enough early exit (mirrors select_idle_cpu() logic).
7820+
*/
7821+
if (!prefers_idle_core &&
7822+
--nr <= 0 && best_fits == ASYM_IDLE_CORE_UCLAMP_MISFIT)
7823+
return best_cpu;
7824+
78067825
if (!available_idle_cpu(cpu) && !sched_idle_cpu(cpu))
78077826
continue;
78087827

0 commit comments

Comments
 (0)