Skip to content

Commit 15cbbd1

Browse files
vingu-linaroIngo Molnar
authored andcommitted
energy_model: Use a fixed reference frequency
The last item of a performance domain is not always the performance point that has been used to compute CPU's capacity. This can lead to different target frequency compared with other part of the system like schedutil and would result in wrong energy estimation. A new arch_scale_freq_ref() is available to return a fixed and coherent frequency reference that can be used when computing the CPU's frequency for an level of utilization. Use this function to get this reference frequency. Energy model is never used without defining arch_scale_freq_ref() but can be compiled. Define a default arch_scale_freq_ref() returning 0 in such case. Signed-off-by: Vincent Guittot <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Tested-by: Lukasz Luba <[email protected]> Reviewed-by: Lukasz Luba <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b3edde4 commit 15cbbd1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/linux/energy_model.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd,
224224
unsigned long max_util, unsigned long sum_util,
225225
unsigned long allowed_cpu_cap)
226226
{
227-
unsigned long freq, scale_cpu;
227+
unsigned long freq, ref_freq, scale_cpu;
228228
struct em_perf_state *ps;
229229
int cpu;
230230

@@ -241,10 +241,10 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd,
241241
*/
242242
cpu = cpumask_first(to_cpumask(pd->cpus));
243243
scale_cpu = arch_scale_cpu_capacity(cpu);
244-
ps = &pd->table[pd->nr_perf_states - 1];
244+
ref_freq = arch_scale_freq_ref(cpu);
245245

246246
max_util = min(max_util, allowed_cpu_cap);
247-
freq = map_util_freq(max_util, ps->frequency, scale_cpu);
247+
freq = map_util_freq(max_util, ref_freq, scale_cpu);
248248

249249
/*
250250
* Find the lowest performance state of the Energy Model above the

0 commit comments

Comments
 (0)