On 07-03-18, 11:13, Patrick Bellasi wrote:
Right, that should work, and I like that it makes clear that we want to miximize the spare capacity within the most energy efficient cluster.
Okay, I am fine with the "goto" reasoning you gave. But I see more problems now. Here is your patch again (with the fix included).
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 1f1a73c8b7c9..9d2780c8c80b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6743,7 +6743,7 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu, unsigned long target_max_spare_cap = 0; unsigned long target_util = ULONG_MAX; unsigned long best_active_util = ULONG_MAX;
- unsigned long target_idle_max_spare_cap = 0;
- unsigned long best_idle_max_spare_cap = 0; int best_idle_cstate = INT_MAX; struct sched_domain *sd; struct sched_group *sg;
@@ -6929,15 +6929,25 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu, */ if (idle_cpu(i)) { int idle_idx = idle_get_state_idx(cpu_rq(i));
int max_spare_cap; /* Select idle CPU with lower cap_orig */ if (capacity_orig > best_idle_min_cap_orig) continue;
/* Favor CPUs that won't end up running at a
/*
* A more energy efficient CPU has been found,
* let's reset the conditions for the
* following min_capped_utilization check
*/
if (capacity_orig < best_idle_min_cap_orig)
best_idle_max_spare_cap = 0;
/*
* Favor CPUs that won't end up running at a * high OPP. */
if ((capacity_orig - min_capped_util) <
target_idle_max_spare_cap)
max_spare_cap = capacity_orig - min_capped_util;
if (max_spare_cap < best_idle_max_spare_cap) continue; /*
@@ -6951,9 +6961,8 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu, continue;
/* Keep track of best idle CPU */
best_idle_max_spare_cap = max_spare_cap; best_idle_min_cap_orig = capacity_orig;
target_idle_max_spare_cap = capacity_orig -
min_capped_util; best_idle_cstate = idle_idx; best_idle_cpu = i; continue;
Because we don't use "goto" and end the loop here, we will reach this part of the code now for an idle CPU (traversing from big to little):
if (sysctl_sched_cstate_aware && best_idle_cstate <= idle_idx) continue;
So if the little CPU is at an idle state >= that of the big CPU, we skip it and that is bad as well :)
-- viresh