[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210625152603.25960-2-lukasz.luba@arm.com>
Date: Fri, 25 Jun 2021 16:26:01 +0100
From: Lukasz Luba <lukasz.luba@....com>
To: linux-kernel@...r.kernel.org
Cc: Chris.Redpath@....com, lukasz.luba@....com,
dietmar.eggemann@....com, morten.rasmussen@....com,
qperret@...gle.com, linux-pm@...r.kernel.org, peterz@...radead.org,
rjw@...ysocki.net, viresh.kumar@...aro.org,
vincent.guittot@...aro.org, mingo@...hat.com,
juri.lelli@...hat.com, rostedt@...dmis.org, segall@...gle.com,
mgorman@...e.de, bristot@...hat.com, CCj.Yeh@...iatek.com
Subject: [PATCH 1/3] sched/fair: Prepare variables for increased precision of EAS estimated energy
The Energy Aware Scheduler (EAS) tries to find best CPU for a waking up
task. It probes many possibilities and compares the estimated energy values
for different scenarios. For calculating those energy values it relies on
Energy Model (EM) data and em_cpu_energy(). The precision which is used in
EM data is in milli-Watts (or abstract scale), which sometimes is not
sufficient. In some cases it might happen that two CPUs from different
Performance Domains (PDs) get the same calculated value for a given task
placement, but in more precised scale, they might differ. This rounding
error has to be addressed. This patch prepares EAS code for better
precision in the coming EM improvements.
Signed-off-by: Lukasz Luba <lukasz.luba@....com>
---
kernel/sched/fair.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 7b8990fd4896..b517c9e79768 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6582,7 +6582,7 @@ static unsigned long cpu_util_next(int cpu, struct task_struct *p, int dst_cpu)
* to compute what would be the energy if we decided to actually migrate that
* task.
*/
-static long
+static u64
compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)
{
struct cpumask *pd_mask = perf_domain_span(pd);
@@ -6689,12 +6689,13 @@ compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)
*/
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;
+ u64 prev_delta = ULLONG_MAX, best_delta = ULLONG_MAX;
int cpu, best_energy_cpu = prev_cpu, target = -1;
- unsigned long cpu_cap, util, base_energy = 0;
+ unsigned long cpu_cap, util;
struct sched_domain *sd;
struct perf_domain *pd;
+ u64 base_energy = 0;
rcu_read_lock();
pd = rcu_dereference(rd->pd);
@@ -6718,9 +6719,9 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
goto unlock;
for (; pd; pd = pd->next) {
- unsigned long cur_delta, spare_cap, max_spare_cap = 0;
+ unsigned long spare_cap, max_spare_cap = 0;
bool compute_prev_delta = false;
- unsigned long base_energy_pd;
+ u64 base_energy_pd, cur_delta;
int max_spare_cap_cpu = -1;
for_each_cpu_and(cpu, perf_domain_span(pd), sched_domain_span(sd)) {
@@ -6790,7 +6791,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
* Pick the best CPU if prev_cpu cannot be used, or if it saves at
* least 6% of the energy used by prev_cpu.
*/
- if ((prev_delta == ULONG_MAX) ||
+ if ((prev_delta == ULLONG_MAX) ||
(prev_delta - best_delta) > ((prev_delta + base_energy) >> 4))
target = best_energy_cpu;
--
2.17.1
Powered by blists - more mailing lists