Skip to content

Commit 3dcbf5e

Browse files
Brendan Jackmanpundiramit
authored andcommitted
sched/core: Warn if ENERGY_AWARE is enabled but data is missing
If the EAS energy model is missing or incomplete, i.e. sd_scs is NULL, then sched_group_energy will return -EINVAL on the assumption that it raced with a CPU hotplug event. In that case, energy_diff will return 0 and the energy-aware wake path will silently fail to trigger any migrations. This case can be triggered by disabling CONFIG_SCHED_MC on existing platforms, so that there are no sched_groups with the SD_SHARE_CAP_STATES flag, so that sd_scs is NULL. Add checks so that a warning is printed if EAS is ever enabled while the necessary data is not present. Change-Id: Id233a510b5ad8b7fcecac0b1d789e730bbfc7c4a Signed-off-by: Brendan Jackman <brendan.jackman@arm.com>
1 parent 43c509a commit 3dcbf5e

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

kernel/sched/core.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
#include <trace/events/sched.h>
9292
#include "walt.h"
9393

94+
static bool have_sched_energy_data(void);
95+
9496
DEFINE_MUTEX(sched_domains_mutex);
9597
DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
9698

@@ -193,6 +195,10 @@ static int sched_feat_set(char *cmp)
193195
sysctl_sched_features &= ~(1UL << i);
194196
sched_feat_disable(i);
195197
} else {
198+
if (i == __SCHED_FEAT_ENERGY_AWARE)
199+
WARN(!have_sched_energy_data(),
200+
"Missing sched energy data\n");
201+
196202
sysctl_sched_features |= (1UL << i);
197203
sched_feat_enable(i);
198204
}
@@ -6649,6 +6655,19 @@ static void init_sched_groups_capacity(int cpu, struct sched_domain *sd)
66496655
atomic_set(&sg->sgc->nr_busy_cpus, sg->group_weight);
66506656
}
66516657

6658+
static bool have_sched_energy_data(void)
6659+
{
6660+
int cpu;
6661+
6662+
for_each_possible_cpu(cpu) {
6663+
if (!rcu_dereference(per_cpu(sd_scs, cpu)) ||
6664+
!rcu_dereference(per_cpu(sd_ea, cpu)))
6665+
return false;
6666+
}
6667+
6668+
return true;
6669+
}
6670+
66526671
/*
66536672
* Check that the per-cpu provided sd energy data is consistent for all cpus
66546673
* within the mask.
@@ -7461,6 +7480,9 @@ static int build_sched_domains(const struct cpumask *cpu_map,
74617480
}
74627481
rcu_read_unlock();
74637482

7483+
WARN(sched_feat(ENERGY_AWARE) && !have_sched_energy_data(),
7484+
"Missing data for energy aware scheduling\n");
7485+
74647486
ret = 0;
74657487
error:
74667488
__free_domain_allocs(&d, alloc_state, cpu_map);

0 commit comments

Comments
 (0)