diff mbox series

[v4,12/18] PM: EM: Use runtime modified EM for CPUs energy estimation in EAS

Message ID 20230925081139.1305766-13-lukasz.luba@arm.com
State New
Headers show
Series Introduce runtime modifiable Energy Model | expand

Commit Message

Lukasz Luba Sept. 25, 2023, 8:11 a.m. UTC
The new Energy Model (EM) supports runtime modification of the performance
state table to better model the power used by the SoC. Use this new
feature to improve energy estimation and therefore task placement in
Energy Aware Scheduler (EAS).

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 include/linux/energy_model.h | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

Comments

Lukasz Luba Sept. 29, 2023, 10:10 a.m. UTC | #1
On 9/26/23 20:54, Rafael J. Wysocki wrote:
> On Mon, Sep 25, 2023 at 10:11 AM Lukasz Luba <lukasz.luba@arm.com> wrote:
>>
>> The new Energy Model (EM) supports runtime modification of the performance
>> state table to better model the power used by the SoC. Use this new
>> feature to improve energy estimation and therefore task placement in
>> Energy Aware Scheduler (EAS).
>>
>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
>> ---
>>   include/linux/energy_model.h | 20 +++++++++++++-------
>>   1 file changed, 13 insertions(+), 7 deletions(-)
>>
>> diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
>> index 8f055ab356ed..41290ee2cdd0 100644
>> --- a/include/linux/energy_model.h
>> +++ b/include/linux/energy_model.h
>> @@ -261,15 +261,14 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd,
>>                                  unsigned long max_util, unsigned long sum_util,
>>                                  unsigned long allowed_cpu_cap)
>>   {
>> +       struct em_perf_table *runtime_table;
> 
> You may as well call it just "table".  The "runtime_" prefix doesn't
> add much value here IMO.

Yes, I'll do that

Thank you Rafael for the review of the patch set!

Regards,
Lukasz
diff mbox series

Patch

diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
index 8f055ab356ed..41290ee2cdd0 100644
--- a/include/linux/energy_model.h
+++ b/include/linux/energy_model.h
@@ -261,15 +261,14 @@  static inline unsigned long em_cpu_energy(struct em_perf_domain *pd,
 				unsigned long max_util, unsigned long sum_util,
 				unsigned long allowed_cpu_cap)
 {
+	struct em_perf_table *runtime_table;
 	unsigned long freq, scale_cpu;
-	struct em_perf_state *table, *ps;
+	struct em_perf_state *ps;
 	int cpu, i;
 
 	if (!sum_util)
 		return 0;
 
-	table = pd->default_table->state;
-
 	/*
 	 * In order to predict the performance state, map the utilization of
 	 * the most utilized CPU of the performance domain to a requested
@@ -280,7 +279,14 @@  static inline unsigned long em_cpu_energy(struct em_perf_domain *pd,
 	 */
 	cpu = cpumask_first(to_cpumask(pd->cpus));
 	scale_cpu = arch_scale_cpu_capacity(cpu);
-	ps = &table[pd->nr_perf_states - 1];
+
+	/*
+	 * No rcu_read_lock() since it's already called by task scheduler.
+	 * The runtime_table is always there for CPUs, so we don't check.
+	 */
+	runtime_table = rcu_dereference(pd->runtime_table);
+
+	ps = &runtime_table->state[pd->nr_perf_states - 1];
 
 	max_util = map_util_perf(max_util);
 	max_util = min(max_util, allowed_cpu_cap);
@@ -290,9 +296,9 @@  static inline unsigned long em_cpu_energy(struct em_perf_domain *pd,
 	 * Find the lowest performance state of the Energy Model above the
 	 * requested frequency.
 	 */
-	i = em_pd_get_efficient_state(table, pd->nr_perf_states, freq,
-				      pd->flags);
-	ps = &table[i];
+	i = em_pd_get_efficient_state(runtime_table->state, pd->nr_perf_states,
+				      freq, pd->flags);
+	ps = &runtime_table->state[i];
 
 	/*
 	 * The capacity of a CPU in the domain at the performance state (ps)