sched/tune: fix PB and PC cuts indexes definition
authorPatrick Bellasi <patrick.bellasi@arm.com>
Fri, 29 Jul 2016 14:32:26 +0000 (15:32 +0100)
committerAmit Pundir <amit.pundir@linaro.org>
Wed, 14 Sep 2016 09:29:32 +0000 (14:59 +0530)
The current definition of the Performance Boost (PB) and Performance Constraint
(PC) regions is has two main issues:
1) in the computation of the boost index we overflow the thresholds_gains
   table for boost=100
2) the two cuts had _NOT_ the same ratio

The last point means that when boost=0 we do _not_ have a "standard" EAS
behaviour, i.e. accepting all candidate which decrease energy regardless
of their impact on performances. Instead, we accept only schedule candidate
which are in the Optimal region, i.e. decrease energy while increasing
performances.

This behaviour can have a negative impact also on CPU selection policies
which tries to spread tasks to reduce latencies. Indeed, for example
we could end up rejecting a schedule candidate which want to move a task
from a congested CPU to an idle one while, specifically in the case where
the target CPU will be running on a lower OPP.

This patch fixes these two issues by properly clamping the boost value
in the appropriate range to compute the threshold indexes as well as
by using the same threshold index for both cuts.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Signed-off-by: Srinath Sridharan <srinathsr@google.com>
sched/tune: fix update of threshold index for boost groups

When SchedTune is configured to work with CGroup mode, each time we update
the boost value of a group we do not update the threshed indexes for the
definition of the Performance Boost (PC) and Performance Constraint (PC)
region. This means that while the OPP boosting and CPU biasing selection
is working as expected, the __schedtune_accept_deltas function is always
using the initial values for these cuts.

This patch ensure that each time a new boost value is configured for a
boost group, the cuts for the PB and PC region are properly updated too.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Signed-off-by: Srinath Sridharan <srinathsr@google.com>
sched/tune: update PC and PB cuts definition

The current definition of Performance Boost (PB) and Performance
Constraint (PC) cuts defines two "dead regions":
- up to 20% boost: we are in energy-reduction only mode, i.e.
  accept all candidate which reduce energy
- over 70% boost: we are in performance-increase only mode, i.e.
  accept only sched candidate which do not reduce performances

This patch uses a more fine grained configuration where these two "dead
regions" are reduced to: up to 10% and over 90%.
This should allow to have some boosting benefits starting from 10% boost
values as well as not being to much permissive starting from boost values
of 80%.

Suggested-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Signed-off-by: Srinath Sridharan <srinathsr@google.com>
bug: 28312446
Change-Id: Ia326c66521e38c98e7a7eddbbb7c437875efa1ba

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
kernel/sched/tune.c

index 4c77cc23e65b1163f581531cae56b507601ca47e..d24f365b0c908e09bdcc97aaa506837c4b6dac7d 100644 (file)
@@ -38,16 +38,16 @@ struct threshold_params {
  */
 static struct threshold_params
 threshold_gains[] = {
-       { 0, 4 }, /* >=  0% */
-       { 0, 4 }, /* >= 10% */
-       { 1, 4 }, /* >= 20% */
-       { 2, 4 }, /* >= 30% */
-       { 3, 4 }, /* >= 40% */
-       { 4, 3 }, /* >= 50% */
-       { 4, 2 }, /* >= 60% */
-       { 4, 1 }, /* >= 70% */
-       { 4, 0 }, /* >= 80% */
-       { 4, 0 }  /* >= 90% */
+       { 0, 5 }, /*   < 10% */
+       { 1, 5 }, /*   < 20% */
+       { 2, 5 }, /*   < 30% */
+       { 3, 5 }, /*   < 40% */
+       { 4, 5 }, /*   < 50% */
+       { 5, 4 }, /*   < 60% */
+       { 5, 3 }, /*   < 70% */
+       { 5, 2 }, /*   < 80% */
+       { 5, 1 }, /*   < 90% */
+       { 5, 0 }  /* <= 100% */
 };
 
 static int
@@ -549,13 +549,29 @@ boost_write(struct cgroup_subsys_state *css, struct cftype *cft,
            s64 boost)
 {
        struct schedtune *st = css_st(css);
+       unsigned threshold_idx;
+       int boost_pct;
 
        if (boost < -100 || boost > 100)
                return -EINVAL;
+       boost_pct = boost;
+
+       /*
+        * Update threshold params for Performance Boost (B)
+        * and Performance Constraint (C) regions.
+        * The current implementatio uses the same cuts for both
+        * B and C regions.
+        */
+       threshold_idx = clamp(boost_pct, 0, 99) / 10;
+       st->perf_boost_idx = threshold_idx;
+       st->perf_constrain_idx = threshold_idx;
 
        st->boost = boost;
-       if (css == &root_schedtune.css)
+       if (css == &root_schedtune.css) {
                sysctl_sched_cfs_boost = boost;
+               perf_boost_idx  = threshold_idx;
+               perf_constrain_idx  = threshold_idx;
+       }
 
        /* Update CPU boost */
        schedtune_boostgroup_update(st->idx, st->boost);
@@ -710,17 +726,25 @@ sysctl_sched_cfs_boost_handler(struct ctl_table *table, int write,
                               loff_t *ppos)
 {
        int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+       unsigned threshold_idx;
+       int boost_pct;
 
        if (ret || !write)
                return ret;
 
-       /* Performance Boost (B) region threshold params */
-       perf_boost_idx  = sysctl_sched_cfs_boost;
-       perf_boost_idx /= 10;
+       if (sysctl_sched_cfs_boost < -100 || sysctl_sched_cfs_boost > 100)
+               return -EINVAL;
+       boost_pct = sysctl_sched_cfs_boost;
 
-       /* Performance Constraint (C) region threshold params */
-       perf_constrain_idx  = 100 - sysctl_sched_cfs_boost;
-       perf_constrain_idx /= 10;
+       /*
+        * Update threshold params for Performance Boost (B)
+        * and Performance Constraint (C) regions.
+        * The current implementatio uses the same cuts for both
+        * B and C regions.
+        */
+       threshold_idx = clamp(boost_pct, 0, 99) / 10;
+       perf_boost_idx = threshold_idx;
+       perf_constrain_idx = threshold_idx;
 
        return 0;
 }