lkml.org 
[lkml]   [2019]   [Dec]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 4/4] sched/fair: Make feec() consider uclamp restrictions
Date
We've just made task_fits_capacity() uclamp-aware, and
find_energy_efficient_cpu() needs to go through the same treatment.
Things are somewhat different here however - we can't directly use
the now uclamp-aware task_fits_capacity(). Consider the following setup:

rq.cpu_capacity_orig = 512
rq.util_avg = 200
rq.uclamp.max = 768

p.util_est = 600
p.uclamp.max = 256

(p not yet enqueued on rq)

Using task_fits_capacity() here would tell us that p fits on the above CPU.
However, enqueuing p on that CPU *will* cause it to become overutilized
since rq clamp values are max-aggregated, so we'd remain with

rq.uclamp.max = 768

Thus we could reach a high enough frequency to reach beyond 0.8 * 512
utilization (== overutilized). What feec() needs here is
uclamp_rq_util_with() which lets us peek at the future utilization
landscape, including rq-wide uclamp values.

Make find_energy_efficient_cpu() use uclamp_rq_util_with() for its
fits_capacity() check. This is in line with what compute_energy() ends up
using for estimating utilization.

Suggested-by: Quentin Perret <qperret@google.com>
Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
---
kernel/sched/fair.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index dc3e86cb2b2e..cc659a3944f1 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6284,9 +6284,18 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
if (!cpumask_test_cpu(cpu, p->cpus_ptr))
continue;

- /* Skip CPUs that will be overutilized. */
util = cpu_util_next(cpu, p, cpu);
cpu_cap = capacity_of(cpu);
+ spare_cap = cpu_cap - util;
+
+ /*
+ * Skip CPUs that cannot satisfy the capacity request.
+ * IOW, placing the task there would make the CPU
+ * overutilized. Take uclamp into account to see how
+ * much capacity we can get out of the CPU; this is
+ * aligned with schedutil_cpu_util().
+ */
+ util = uclamp_rq_util_with(cpu_rq(cpu), util, p);
if (!fits_capacity(util, cpu_cap))
continue;

@@ -6301,7 +6310,6 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
* Find the CPU with the maximum spare capacity in
* the performance domain
*/
- spare_cap = cpu_cap - util;
if (spare_cap > max_spare_cap) {
max_spare_cap = spare_cap;
max_spare_cap_cpu = cpu;
--
2.24.0
\
 
 \ /
  Last update: 2019-12-03 17:02    [W:0.037 / U:9.552 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site