In current code, PE filter don't support negative boosting and it will directly convert the same case with boost=0.
So this patch is to add PE filter support for negative boosting, when the boosting value is negative, then that means we should rotate left for cut regions; for boosting value = -100, that means the cut regions should rotate totally under X-axis; so finally it will only consider to place task with lower capacity but don't care about any case for energy.
After PE filter support both positive and negative boosting value, it will have more confidence for algorithm integrity.
Signed-off-by: Leo Yan leo.yan@linaro.org --- kernel/sched/tune.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-)
diff --git a/kernel/sched/tune.c b/kernel/sched/tune.c index 5c1844a..fef0fc9 100644 --- a/kernel/sched/tune.c +++ b/kernel/sched/tune.c @@ -47,15 +47,34 @@ threshold_gains[] = { { 5, 0 } /* <= 100% */ };
+static struct threshold_params +negative_threshold_gains[] = { + { -1, 5 }, /* < 10% */ + { -2, 5 }, /* < 20% */ + { -3, 5 }, /* < 30% */ + { -4, 5 }, /* < 40% */ + { -5, 5 }, /* < 50% */ + { -5, 4 }, /* < 60% */ + { -5, 3 }, /* < 70% */ + { -5, 2 }, /* < 80% */ + { -5, 1 }, /* < 90% */ + { -5, 0 } /* <= 100% */ +}; + static int __schedtune_accept_deltas(int nrg_delta, int cap_delta, int threshold_idx) { int payoff = -INT_MAX; - int gain_idx = threshold_idx; - - /* Default: reject schedule candidate */ - if (gain_idx == -1) - return payoff; + int gain_idx; + struct threshold_params *gain_table; + + if (threshold_idx > 0) { + gain_idx = threshold_idx; + gain_table = threshold_gains; + } else { + gain_idx = -threshold_idx; + gain_table = negative_threshold_gains; + }
/* * Evaluate "Performance Boost" vs "Energy Increase" @@ -86,8 +105,8 @@ __schedtune_accept_deltas(int nrg_delta, int cap_delta, int threshold_idx) * for both the B and C regions, we can use the same payoff formula * where a positive value represents the accept condition. */ - payoff = cap_delta * threshold_gains[gain_idx].nrg_gain; - payoff -= nrg_delta * threshold_gains[gain_idx].cap_gain; + payoff = cap_delta * gain_table[gain_idx].nrg_gain; + payoff -= nrg_delta * gain_table[gain_idx].cap_gain;
return payoff; } @@ -569,7 +588,7 @@ boost_write(struct cgroup_subsys_state *css, struct cftype *cft, * The current implementatio uses the same cuts for both * B and C regions. */ - idx = clamp(boost_pct, 0, 99) / 10; + idx = clamp(boost_pct, -99, 99) / 10; st->threshold_idx = idx;
st->boost = boost; @@ -751,7 +770,7 @@ sysctl_sched_cfs_boost_handler(struct ctl_table *table, int write, * The current implementatio uses the same cuts for both * B and C regions. */ - idx = clamp(boost_pct, 0, 99) / 10; + idx = clamp(boost_pct, -99, 99) / 10; threshold_idx = threshold_idx;
return 0; -- 1.9.1