cpufreq/sched: Consider max cpu capacity when choosing frequencies

When using schedfreq on cpus with max capacity significantly smaller than
1024, the tick update uses non-normalised capacities - this leads to
selecting an incorrect OPP as we were scaling the frequency as if the
max capacity achievable was 1024 rather than the max for that particular
cpu or group. This could result in a cpu being stuck at the lowest OPP
and unable to generate enough utilisation to climb out if the max
capacity is significantly smaller than 1024.

Instead, normalize the capacity to be in the range 0-1024 in the tick
so that when we later select a frequency, we get the correct one.

Also comments updated to be clearer about what is needed.

Change-Id: Id84391c7ac015311002ada21813a353ee13bee60
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
(cherry picked from commit bc3b0db024f3d0b323e7d93994655e9e3d9f8d68)
Signed-off-by: Quentin Perret <quentin.perret@arm.com>
This commit is contained in:
Chris Redpath
2017-04-25 10:37:58 +01:00
committed by Todd Kjos
parent 22f1127850
commit d870d26fb3
3 changed files with 10 additions and 2 deletions

View File

@@ -3175,7 +3175,9 @@ static void sched_freq_tick_pelt(int cpu)
* utilization and to harm its performance the least, request
* a jump to a higher OPP as soon as the margin of free capacity
* is impacted (specified by capacity_margin).
* Remember CPU utilization in sched_capacity_reqs should be normalised.
*/
cpu_utilization = cpu_utilization * SCHED_CAPACITY_SCALE / capacity_orig_of(cpu);
set_cfs_cpu_capacity(cpu, true, cpu_utilization);
}
@@ -3202,7 +3204,9 @@ static void sched_freq_tick_walt(int cpu)
* It is likely that the load is growing so we
* keep the added margin in our request as an
* extra boost.
* Remember CPU utilization in sched_capacity_reqs should be normalised.
*/
cpu_utilization = cpu_utilization * SCHED_CAPACITY_SCALE / capacity_orig_of(cpu);
set_cfs_cpu_capacity(cpu, true, cpu_utilization);
}

View File

@@ -4803,7 +4803,7 @@ static void update_capacity_of(int cpu)
if (!sched_freq())
return;
/* Convert scale-invariant capacity to cpu. */
/* Normalize scale-invariant capacity to cpu. */
req_cap = boosted_cpu_util(cpu);
req_cap = req_cap * SCHED_CAPACITY_SCALE / capacity_orig_of(cpu);
set_cfs_cpu_capacity(cpu, true, req_cap);
@@ -4996,7 +4996,7 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
if (rq->cfs.nr_running)
update_capacity_of(cpu_of(rq));
else if (sched_freq())
set_cfs_cpu_capacity(cpu_of(rq), false, 0);
set_cfs_cpu_capacity(cpu_of(rq), false, 0); /* no normalization required for 0 */
}
}

View File

@@ -1667,6 +1667,10 @@ static inline bool sched_freq(void)
return static_key_false(&__sched_freq);
}
/*
* sched_capacity_reqs expects capacity requests to be normalised.
* All capacities should sum to the range of 0-1024.
*/
DECLARE_PER_CPU(struct sched_capacity_reqs, cpu_sched_capacity_reqs);
void update_cpu_capacity_request(int cpu, bool request);