Message ID | 20210803102744.23654-1-lukasz.luba@arm.com |
---|---|
State | Accepted |
Commit | 7fcc17d0cb12938d2b3507973a6f93fc9ed2c7a1 |
Headers | show |
Series | [v3] PM: EM: Increase energy calculation precision | expand |
On Tue, Aug 3, 2021 at 3:31 PM Lukasz Luba <lukasz.luba@arm.com> wrote: > > Hi Rafael, > > On 8/3/21 11:27 AM, Lukasz Luba wrote: > > [snip] > > > > > Fixes: 27871f7a8a341ef ("PM: Introduce an Energy Model management framework") > > Reported-by: CCJ Yeh <CCj.Yeh@mediatek.com> > > Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com> > > Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> > > --- > > > > v3 changes: > > - adjusted patch description according to Dietmar's comments > > - added Dietmar's review tag > > - added one empty line in the code to separate them > > > > include/linux/energy_model.h | 16 ++++++++++++++++ > > kernel/power/energy_model.c | 4 +++- > > 2 files changed, 19 insertions(+), 1 deletion(-) > > > > Could you take this patch via your PM tree, please? I can do that, but do you want a Cc:stable tag on it?
On 8/4/21 7:10 PM, Rafael J. Wysocki wrote: > On Tue, Aug 3, 2021 at 3:31 PM Lukasz Luba <lukasz.luba@arm.com> wrote: >> >> Hi Rafael, >> >> On 8/3/21 11:27 AM, Lukasz Luba wrote: >> >> [snip] >> >>> >>> Fixes: 27871f7a8a341ef ("PM: Introduce an Energy Model management framework") >>> Reported-by: CCJ Yeh <CCj.Yeh@mediatek.com> >>> Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com> >>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> >>> --- >>> >>> v3 changes: >>> - adjusted patch description according to Dietmar's comments >>> - added Dietmar's review tag >>> - added one empty line in the code to separate them >>> >>> include/linux/energy_model.h | 16 ++++++++++++++++ >>> kernel/power/energy_model.c | 4 +++- >>> 2 files changed, 19 insertions(+), 1 deletion(-) >>> >> >> Could you take this patch via your PM tree, please? > > I can do that, but do you want a Cc:stable tag on it? > No, thank you. I'll prepare a dedicated patches and send them after this patch gets a proper commit ID. I've done similar things recently with some thermal stuff and different stable versions [1]. Please take this patch. I will handle the stable testing, preparation separately. Regards, Lukasz [1] https://lore.kernel.org/lkml/20210514104916.19975-1-lukasz.luba@arm.com/
On Thu, Aug 5, 2021 at 12:00 PM Lukasz Luba <lukasz.luba@arm.com> wrote: > > > > On 8/4/21 7:10 PM, Rafael J. Wysocki wrote: > > On Tue, Aug 3, 2021 at 3:31 PM Lukasz Luba <lukasz.luba@arm.com> wrote: > >> > >> Hi Rafael, > >> > >> On 8/3/21 11:27 AM, Lukasz Luba wrote: > >> > >> [snip] > >> > >>> > >>> Fixes: 27871f7a8a341ef ("PM: Introduce an Energy Model management framework") > >>> Reported-by: CCJ Yeh <CCj.Yeh@mediatek.com> > >>> Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com> > >>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> > >>> --- > >>> > >>> v3 changes: > >>> - adjusted patch description according to Dietmar's comments > >>> - added Dietmar's review tag > >>> - added one empty line in the code to separate them > >>> > >>> include/linux/energy_model.h | 16 ++++++++++++++++ > >>> kernel/power/energy_model.c | 4 +++- > >>> 2 files changed, 19 insertions(+), 1 deletion(-) > >>> > >> > >> Could you take this patch via your PM tree, please? > > > > I can do that, but do you want a Cc:stable tag on it? > > > > No, thank you. I'll prepare a dedicated patches and send them after this > patch gets a proper commit ID. I've done similar things recently with > some thermal stuff and different stable versions [1]. > > Please take this patch. I will handle the stable testing, preparation > separately. > > [1] https://lore.kernel.org/lkml/20210514104916.19975-1-lukasz.luba@arm.com/ OK, applied as 5.15 material. However, since I'm on vacation next week, it will show up in linux-next after -rc6. Thanks!
On 8/6/21 2:32 PM, Rafael J. Wysocki wrote: [snip] > > OK, applied as 5.15 material. Thank you Rafael! > > However, since I'm on vacation next week, it will show up in > linux-next after -rc6. No worries. Have a nice vacation!
diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index 3f221dbf5f95..1834752c5617 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -53,6 +53,22 @@ struct em_perf_domain { #ifdef CONFIG_ENERGY_MODEL #define EM_MAX_POWER 0xFFFF +/* + * Increase resolution of energy estimation calculations for 64-bit + * architectures. The extra resolution improves decision made by EAS for the + * task placement when two Performance Domains might provide similar energy + * estimation values (w/o better resolution the values could be equal). + * + * We increase resolution only if we have enough bits to allow this increased + * resolution (i.e. 64-bit). The costs for increasing resolution when 32-bit + * are pretty high and the returns do not justify the increased costs. + */ +#ifdef CONFIG_64BIT +#define em_scale_power(p) ((p) * 1000) +#else +#define em_scale_power(p) (p) +#endif + struct em_data_callback { /** * active_power() - Provide power at the next performance state of diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c index 0f4530b3a8cd..a332ccd829e2 100644 --- a/kernel/power/energy_model.c +++ b/kernel/power/energy_model.c @@ -170,7 +170,9 @@ static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd, /* Compute the cost of each performance state. */ fmax = (u64) table[nr_states - 1].frequency; for (i = 0; i < nr_states; i++) { - table[i].cost = div64_u64(fmax * table[i].power, + unsigned long power_res = em_scale_power(table[i].power); + + table[i].cost = div64_u64(fmax * power_res, table[i].frequency); }