Re: [PATCH v5 15/23] PM: EM: Optimize em_cpu_energy() and remove division

Lukasz Luba
2024-01-02T11:45:47Z

On 12/28/23 18:06, Qais Yousef wrote:
> On 11/29/23 11:08, Lukasz Luba wrote:
>
>> @@ -220,8 +218,9 @@ static int em_compute_costs(struct device *dev, struct em_perf_state *table,
>> return -EINVAL;
>> }
>> } else {
>> - power_res = table[i].power;
>> - cost = div64_u64(fmax * power_res, table[i].frequency);
>> + /* increase resolution of 'cost' precision */
>> + power_res = table[i].power * 10;
>
> Power is in uW, right? You're just taking advantage here that everything will
> use this new cost field so you can add as many 0s to improve resolution without
> impact elsewhere that care to compare using the same units?

This code doesn't overwrite the 'power' field value. The 'cost' value is
only used in EAS, so yes I just want to increase resolution there.

I think you mixed 'power' and 'cost' fields. We don't compare 'cost'
anywhere. We just use 'cost' in one place em_cpu_energy() and we
multiply it (not compare it).

>
> Did you see a problem or just being extra cautious here?

There is no problem, 'cost' is a private coefficient for EAS only.

>
>> + cost = power_res / table[i].performance;
>> }
>>
>> table[i].cost = cost;
>> --
>> 2.25.1
>>