[RESEND][PATCH v2 2/4] PM: EM: Change the em_adjust_new_capacity() to re-use code

Lukasz Luba lukasz.luba at arm.com
Tue Mar 26 13:36:08 PDT 2024



On 3/26/24 10:51, Dietmar Eggemann wrote:
> On 22/03/2024 12:08, Lukasz Luba wrote:
> 
> Maybe better : "PM: EM: Refactoring em_adjust_new_capacity()" ?
> 
>> There is going to be a new update function addressing chip binning.
>> Therefore, some common code which can be refactored and called from
>> upcoming changes and em_adjust_new_capacity(). In this way the code
>> duplication can be avoided.
> 
> IMHO, that's hard to digest.
> 
> Extract em_table_dup() and em_recalc_and_update() from
> em_adjust_new_capacity(). Both functions will be later reused by the
> 'update EM due to chip binning' functionality.

That looks good, I'll update it.

> 
> [...]
> 
>> +static int em_recalc_and_update(struct device *dev, struct em_perf_domain *pd,
>> +				struct em_perf_table __rcu *em_table)
>> +{
>> +	int ret;
>> +
>> +	ret = em_compute_costs(dev, em_table->state, NULL, pd->nr_perf_states,
>>   			       pd->flags);
>> -	if (ret) {
>> -		dev_warn(dev, "EM: compute costs failed\n");
>> -		return;
>> -	}
>> +	if (ret)
>> +		goto free_em_table;
> 
> There seems to be a subtle change in this patch. When em_compute_costs()
> fails now em_table_free() is called. This wasn't the case before when
> em_compute_costs() was directly called from em_adjust_new_capacity().

Yes, I've refactored it to explicitly call to the same free_em_table
for both fails in the new code. It should have been done in old code.

> 
> [...]



More information about the linux-arm-kernel mailing list