Skip to content

Commit a0fe2cf

Browse files
Valentin SchneiderIngo Molnar
authored andcommitted
sched/fair: Tune down misfit NOHZ kicks
In this commit: 3b1baa6 ("sched/fair: Add 'group_misfit_task' load-balance type") we set rq->misfit_task_load whenever the current running task has a utilization greater than 80% of rq->cpu_capacity. A non-zero value in this field enables misfit load balancing. However, if the task being looked at is already running on a CPU of highest capacity, there's nothing more we can do for it. We can currently spot this in update_sd_pick_busiest(), which prevents us from selecting a sched_group of group_type == group_misfit_task as the busiest group, but we don't do any of that in nohz_balancer_kick(). This means that we could repeatedly kick NOHZ CPUs when there's no improvements in terms of load balance to be done. Introduce a check_misfit_status() helper that returns true iff there is a CPU in the system that could give more CPU capacity to a rq's misfit task - IOW, there exists a CPU of higher capacity_orig or the rq's CPU is severely pressured by rt/IRQ. Signed-off-by: Valentin Schneider <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: [email protected] Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent e25a7a9 commit a0fe2cf

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

kernel/sched/fair.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8058,6 +8058,18 @@ check_cpu_capacity(struct rq *rq, struct sched_domain *sd)
80588058
(rq->cpu_capacity_orig * 100));
80598059
}
80608060

8061+
/*
8062+
* Check whether a rq has a misfit task and if it looks like we can actually
8063+
* help that task: we can migrate the task to a CPU of higher capacity, or
8064+
* the task's current CPU is heavily pressured.
8065+
*/
8066+
static inline int check_misfit_status(struct rq *rq, struct sched_domain *sd)
8067+
{
8068+
return rq->misfit_task_load &&
8069+
(rq->cpu_capacity_orig < rq->rd->max_cpu_capacity ||
8070+
check_cpu_capacity(rq, sd));
8071+
}
8072+
80618073
/*
80628074
* Group imbalance indicates (and tries to solve) the problem where balancing
80638075
* groups is inadequate due to ->cpus_allowed constraints.
@@ -9585,7 +9597,7 @@ static void nohz_balancer_kick(struct rq *rq)
95859597
if (time_before(now, nohz.next_balance))
95869598
goto out;
95879599

9588-
if (rq->nr_running >= 2 || rq->misfit_task_load) {
9600+
if (rq->nr_running >= 2) {
95899601
flags = NOHZ_KICK_MASK;
95909602
goto out;
95919603
}
@@ -9623,6 +9635,18 @@ static void nohz_balancer_kick(struct rq *rq)
96239635
}
96249636
}
96259637

9638+
sd = rcu_dereference(per_cpu(sd_asym_cpucapacity, cpu));
9639+
if (sd) {
9640+
/*
9641+
* When ASYM_CPUCAPACITY; see if there's a higher capacity CPU
9642+
* to run the misfit task on.
9643+
*/
9644+
if (check_misfit_status(rq, sd)) {
9645+
flags = NOHZ_KICK_MASK;
9646+
goto unlock;
9647+
}
9648+
}
9649+
96269650
sd = rcu_dereference(per_cpu(sd_asym_packing, cpu));
96279651
if (sd) {
96289652
/*

0 commit comments

Comments
 (0)