In find_energy_effecient_cpu(), if we set a task min util clamp to 1024,
all cpus will be skipped because of !fit_capcity() condition.
And the return value will always be prev_cpu (best_energy_cpu initial value).
For this case is it better to find max spare capcity CPU in the whole system?
ex.
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index da3e5b54715b..7e431195753e 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6536,6 +6536,8 @@ static int find_energy_efficient_cpu(struct
task_struct *p, int prev_cpu)
unsigned long prev_delta = ULONG_MAX, best_delta = ULONG_MAX;
struct root_domain *rd = cpu_rq(smp_processor_id())->rd;
unsigned long cpu_cap, util, base_energy = 0;
+ unsigned long sys_max_spare_cap = 0;
+ int sys_max_spare_cap_cpu = prev_cpu;
int cpu, best_energy_cpu = prev_cpu;
struct sched_domain *sd;
struct perf_domain *pd;
@@ -6576,6 +6578,14 @@ static int find_energy_efficient_cpu(struct
task_struct *p, int prev_cpu)
cpu_cap = capacity_of(cpu);
spare_cap = cpu_cap - util;
+ /*
+ * Find the CPU with the maximum spare capacity in
+ * the performance domain
+ */
+ if (spare_cap > sys_max_spare_cap) {
+ sys_max_spare_cap = spare_cap;
+ sys_max_spare_cap_cpu = cpu;
+ }
/*
* Skip CPUs that cannot satisfy the capacity request.
* IOW, placing the task there would make the CPU
@@ -6622,7 +6632,7 @@ static int find_energy_efficient_cpu(struct
task_struct *p, int prev_cpu)
* least 6% of the energy used by prev_cpu.
*/
if (prev_delta == ULONG_MAX)
- return best_energy_cpu;
+ return sys_max_spare_cap_cpu;
if ((prev_delta - best_delta) > ((prev_delta + base_energy) >> 4))
return best_energy_cpu;
Best Regards,
Yun