Currently we use the same index for PB and PC region, so it's not necessary to define two index value for PE regions cut.
This patch is to polish related code, which only use one index to refer gain table and it will be used both for PB and PC region's cut.
Signed-off-by: Leo Yan leo.yan@linaro.org --- kernel/sched/tune.c | 58 +++++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 40 deletions(-)
diff --git a/kernel/sched/tune.c b/kernel/sched/tune.c index dbe1825..4bca506 100644 --- a/kernel/sched/tune.c +++ b/kernel/sched/tune.c @@ -19,11 +19,8 @@ unsigned int sysctl_sched_cfs_boost __read_mostly;
extern struct target_nrg schedtune_target_nrg;
-/* 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) thresholds index */ +static int threshold_idx;
/** * Performance-Energy (P-E) Space thresholds constants @@ -51,18 +48,10 @@ threshold_gains[] = { };
static int -__schedtune_accept_deltas(int nrg_delta, int cap_delta, - int perf_boost_idx, int perf_constrain_idx) +__schedtune_accept_deltas(int nrg_delta, int cap_delta, int threshold_idx) { int payoff = -INT_MAX; - int gain_idx = -1; - - /* Performance Boost (B) region */ - if (nrg_delta >= 0 && cap_delta > 0) - gain_idx = perf_boost_idx; - /* Performance Constraint (C) region */ - else if (nrg_delta < 0 && cap_delta <= 0) - gain_idx = perf_constrain_idx; + int gain_idx = threshold_idx;
/* Default: reject schedule candidate */ if (gain_idx == -1) @@ -120,11 +109,8 @@ struct schedtune { /* Boost value for tasks on that SchedTune CGroup */ int boost;
- /* Performance Boost (B) region threshold params */ - int perf_boost_idx; - - /* Performance Constraint (C) region threshold params */ - int perf_constrain_idx; + /* Power-efficiency gain table index */ + int threshold_idx;
/* Hint to bias scheduling of tasks on that SchedTune CGroup * towards idle CPUs */ @@ -158,8 +144,7 @@ static inline struct schedtune *parent_st(struct schedtune *st) static struct schedtune root_schedtune = { .boost = 0, - .perf_boost_idx = 0, - .perf_constrain_idx = 0, + .threshold_idx = 0, .prefer_idle = 0, };
@@ -168,8 +153,7 @@ schedtune_accept_deltas(int nrg_delta, int cap_delta, struct task_struct *task) { struct schedtune *ct; - int perf_boost_idx; - int perf_constrain_idx; + int idx;
/* Optimal (O) region */ if (nrg_delta < 0 && cap_delta > 0) { @@ -186,12 +170,10 @@ schedtune_accept_deltas(int nrg_delta, int cap_delta, /* Get task specific perf Boost/Constraints indexes */ rcu_read_lock(); ct = task_schedtune(task); - perf_boost_idx = ct->perf_boost_idx; - perf_constrain_idx = ct->perf_constrain_idx; + idx = ct->threshold_idx; rcu_read_unlock();
- return __schedtune_accept_deltas(nrg_delta, cap_delta, - perf_boost_idx, perf_constrain_idx); + return __schedtune_accept_deltas(nrg_delta, cap_delta, idx); }
/* @@ -586,7 +568,7 @@ boost_write(struct cgroup_subsys_state *css, struct cftype *cft, s64 boost) { struct schedtune *st = css_st(css); - unsigned threshold_idx; + unsigned int idx; int boost_pct;
if (boost < -100 || boost > 100) @@ -599,15 +581,13 @@ boost_write(struct cgroup_subsys_state *css, struct cftype *cft, * 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; + idx = clamp(boost_pct, 0, 99) / 10; + st->threshold_idx = idx;
st->boost = boost; if (css == &root_schedtune.css) { sysctl_sched_cfs_boost = boost; - perf_boost_idx = threshold_idx; - perf_constrain_idx = threshold_idx; + threshold_idx = idx; }
/* Update CPU boost */ @@ -756,8 +736,7 @@ schedtune_accept_deltas(int nrg_delta, int cap_delta, return -INT_MAX; }
- return __schedtune_accept_deltas(nrg_delta, cap_delta, - perf_boost_idx, perf_constrain_idx); + return __schedtune_accept_deltas(nrg_delta, cap_delta, threshold_idx); }
#endif /* CONFIG_CGROUP_SCHEDTUNE */ @@ -768,7 +747,7 @@ 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; + unsigned idx; int boost_pct;
if (ret || !write) @@ -784,9 +763,8 @@ sysctl_sched_cfs_boost_handler(struct ctl_table *table, int write, * 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; + idx = clamp(boost_pct, 0, 99) / 10; + threshold_idx = threshold_idx;
return 0; } -- 1.9.1