blob: 95ea3e2085612ba49dd2505e8666e713d1dbe77f [file] [log] [blame]
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Patrick Bellasi <patrick.bellasi@arm.com>
Date: Tue, 18 Dec 2018 10:31:30 +0000
Subject: ANDROID: sched/fair: EAS: Add uclamp support to
find_energy_efficient_cpu()
Utilization clamping can be used to boost the utilization of small tasks
or cap that of big tasks. Thus, one of its possible usages is to bias
tasks placement to "promote" small tasks on higher capacity (less energy
efficient) CPUs or "constraint" big tasks on small capacity (more energy
efficient) CPUs.
When the Energy Aware Scheduler (EAS) looks for the most energy
efficient CPU to run a task on, it currently considers only the
effective utiliation estimated for a task.
Fix this by adding an additional check to skip CPUs which capacity is
smaller then the task clamped utilization.
Change-Id: I43fa6fa27e27c1eb5272c6a45d1a6a5b0faae1aa
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Quentin Perret <quentin.perret@arm.com>
---
kernel/sched/fair.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 69a81a5709ff..e00f6c43a02b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6034,6 +6034,19 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
return target;
}
+static unsigned int uclamp_task_util(struct task_struct *p)
+{
+#ifdef CONFIG_UCLAMP_TASK
+ unsigned int min_util = uclamp_eff_value(p, UCLAMP_MIN);
+ unsigned int max_util = uclamp_eff_value(p, UCLAMP_MAX);
+ unsigned int est_util = task_util_est(p);
+
+ return clamp(est_util, min_util, max_util);
+#else
+ return task_util_est(p);
+#endif
+}
+
/**
* Amount of capacity of a CPU that is (estimated to be) used by CFS tasks
* @cpu: the CPU to get the utilization of
@@ -6378,6 +6391,10 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
if (!fits_capacity(util, cpu_cap))
continue;
+ /* Skip CPUs which do not fit task requirements */
+ if (cpu_cap < uclamp_task_util(p))
+ continue;
+
/* Always use prev_cpu as a candidate. */
if (cpu == prev_cpu) {
prev_delta = compute_energy(p, prev_cpu, pd);