Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94da10c9 authored by Olav Haugan's avatar Olav Haugan Committed by Matt Wagantall
Browse files

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: default avatarOlav Haugan <ohaugan@codeaurora.org>
[rameezmustafa@codeaurora.org]: Port to msm-3.18]
Signed-off-by: default avatarSyed Rameez Mustafa <rameezmustafa@codeaurora.org>
parent 2a6f685b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -1095,7 +1095,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;
}
+9 −8
Original line number Diff line number Diff line
@@ -2344,8 +2344,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
@@ -2793,7 +2794,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
@@ -2824,7 +2825,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 */
@@ -3455,7 +3456,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)))
@@ -3550,7 +3551,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)
{
@@ -7550,7 +7551,7 @@ struct sched_group *group, struct sg_lb_stats *sgs, struct lb_env *env)
	 * 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) <
@@ -8641,7 +8642,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);
@@ -9124,7 +9125,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) {
+0 −1
Original line number Diff line number Diff line
@@ -1059,7 +1059,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);
Loading