When calculate payoff criteria for performance constraint region, the inequality formula is wrong:
cap_delta / nrg_delta > cap_gain / nrg_gain
Here nrg_delta < 0, so when multiply it both side then should then multiplying nrg_delta inverts the inequality:
nrg_delta * cap_gain > cap_delta * nrg_gain
So finally we can get unified formula for both performance constraint region and performance boost region. So this patch unified these the calculation after fixed inequality formula.
Signed-off-by: Leo Yan leo.yan@linaro.org --- kernel/sched/tune.c | 54 ++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 25 deletions(-)
diff --git a/kernel/sched/tune.c b/kernel/sched/tune.c index 9d8eeb4..1da85a8 100644 --- a/kernel/sched/tune.c +++ b/kernel/sched/tune.c @@ -58,36 +58,40 @@ __schedtune_accept_deltas(int nrg_delta, int cap_delta, int perf_boost_idx, int perf_constrain_idx) { int payoff = -INT_MAX; + int idx = -1;
/* Performance Boost (B) region */ - if (nrg_delta > 0 && cap_delta > 0) { - /* - * Evaluate "Performance Boost" vs "Energy Increase" - * payoff criteria: - * cap_delta / nrg_delta < cap_gain / nrg_gain - * which is: - * nrg_delta * cap_gain > cap_delta * nrg_gain - */ - payoff = nrg_delta * threshold_gains[perf_boost_idx].cap_gain; - payoff -= cap_delta * threshold_gains[perf_boost_idx].nrg_gain; - return payoff; - } - + if (nrg_delta > 0 && cap_delta > 0) + idx = perf_boost_idx; /* Performance Constraint (C) region */ - if (nrg_delta < 0 && cap_delta < 0) { - /* - * Evaluate "Performance Boost" vs "Energy Increase" - * payoff criteria: - * cap_delta / nrg_delta > cap_gain / nrg_gain - * which is: - * cap_delta * nrg_gain > nrg_delta * cap_gain - */ - payoff = cap_delta * threshold_gains[perf_constrain_idx].nrg_gain; - payoff -= nrg_delta * threshold_gains[perf_constrain_idx].cap_gain; - return payoff; - } + else if (nrg_delta < 0 && cap_delta < 0) + idx = perf_constrain_idx;
/* Default: reject schedule candidate */ + if (idx == -1) + return payoff; + + /* + * Evaluate "Performance Boost" vs "Energy Increase" + * + * - Performance Boost (B) region + * + * Condition: nrg_delta > 0 && cap_delta > 0 + * Payoff criteria: + * cap_delta / nrg_delta < cap_gain / nrg_gain = + * nrg_delta * cap_gain > cap_delta * nrg_gain + * (note: nrg_delta > 0, nrg_gain > 0) + * + * - Performance Constraint (C) region + * + * Condition: nrg_delta < 0 && cap_delta < 0 + * payoff criteria: + * cap_delta / nrg_delta > cap_gain / nrg_gain = + * nrg_delta * cap_gain > cap_delta * nrg_gain + * (note: nrg_delta < 0, nrg_gain > 0) + */ + payoff = nrg_delta * threshold_gains[perf_boost_idx].cap_gain; + payoff -= cap_delta * threshold_gains[perf_boost_idx].nrg_gain; return payoff; }
-- 1.9.1