return (util >= capacity) ? capacity : util;
}
+struct energy_table {
+ struct capacity_state *states;
+ unsigned int nr_states;
+};
+
+DEFINE_PER_CPU(struct energy_table, energy_table);
+
struct eco_env {
struct task_struct *p;
int backup_cpu = -1;
int cpu;
+ /*
+ * It is meaningless to find an energy cpu when the energy table is
+ * not created or has not been created yet.
+ */
+ if (!per_cpu(energy_table, eenv->prev_cpu).nr_states)
+ return;
+
rcu_read_lock();
for_each_cpu_and(cpu, &p->cpus_allowed, cpu_active_mask) {
eenv->backup_cpu = backup_cpu;
}
-struct energy_table {
- struct capacity_state *states;
- unsigned int nr_states;
-};
-
-DEFINE_PER_CPU(struct energy_table, energy_table);
-
static unsigned int calculate_energy(struct task_struct *p, int target_cpu)
{
unsigned long util[NR_CPUS] = {0, };
struct eco_env eenv = {
.p = p,
.prev_cpu = prev_cpu,
+ .best_cpu = -1,
+ .backup_cpu = -1,
};
if (!sched_feat(ENERGY_AWARE))