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

Commit 8f7e5b8e authored by Syed Rameez Mustafa's avatar Syed Rameez Mustafa Committed by Steve Muckle
Browse files

sched: Add a per rq max_possible_capacity for use in power calculations



In the absence of a power driver providing real power values, the scheduler
currently defaults to using capacity of a CPU as a measure of power. This,
however, is not a good measure since the capacity of a CPU can change due
to thermal conditions and/or other hardware restrictions. These frequency
restrictions have no effect on the power efficiency of those CPUs.
Introduce max possible capacity of a CPU to track an absolute measure of
capacity which translates into a good absolute measure of power efficiency.
Max possible capacity takes the max possible frequency of CPUs into account
instead of max frequency.

Change-Id: Ia970b853e43a90eb8cc6fd990b5c47fca7e50db8
Signed-off-by: default avatarSyed Rameez Mustafa <rameezmustafa@codeaurora.org>
parent 16fa0667
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1611,6 +1611,8 @@ static int cpufreq_notifier_policy(struct notifier_block *nb,
		struct rq *rq = cpu_rq(i);

		rq->capacity = compute_capacity(i);
		rq->max_possible_capacity = rq->capacity *
				rq->max_possible_freq / rq->max_freq;
		rq->load_scale_factor = compute_load_scale_factor(i);
	}

@@ -8158,6 +8160,7 @@ void __init sched_init(void)
		rq->max_freq = 1;
		rq->min_freq = 1;
		rq->max_possible_freq = 1;
		rq->max_possible_capacity = 0;
		rq->cumulative_runnable_avg = 0;
		rq->efficiency = 1024;
		rq->capacity = 1024;
+1 −0
Original line number Diff line number Diff line
@@ -308,6 +308,7 @@ do { \
#if defined(CONFIG_SCHED_HMP) || defined(CONFIG_SCHED_FREQ_INPUT)
	P(load_scale_factor);
	P(capacity);
	P(max_possible_capacity);
	P(efficiency);
	P(cur_freq);
	P(max_freq);
+2 −2
Original line number Diff line number Diff line
@@ -1576,7 +1576,7 @@ unsigned int power_cost_at_freq(int cpu, unsigned int freq)
		 * capacity as a rough stand-in for real CPU power
		 * numbers, assuming bigger CPUs are more power
		 * hungry. */
		return cpu_rq(cpu)->capacity;
		return cpu_rq(cpu)->max_possible_capacity;

	if (!freq)
		freq = min_max_freq;
@@ -1602,7 +1602,7 @@ static unsigned int power_cost(struct task_struct *p, int cpu)
	unsigned int cur_freq = cpu_rq(cpu)->cur_freq;

	if (!sysctl_sched_enable_power_aware)
		return cpu_rq(cpu)->capacity;
		return cpu_rq(cpu)->max_possible_capacity;

	/* calculate % of max freq needed */
	demand = scale_load_to_cpu(task_load(p), cpu) * 100;
+1 −0
Original line number Diff line number Diff line
@@ -495,6 +495,7 @@ struct rq {
	int efficiency; /* Differentiate cpus with different IPC capability */
	int load_scale_factor;
	int capacity;
	int max_possible_capacity;
	u64 window_start;

	unsigned int curr_runnable_sum;