diff mbox series

[RESEND,2/8] PM: EM: Add artificial EM flag

Message ID 20220321095729.20655-3-lukasz.luba@arm.com
State New
Headers show
Series Introduce support for artificial Energy Model | expand

Commit Message

Lukasz Luba March 21, 2022, 9:57 a.m. UTC
From: Pierre Gondois <Pierre.Gondois@arm.com>

The Energy Model (EM) can be used on platforms which are missing real
power information. Those platforms would implement .get_cost() which
populates needed values for the Energy Aware Scheduler (EAS). The EAS
doesn't use 'power' fields from EM, but other frameworks might use them.
Thus, to avoid miss-usage of this specific type of EM, introduce a new
flags which can be checked by other frameworks.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 include/linux/energy_model.h | 5 +++++
 kernel/power/energy_model.c  | 2 ++
 2 files changed, 7 insertions(+)

Comments

Ionela Voinescu April 4, 2022, 4:01 p.m. UTC | #1
On Monday 21 Mar 2022 at 09:57:23 (+0000), Lukasz Luba wrote:
> From: Pierre Gondois <Pierre.Gondois@arm.com>
> 
> The Energy Model (EM) can be used on platforms which are missing real
> power information. Those platforms would implement .get_cost() which
> populates needed values for the Energy Aware Scheduler (EAS). The EAS
> doesn't use 'power' fields from EM, but other frameworks might use them.
> Thus, to avoid miss-usage of this specific type of EM, introduce a new
> flags which can be checked by other frameworks.
> 
> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> ---
>  include/linux/energy_model.h | 5 +++++
>  kernel/power/energy_model.c  | 2 ++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
> index 0a3a5663177b..92e82a322859 100644
> --- a/include/linux/energy_model.h
> +++ b/include/linux/energy_model.h
> @@ -67,11 +67,16 @@ struct em_perf_domain {
>   *
>   *  EM_PERF_DOMAIN_SKIP_INEFFICIENCIES: Skip inefficient states when estimating
>   *  energy consumption.
> + *
> + *  EM_PERF_DOMAIN_ARTIFICIAL: The power values are artificial and might be
> + *  created by platform missing real power information
>   */
>  #define EM_PERF_DOMAIN_MILLIWATTS BIT(0)
>  #define EM_PERF_DOMAIN_SKIP_INEFFICIENCIES BIT(1)
> +#define EM_PERF_DOMAIN_ARTIFICIAL BIT(2)
>  
>  #define em_span_cpus(em) (to_cpumask((em)->cpus))
> +#define em_is_artificial(em) ((em)->flags & EM_PERF_DOMAIN_ARTIFICIAL)
>  
>  #ifdef CONFIG_ENERGY_MODEL
>  #define EM_MAX_POWER 0xFFFF
> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
> index 0153b0ca7b23..6ecee99af842 100644
> --- a/kernel/power/energy_model.c
> +++ b/kernel/power/energy_model.c
> @@ -384,6 +384,8 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
>  
>  	if (milliwatts)
>  		dev->em_pd->flags |= EM_PERF_DOMAIN_MILLIWATTS;
> +	else if (cb->get_cost)
> +		dev->em_pd->flags |= EM_PERF_DOMAIN_ARTIFICIAL;
>  
>  	em_cpufreq_update_efficiencies(dev);
>  

Reviewed-by: Ionela Voinescu <ionela.voinescu@arm.com>

> -- 
> 2.17.1
>
diff mbox series

Patch

diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
index 0a3a5663177b..92e82a322859 100644
--- a/include/linux/energy_model.h
+++ b/include/linux/energy_model.h
@@ -67,11 +67,16 @@  struct em_perf_domain {
  *
  *  EM_PERF_DOMAIN_SKIP_INEFFICIENCIES: Skip inefficient states when estimating
  *  energy consumption.
+ *
+ *  EM_PERF_DOMAIN_ARTIFICIAL: The power values are artificial and might be
+ *  created by platform missing real power information
  */
 #define EM_PERF_DOMAIN_MILLIWATTS BIT(0)
 #define EM_PERF_DOMAIN_SKIP_INEFFICIENCIES BIT(1)
+#define EM_PERF_DOMAIN_ARTIFICIAL BIT(2)
 
 #define em_span_cpus(em) (to_cpumask((em)->cpus))
+#define em_is_artificial(em) ((em)->flags & EM_PERF_DOMAIN_ARTIFICIAL)
 
 #ifdef CONFIG_ENERGY_MODEL
 #define EM_MAX_POWER 0xFFFF
diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
index 0153b0ca7b23..6ecee99af842 100644
--- a/kernel/power/energy_model.c
+++ b/kernel/power/energy_model.c
@@ -384,6 +384,8 @@  int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
 
 	if (milliwatts)
 		dev->em_pd->flags |= EM_PERF_DOMAIN_MILLIWATTS;
+	else if (cb->get_cost)
+		dev->em_pd->flags |= EM_PERF_DOMAIN_ARTIFICIAL;
 
 	em_cpufreq_update_efficiencies(dev);