Skip to content

Commit 670075c

Browse files
committed
sched: limit cpu search in select_idle_cpu
Put upper and lower limit on cpu search of select_idle_cpu. The lower limit is amount of cpus in a core while upper limit is twice that. This ensures for any architecture we will usually search beyond a core. The upper limit also helps in keeping the search cost low and constant. Orabug: 28482695 Signed-off-by: subhra mazumdar <[email protected]> Reviewed-by: Rohit Jain <[email protected]>
1 parent c10a263 commit 670075c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

kernel/sched/fair.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5764,7 +5764,7 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t
57645764
u64 avg_cost, avg_idle;
57655765
u64 time, cost;
57665766
s64 delta;
5767-
int cpu, nr = INT_MAX;
5767+
int cpu, limit, floor, nr = INT_MAX;
57685768

57695769
this_sd = rcu_dereference(*this_cpu_ptr(&sd_llc));
57705770
if (!this_sd)
@@ -5782,10 +5782,17 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t
57825782

57835783
if (sched_feat(SIS_PROP)) {
57845784
u64 span_avg = sd->span_weight * avg_idle;
5785-
if (span_avg > 4*avg_cost)
5785+
floor = cpumask_weight(topology_sibling_cpumask(target));
5786+
if (floor < 2)
5787+
floor = 2;
5788+
limit = floor << 1;
5789+
if (span_avg > floor*avg_cost) {
57865790
nr = div_u64(span_avg, avg_cost);
5787-
else
5788-
nr = 4;
5791+
if (nr > limit)
5792+
nr = limit;
5793+
} else {
5794+
nr = floor;
5795+
}
57895796
}
57905797

57915798
time = local_clock();

0 commit comments

Comments
 (0)