summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlav Haugan <ohaugan@codeaurora.org>2014-12-19 16:13:58 -0800
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 20:01:24 -0700
commit3f947e7ba7a22de8b5be7b064acbb3d395aa2760 (patch)
tree109b9ff2cac9fe2e7e83ee708f6cb3dc2d90ef3a
parent1bc662a79143c8814dac727b37cd4bf4a1c64e7f (diff)
sched: Add sysctl to enable power aware scheduling
Add sysctl to enable energy awareness at runtime. This is useful for performance/power tuning/measurements and debugging. In addition this will match up with the Documentation/scheduler/sched-hmp.txt documentation. Change-Id: I0a9185498640d66917b38bf5d55f6c59fc60ad5c Signed-off-by: Olav Haugan <ohaugan@codeaurora.org> [rameezmustafa@codeaurora.org]: Port to msm-3.18] Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org
-rw-r--r--Documentation/scheduler/sched-hmp.txt2
-rw-r--r--include/linux/sched/sysctl.h1
-rw-r--r--kernel/sched/core.c2
-rw-r--r--kernel/sched/fair.c17
-rw-r--r--kernel/sched/sched.h1
-rw-r--r--kernel/sysctl.c7
6 files changed, 19 insertions, 11 deletions
diff --git a/Documentation/scheduler/sched-hmp.txt b/Documentation/scheduler/sched-hmp.txt
index 54add3c4b94f..62c33b8b45fd 100644
--- a/Documentation/scheduler/sched-hmp.txt
+++ b/Documentation/scheduler/sched-hmp.txt
@@ -1086,7 +1086,7 @@ high-performance CPU).
Appears at: /proc/sys/kernel/sched_enable_power_aware
-Default value: 1
+Default value: 0
Controls whether or not per-CPU power values are used in determining
task placement. If this is disabled, tasks are simply placed on the
diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
index 0ec9fc8cd361..5437c599fd54 100644
--- a/include/linux/sched/sysctl.h
+++ b/include/linux/sched/sysctl.h
@@ -49,6 +49,7 @@ extern unsigned int sysctl_sched_freq_account_wait_time;
extern unsigned int sysctl_sched_migration_fixup;
extern unsigned int sysctl_sched_heavy_task_pct;
extern unsigned int sysctl_sched_min_runtime;
+extern unsigned int sysctl_sched_enable_power_aware;
#if defined(CONFIG_SCHED_FREQ_INPUT) || defined(CONFIG_SCHED_HMP)
extern unsigned int sysctl_sched_init_task_load_pct;
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 290b8df6f6e0..332b920af31e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1097,7 +1097,7 @@ static int __init set_sched_enable_power_aware(char *str)
get_option(&str, &enable_power_aware);
- sched_enable_power_aware = !!enable_power_aware;
+ sysctl_sched_enable_power_aware = !!enable_power_aware;
return 0;
}
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ec085a9e4da1..d9d4694d58da 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2579,8 +2579,9 @@ unsigned int __read_mostly sysctl_sched_spill_nr_run = 10;
/*
* Control whether or not individual CPU power consumption is used to
* guide task placement.
+ * This sysctl can be set to a default value using boot command line arguments.
*/
-unsigned int __read_mostly sched_enable_power_aware = 0;
+unsigned int __read_mostly sysctl_sched_enable_power_aware = 0;
/*
* This specifies the maximum percent power difference between 2
@@ -3028,7 +3029,7 @@ unsigned int power_cost_at_freq(int cpu, unsigned int freq)
struct cpu_pstate_pwr *costs;
if (!per_cpu_info || !per_cpu_info[cpu].ptable ||
- !sched_enable_power_aware)
+ !sysctl_sched_enable_power_aware)
/* When power aware scheduling is not in use, or CPU
* power data is not available, just use the CPU
* capacity as a rough stand-in for real CPU power
@@ -3059,7 +3060,7 @@ static unsigned int power_cost(struct task_struct *p, int cpu)
unsigned int task_freq;
unsigned int cur_freq = cpu_rq(cpu)->cur_freq;
- if (!sched_enable_power_aware)
+ if (!sysctl_sched_enable_power_aware)
return cpu_rq(cpu)->max_possible_capacity;
/* calculate % of max freq needed */
@@ -3690,7 +3691,7 @@ static inline int migration_needed(struct rq *rq, struct task_struct *p)
if (!task_will_fit(p, cpu_of(rq)))
return MOVE_TO_BIG_CPU;
- if (sched_enable_power_aware &&
+ if (sysctl_sched_enable_power_aware &&
!is_task_migration_throttled(p) &&
is_cpu_throttling_imminent(cpu_of(rq)) &&
lower_power_cpu_available(p, cpu_of(rq)))
@@ -3785,7 +3786,7 @@ unsigned int cpu_temp(int cpu)
#else /* CONFIG_SCHED_HMP */
-#define sched_enable_power_aware 0
+#define sysctl_sched_enable_power_aware 0
static inline int task_will_fit(struct task_struct *p, int cpu)
{
@@ -7827,7 +7828,7 @@ group_type group_classify(struct sched_group *group,
* prioritize spreading work over power optimization.
*/
cpu = cpumask_first(sched_group_cpus(group));
- if (sched_enable_power_aware &&
+ if (sysctl_sched_enable_power_aware &&
(capacity(env->dst_rq) == group_rq_capacity(group)) &&
sgs->sum_nr_running && (env->idle != CPU_NOT_IDLE) &&
power_cost_at_freq(env->dst_cpu, 0) <
@@ -8935,7 +8936,7 @@ static int idle_balance(struct rq *this_rq)
*/
rcu_read_lock();
sd = rcu_dereference_check_sched_domain(this_rq->sd);
- if (sd && sched_enable_power_aware) {
+ if (sd && sysctl_sched_enable_power_aware) {
for_each_cpu(i, sched_domain_span(sd)) {
if (i == this_cpu || idle_cpu(i)) {
cost = power_cost_at_freq(i, 0);
@@ -9429,7 +9430,7 @@ static int select_lowest_power_cpu(struct cpumask *cpus)
int lowest_power_cpu = -1;
int lowest_power = INT_MAX;
- if (sched_enable_power_aware) {
+ if (sysctl_sched_enable_power_aware) {
for_each_cpu(i, cpus) {
cost = power_cost_at_freq(i, 0);
if (cost < lowest_power) {
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 898e24e9f63d..89b2f4dee627 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1150,7 +1150,6 @@ static inline void clear_reserved(int cpu)
}
extern unsigned int sched_enable_hmp;
-extern unsigned int sched_enable_power_aware;
int mostly_idle_cpu(int cpu);
extern void check_for_migration(struct rq *rq, struct task_struct *p);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 69a379c4573f..5e0354d6317c 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -442,6 +442,13 @@ static struct ctl_table kern_table[] = {
.mode = 0644,
.proc_handler = sched_boost_handler,
},
+ {
+ .procname = "sched_enable_power_aware",
+ .data = &sysctl_sched_enable_power_aware,
+ .maxlen = sizeof(unsigned int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
#endif /* CONFIG_SCHED_HMP */
#ifdef CONFIG_SCHED_DEBUG
{