On 20-Mar 00:15, Leo Yan wrote:
On Mon, Mar 19, 2018 at 12:24:09PM +0000, Patrick Bellasi wrote:
Hi Leo,
On 17-Mar 20:05, Leo Yan wrote:
Move out energy env cpumask setting from select_energy_cpu_idx() and prepare it ahead. This changes make code more clear, which can prepare energy environment variable before energy calculation.
Change-Id: I9061492177ad8d4830cf8bbdaffdf7860b27e319 Signed-off-by: Leo Yan leo.yan@linaro.org
kernel/sched/fair.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 315c386..37231b8 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5874,15 +5874,6 @@ static inline int select_energy_cpu_idx(struct energy_env *eenv) if (!sd) return EAS_CPU_PRV;
- cpumask_clear(&eenv->cpus_mask);
- for (cpu_idx = EAS_CPU_PRV; cpu_idx < EAS_CPU_CNT; ++cpu_idx) {
int cpu = eenv->cpu[cpu_idx].cpu_id;
The intent to do it here and do it with a loop is because of that EAS_CPU_CNT definition, which should make it clear that potentially we can think about having more then 3 candidate we have not.
That's why also I don't agree that moving this block outside makes the code more clear...
I think we could connect this patch with patch 0006 'sched/fair: Use cpumask to track candidates for energy calculation'; so all cpumask should be initialized in function select_energy_cpu_brute().
We can take this patch as refactoring for 'preparing energy_env context' so we can have two distinguished steps: the first step is preparation eenv context (in func select_energy_cpu_brute()) and second step is energy calculation & comparison (in func select_energy_cpu_idx()).
Right, I appreciate the fine grained splitting in patches... but I agree that some could be better merged to make more clear why a refactoring is eventually needed for.
Thanks, Leo Yan
if (cpu < 0)
continue;
cpumask_set_cpu(cpu, &eenv->cpus_mask);
- }
- sg = sd->groups; do { /* Skip SGs which do not contains a candidate CPU */
@@ -7133,7 +7124,6 @@ static int select_energy_cpu_brute(struct task_struct *p, int prev_cpu, int sync }, };
#ifdef CONFIG_SCHED_WALT if (!walt_disabled && sysctl_sched_use_walt_cpu_util && p->state == TASK_WAKING) @@ -7147,6 +7137,14 @@ static int select_energy_cpu_brute(struct task_struct *p, int prev_cpu, int sync goto unlock; }
cpumask_clear(&eenv.cpus_mask);
if (prev_cpu >= 0)
cpumask_set_cpu(prev_cpu, &eenv.cpus_mask);
if (next_cpu >= 0)
cpumask_set_cpu(next_cpu, &eenv.cpus_mask);
if (backup_cpu >= 0)
cpumask_set_cpu(backup_cpu, &eenv.cpus_mask);
- /* Check if EAS_CPU_NXT is a more energy efficient CPU */ if (select_energy_cpu_idx(&eenv) != EAS_CPU_PRV) { schedstat_inc(p->se.statistics.nr_wakeups_secb_nrg_sav);
-- 1.9.1
-- #include <best/regards.h>
Patrick Bellasi
-- #include <best/regards.h>
Patrick Bellasi