sched/fair: Use the same cpumask per-PD throughout find_energy_efficient_cpu()
authorDietmar Eggemann <dietmar.eggemann@arm.com>
Tue, 21 Jun 2022 09:04:12 +0000 (10:04 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 28 Jun 2022 07:17:47 +0000 (09:17 +0200)
commit9b340131a4bcf6d0a282a2bdcd8ca268a74da709
tree24a580e4e02dd7a00e07247ec187dbd32b9fa7c9
parentec4fc801a02d96180c597238fe87141471b70971
sched/fair: Use the same cpumask per-PD throughout find_energy_efficient_cpu()

The Perf Domain (PD) cpumask (struct em_perf_domain.cpus) stays
invariant after Energy Model creation, i.e. it is not updated after
CPU hotplug operations.

That's why the PD mask is used in conjunction with the cpu_online_mask
(or Sched Domain cpumask). Thereby the cpu_online_mask is fetched
multiple times (in compute_energy()) during a run-queue selection
for a task.

cpu_online_mask may change during this time which can lead to wrong
energy calculations.

To be able to avoid this, use the select_rq_mask per-cpu cpumask to
create a cpumask out of PD cpumask and cpu_online_mask and pass it
through the function calls of the EAS run-queue selection path.

The PD cpumask for max_spare_cap_cpu/compute_prev_delta selection
(find_energy_efficient_cpu()) is now ANDed not only with the SD mask
but also with the cpu_online_mask. This is fine since this cpumask
has to be in syc with the one used for energy computation
(compute_energy()).
An exclusive cpuset setup with at least one asymmetric CPU capacity
island (hence the additional AND with the SD cpumask) is the obvious
exception here.

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Tested-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://lkml.kernel.org/r/20220621090414.433602-6-vdonnefort@google.com
kernel/sched/fair.c