Hi,
On 05/03/18 10:27, Viresh Kumar wrote:
From: Leo Yan leo.yan@linaro.org
The homescreen test-case shows unwanted disturbance on the big CPUs on the Hikey620 platform with Android 4.9. There are multiple reasons for that though.
I think you mean Hikey960 here, as Hikey620 has only cores with the same micro-architecture. Are you able to share the test setup and results? I was under the impression that in the current configuration, all boosted tasks are also prefer_idle, so I would not expect any disturbance in that case. I might be wrong, but I'm curious if you had to change the schedtune configuration in order to observe an issue.
By default boost and prefer_idle are enabled for both top-app and foreground tasks and find_best_target() always (intentionally) prefers the big CPUs if prefer_idle is enabled. And some of the foreground tasks (like: DispSync, PowerManagerSer and PhotonicModulat) for the homescreen test-case get placed on the big CPUs eventually because of that.
Even if prefer_idle is disabled for such foreground tasks, they don't end up on the little CPUs. The reason being that find_best_target() still prefers big CPUs if the task is boosted, though some of the comments in find_best_target() routine say the exact opposite of that. It eventually depends on the order in which CPUs are processed, which is from big to little for boosted tasks.
I was looking into the same issue and wondering if this logic should not be applied for both non-latency sensitive scenarios: selection of backup idle CPU (as you've done here) and selection of active CPU, where we would select the lowest capacity one, despite it not having the highest spare. But, I think the scenario involving choosing an active CPU is more complicated as we might want to spread tasks when boosted, rather then pack them.
But this is a more simple case and it would benefit from a wider audience on android gerrit, especially in light of other changes that are considered for find_best_target: https://android-review.googlesource.com/q/strf
Ionela.
This patch updates the find_best_target() routine to select low capacity idle-CPU if the task is boosted but doesn't have prefer_idle enabled. This would be the same for non-boosted tasks as well.
Signed-off-by: Leo Yan leo.yan@linaro.org Signed-off-by: Viresh Kumar viresh.kumar@linaro.org
kernel/sched/fair.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e45047bdd245..4534d8620989 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6998,8 +6998,11 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu, int idle_idx = idle_get_state_idx(cpu_rq(i));
/* Select idle CPU with lower cap_orig */
if (capacity_orig > best_idle_min_cap_orig)
if (capacity_orig < best_idle_min_cap_orig)
goto found_best_idle_cpu;
else if (capacity_orig > best_idle_min_cap_orig) continue;
/* Favor CPUs that won't end up running at a * high OPP. */
@@ -7017,6 +7020,7 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu, best_idle_cstate <= idle_idx) continue;
+found_best_idle_cpu: /* Keep track of best idle CPU */ best_idle_min_cap_orig = capacity_orig; target_idle_max_spare_cap = capacity_orig -