Skip to content

Commit 9e9af81

Browse files
vingu-linaroPeter Zijlstra
authored andcommitted
sched/fair: Account update_blocked_averages in newidle_balance cost
The time spent to update the blocked load can be significant depending of the complexity fo the cgroup hierarchy. Take this time into account in the cost of the 1st load balance of a newly idle cpu. Also reduce the number of call to sched_clock_cpu() and track more actual work. Signed-off-by: Vincent Guittot <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Dietmar Eggemann <[email protected]> Acked-by: Mel Gorman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5d1ceb3 commit 9e9af81

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

kernel/sched/fair.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10840,9 +10840,9 @@ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf)
1084010840
{
1084110841
unsigned long next_balance = jiffies + HZ;
1084210842
int this_cpu = this_rq->cpu;
10843+
u64 t0, t1, curr_cost = 0;
1084310844
struct sched_domain *sd;
1084410845
int pulled_task = 0;
10845-
u64 curr_cost = 0;
1084610846

1084710847
update_misfit_status(NULL, this_rq);
1084810848

@@ -10887,29 +10887,32 @@ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf)
1088710887

1088810888
raw_spin_rq_unlock(this_rq);
1088910889

10890+
t0 = sched_clock_cpu(this_cpu);
1089010891
update_blocked_averages(this_cpu);
10892+
1089110893
rcu_read_lock();
1089210894
for_each_domain(this_cpu, sd) {
1089310895
int continue_balancing = 1;
10894-
u64 t0, domain_cost;
10896+
u64 domain_cost;
1089510897

1089610898
if (this_rq->avg_idle < curr_cost + sd->max_newidle_lb_cost) {
1089710899
update_next_balance(sd, &next_balance);
1089810900
break;
1089910901
}
1090010902

1090110903
if (sd->flags & SD_BALANCE_NEWIDLE) {
10902-
t0 = sched_clock_cpu(this_cpu);
1090310904

1090410905
pulled_task = load_balance(this_cpu, this_rq,
1090510906
sd, CPU_NEWLY_IDLE,
1090610907
&continue_balancing);
1090710908

10908-
domain_cost = sched_clock_cpu(this_cpu) - t0;
10909+
t1 = sched_clock_cpu(this_cpu);
10910+
domain_cost = t1 - t0;
1090910911
if (domain_cost > sd->max_newidle_lb_cost)
1091010912
sd->max_newidle_lb_cost = domain_cost;
1091110913

1091210914
curr_cost += domain_cost;
10915+
t0 = t1;
1091310916
}
1091410917

1091510918
update_next_balance(sd, &next_balance);

0 commit comments

Comments
 (0)