Message ID | 20240117095714.1524808-23-lukasz.luba@arm.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | Introduce runtime modifiable Energy Model | expand |
On 17/01/2024 10:57, Lukasz Luba wrote: [...] > diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c > index e91c8efb5361..104cc2e2aa84 100644 > --- a/kernel/power/energy_model.c > +++ b/kernel/power/energy_model.c > @@ -276,6 +276,24 @@ static int em_compute_costs(struct device *dev, struct em_perf_state *table, > return 0; > } > > +/** > + * em_dev_compute_costs() - Calculate cost values for new runtime EM table > + * @dev : Device for which the EM table is to be updated > + * @table : The new EM table that is going to get the costs calculated > + * > + * Calculate the em_perf_state::cost values for new runtime EM table. The > + * values are used for EAS during task placement. It also calculates and sets > + * the efficiency flag for each performance state. When the function finish > + * successfully the EM table is ready to be updated and used by EAS. > + * > + * Return 0 on success or a proper error in case of failure. > + */ > +int em_dev_compute_costs(struct device *dev, struct em_perf_state *table, > + int nr_states) > +{ > + return em_compute_costs(dev, table, NULL, nr_states, 0); > +} > + Still no user of this function in this patch-set so it could be introduced with the follow-up patch 'OPP: Add API to update EM after adjustment of voltage for OPPs'. Especially now since Viresh and you have agreed that this should be part of the EM code as well: https://lkml.kernel.org/r/a42ae8dd-383c-43c0-88b4-101303d6f548@arm.com
diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index 92866a81abe4..770755df852f 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -170,6 +170,8 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, void em_dev_unregister_perf_domain(struct device *dev); struct em_perf_table __rcu *em_table_alloc(struct em_perf_domain *pd); void em_table_free(struct em_perf_table __rcu *table); +int em_dev_compute_costs(struct device *dev, struct em_perf_state *table, + int nr_states); /** * em_pd_get_efficient_state() - Get an efficient performance state from the EM @@ -379,6 +381,12 @@ struct em_perf_state *em_perf_state_from_pd(struct em_perf_domain *pd) { return NULL; } +static inline +int em_dev_compute_costs(struct device *dev, struct em_perf_state *table, + int nr_states) +{ + return -EINVAL; +} #endif #endif diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c index e91c8efb5361..104cc2e2aa84 100644 --- a/kernel/power/energy_model.c +++ b/kernel/power/energy_model.c @@ -276,6 +276,24 @@ static int em_compute_costs(struct device *dev, struct em_perf_state *table, return 0; } +/** + * em_dev_compute_costs() - Calculate cost values for new runtime EM table + * @dev : Device for which the EM table is to be updated + * @table : The new EM table that is going to get the costs calculated + * + * Calculate the em_perf_state::cost values for new runtime EM table. The + * values are used for EAS during task placement. It also calculates and sets + * the efficiency flag for each performance state. When the function finish + * successfully the EM table is ready to be updated and used by EAS. + * + * Return 0 on success or a proper error in case of failure. + */ +int em_dev_compute_costs(struct device *dev, struct em_perf_state *table, + int nr_states) +{ + return em_compute_costs(dev, table, NULL, nr_states, 0); +} + /** * em_dev_update_perf_domain() - Update runtime EM table for a device * @dev : Device for which the EM is to be updated
The device drivers can modify EM at runtime by providing a new EM table. The EM is used by the EAS and the em_perf_state::cost stores pre-calculated value to avoid overhead. This patch provides the API for device drivers to calculate the cost values properly (and not duplicate the same code). Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> --- include/linux/energy_model.h | 8 ++++++++ kernel/power/energy_model.c | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+)