Message ID | 1625738946-295849-4-git-send-email-vincent.donnefort@arm.com |
---|---|
State | Superseded |
Headers | show |
Series | [v4,1/9] PM / EM: Fix inefficient states detection | expand |
On 7/8/21 11:09 AM, Vincent Donnefort wrote: > Merge the current "milliwatts" option into a "flag" field. This intends to > prepare the extension of this structure for inefficient states support in > the Energy Model. > > Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com> > > diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h > index 7ca4f9cc8baf..1deb727245be 100644 > --- a/include/linux/energy_model.h > +++ b/include/linux/energy_model.h > @@ -40,8 +40,7 @@ struct em_perf_state { > * em_perf_domain - Performance domain > * @table: List of performance states, in ascending order > * @nr_perf_states: Number of performance states > - * @milliwatts: Flag indicating the power values are in milli-Watts > - * or some other scale. > + * @flags: See "em_perf_domain flags" > * @cpus: Cpumask covering the CPUs of the domain. It's here > * for performance reasons to avoid potential cache > * misses during energy calculations in the scheduler > @@ -56,10 +55,18 @@ struct em_perf_state { > struct em_perf_domain { > struct em_perf_state *table; > int nr_perf_states; > - int milliwatts; > + unsigned long flags; > unsigned long cpus[]; > }; > > +/* > + * em_perf_domain flags: > + * > + * EM_PERF_DOMAIN_MILLIWATTS: The power values are in milli-Watts or some > + * other scale. > + */ > +#define EM_PERF_DOMAIN_MILLIWATTS BIT(0) > + > #define em_span_cpus(em) (to_cpumask((em)->cpus)) > > #ifdef CONFIG_ENERGY_MODEL > diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c > index 30ab73ab6439..3ab0b913bcfa 100644 > --- a/kernel/power/energy_model.c > +++ b/kernel/power/energy_model.c > @@ -56,7 +56,8 @@ DEFINE_SHOW_ATTRIBUTE(em_debug_cpus); > static int em_debug_units_show(struct seq_file *s, void *unused) > { > struct em_perf_domain *pd = s->private; > - char *units = pd->milliwatts ? "milliWatts" : "bogoWatts"; > + char *units = (pd->flags & EM_PERF_DOMAIN_MILLIWATTS) ? > + "milliWatts" : "bogoWatts"; > > seq_printf(s, "%s\n", units); > > @@ -343,7 +344,8 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, > if (ret) > goto unlock; > > - dev->em_pd->milliwatts = milliwatts; > + if (milliwatts) > + dev->em_pd->flags |= EM_PERF_DOMAIN_MILLIWATTS; > > em_debug_create_pd(dev); > dev_info(dev, "EM: created perf domain\n"); > LGTM Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index 7ca4f9cc8baf..1deb727245be 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -40,8 +40,7 @@ struct em_perf_state { * em_perf_domain - Performance domain * @table: List of performance states, in ascending order * @nr_perf_states: Number of performance states - * @milliwatts: Flag indicating the power values are in milli-Watts - * or some other scale. + * @flags: See "em_perf_domain flags" * @cpus: Cpumask covering the CPUs of the domain. It's here * for performance reasons to avoid potential cache * misses during energy calculations in the scheduler @@ -56,10 +55,18 @@ struct em_perf_state { struct em_perf_domain { struct em_perf_state *table; int nr_perf_states; - int milliwatts; + unsigned long flags; unsigned long cpus[]; }; +/* + * em_perf_domain flags: + * + * EM_PERF_DOMAIN_MILLIWATTS: The power values are in milli-Watts or some + * other scale. + */ +#define EM_PERF_DOMAIN_MILLIWATTS BIT(0) + #define em_span_cpus(em) (to_cpumask((em)->cpus)) #ifdef CONFIG_ENERGY_MODEL diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c index 30ab73ab6439..3ab0b913bcfa 100644 --- a/kernel/power/energy_model.c +++ b/kernel/power/energy_model.c @@ -56,7 +56,8 @@ DEFINE_SHOW_ATTRIBUTE(em_debug_cpus); static int em_debug_units_show(struct seq_file *s, void *unused) { struct em_perf_domain *pd = s->private; - char *units = pd->milliwatts ? "milliWatts" : "bogoWatts"; + char *units = (pd->flags & EM_PERF_DOMAIN_MILLIWATTS) ? + "milliWatts" : "bogoWatts"; seq_printf(s, "%s\n", units); @@ -343,7 +344,8 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, if (ret) goto unlock; - dev->em_pd->milliwatts = milliwatts; + if (milliwatts) + dev->em_pd->flags |= EM_PERF_DOMAIN_MILLIWATTS; em_debug_create_pd(dev); dev_info(dev, "EM: created perf domain\n");
Merge the current "milliwatts" option into a "flag" field. This intends to prepare the extension of this structure for inefficient states support in the Energy Model. Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>