aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Bellasi <patrick.bellasi@arm.com>2015-06-23 09:16:43 +0100
committerJuri Lelli <juri.lelli@arm.com>2015-10-05 12:11:50 +0100
commitf92f7bf608e1ca7c84a06d178415394a4c887223 (patch)
tree871cf3a68f667d770d7b0e8c601a8dddda18e16d
parent8eb0fa991c6bc230e6e5362ccd8d7f76b4d35cd3 (diff)
downloadlinux-linaro-stable-f92f7bf608e1ca7c84a06d178415394a4c887223.tar.gz
WIP: sched/tune: add performance-energy space filtering function
Boosting the utilisation of a task could imply the selection of a CPU/OPP and cluster which has an higher energy impact. In that conditions the energy_diff() function will discard the scheduling proposal under evaluation thus impacting the possibility to boost the performances of a task. A trade-off between increased energy consumption and performances benefits should be evaluated. This patch introduces the required support to evaluate the "energy payoff" corresponding to a certain variation on expected task performances. A proposed schedule candidate is described in term of expected variation of energy and performance. These values are used to verify in which region of the Performance-Energy Space the solution becomes and thus returns an energy_payoff metrics which is positive if - the increased energy is compensated by a configured performance gain i.e. either in Optimal (O) or Performance Boost (B) region - the decreased energy is compliant with a configured performance constraint i.e. in Performance Constraint (C) region Otherwise the returned energy_payoff will be negative, i.e. not in the above cases or in the Suboptimal (S) region. The classification of a schedule decision in one of the four regions is defined also by a couple of thresholds in the Performance-Energy variation Space, which allows to identify two main optimization subregions: - Performance Boost (B) region top right quadrant: both nrg and cap expected variations are positive - Performance Constraining (C) region bottom-left quadrant: both nrg and cap expected variations are negative This implementation binds both the thresholds values to the single value of the boost margin, thus allowing to use a single boost knob to configure all the thresholds. Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com> Conflicts: kernel/sched/tune.c Change-Id: I1e77b49135c041c18e80de2090069e0aab0ec4ad
-rw-r--r--kernel/sched/tune.c93
-rw-r--r--kernel/sched/tune.h2
2 files changed, 95 insertions, 0 deletions
diff --git a/kernel/sched/tune.c b/kernel/sched/tune.c
index 8a3e34c707fc..3b49270d5de8 100644
--- a/kernel/sched/tune.c
+++ b/kernel/sched/tune.c
@@ -1,8 +1,41 @@
+#include <linux/kernel.h>
+
#include "sched.h"
#include "tune.h"
unsigned int sysctl_sched_cfs_boost __read_mostly = 0;
+/* Performance Boost region (B) threshold params */
+static int perf_boost_idx;
+
+/* Performance Constraint region (C) threshold params */
+static int perf_constrain_idx;
+
+/**
+ * Performance-Energy (P-E) Space thresholds constants
+ */
+struct threshold_params {
+ int nrg_gain;
+ int cap_gain;
+};
+
+/*
+ * System specific P-E space thresholds constants
+ */
+static struct threshold_params
+threshold_gains[] = {
+ { 0, 4 }, /* >= 0% */
+ { 1, 4 }, /* >= 10% */
+ { 2, 4 }, /* >= 20% */
+ { 3, 4 }, /* >= 30% */
+ { 4, 4 }, /* >= 40% */
+ { 4, 3 }, /* >= 50% */
+ { 4, 2 }, /* >= 60% */
+ { 4, 1 }, /* >= 70% */
+ { 4, 0 }, /* >= 80% */
+ { 4, 0 } /* >= 90% */
+};
+
/*
* System energy normalization constants
*/
@@ -81,6 +114,57 @@ schedtune_normalize_energy(int energy_diff)
return normalized_nrg;
}
+static int
+__schedtune_accept_deltas(int nrg_delta, int cap_delta,
+ int perf_boost_idx, int perf_constrain_idx) {
+ int energy_payoff;
+
+ /* Performance Boost (B) region */
+ if (nrg_delta > 0 && cap_delta > 0) {
+ /*
+ * energy_payoff criteria:
+ * cap_delta / nrg_delta > cap_gain / nrg_gain
+ * which is:
+ * nrg_delta * cap_gain < cap_delta * nrg_gain
+ */
+ energy_payoff = cap_delta * threshold_gains[perf_boost_idx].nrg_gain;
+ energy_payoff -= nrg_delta * threshold_gains[perf_boost_idx].cap_gain;
+ return energy_payoff;
+ }
+
+ /* Performance Constraint (C) region */
+ if (nrg_delta < 0 && cap_delta < 0) {
+ /*
+ * energy_payoff criteria:
+ * cap_delta / nrg_delta < cap_gain / nrg_gain
+ * which is:
+ * nrg_delta * cap_gain > cap_delta * nrg_gain
+ */
+ energy_payoff = nrg_delta * threshold_gains[perf_constrain_idx].cap_gain;
+ energy_payoff -= cap_delta * threshold_gains[perf_constrain_idx].nrg_gain;
+ return energy_payoff;
+ }
+
+ /* Default: reject schedule candidate */
+ return -INT_MAX;
+}
+
+int
+schedtune_accept_deltas(int nrg_delta, int cap_delta) {
+
+ /* Optimal (O) region */
+ if (nrg_delta < 0 && cap_delta > 0)
+ return INT_MAX;
+
+ /* Suboptimal (S) region */
+ if (nrg_delta > 0 && cap_delta < 0)
+ return -INT_MAX;
+
+ return __schedtune_accept_deltas(nrg_delta, cap_delta,
+ perf_boost_idx, perf_constrain_idx);
+
+}
+
int
sysctl_sched_cfs_boost_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
@@ -90,5 +174,14 @@ sysctl_sched_cfs_boost_handler(struct ctl_table *table, int write,
if (ret || !write)
return ret;
+ /* Performance Boost (B) region threshold params */
+ perf_boost_idx = sysctl_sched_cfs_boost;
+ perf_boost_idx /= 10;
+
+ /* Performance Constraint (C) region threshold params */
+ perf_constrain_idx = 100 - sysctl_sched_cfs_boost;
+ perf_constrain_idx /= 10;
+
return 0;
}
+
diff --git a/kernel/sched/tune.h b/kernel/sched/tune.h
index 37e877276dfc..c525176f2a95 100644
--- a/kernel/sched/tune.h
+++ b/kernel/sched/tune.h
@@ -2,9 +2,11 @@
#ifdef CONFIG_SCHED_TUNE
extern int schedtune_normalize_energy(int energy);
+extern int schedtune_accept_deltas(int nrg_delta, int cap_delta);
#else /* CONFIG_SCHED_TUNE */
#define schedtune_normalize_energy(energy) energy
+#define schedtune_accept_deltas(nrg_delta, cap_delta) nrg_delta
#endif /* CONFIG_SCHED_TUNE */