Re: [PATCH V2 1/3] Calculate Thermal Pressure

From: Thara Gopinath
Date: Wed Apr 24 2019 - 00:13:45 EST


On 04/18/2019 06:14 AM, Quentin Perret wrote:
> On Tuesday 16 Apr 2019 at 15:38:39 (-0400), Thara Gopinath wrote:
>> +/**
>> + * Function to update thermal pressure from cooling device
>> + * or any framework responsible for capping cpu maximum
>> + * capacity.
>> + */
>> +void sched_update_thermal_pressure(struct cpumask *cpus,
>> + unsigned long cap_max_freq,
>> + unsigned long max_freq)
>> +{
>> + int cpu;
>> + unsigned long flags = 0;
>> + struct thermal_pressure *cpu_thermal;
>> +
>> + for_each_cpu(cpu, cpus) {
>
> Is it actually required to do this for each CPU ? You could calculate
> the whole thing once for the first CPU, and apply the result to all CPUs
> in the policy no ? All CPUs in a policy are capped and uncapped
> synchronously.
Hmm. You are right that all cpus in a policy are capped and uncapped
synchronously from the thermal framework point of view. But the thermal
pressure decay can happen at different times for each cpu and hence the
update has to be done on a per cpu basis(especially to keep track of
other age and other variables in the averaging and accumulating
algorithm). It can be separated out but I think it will just make the
solution more complicated.
>
>> + cpu_thermal = per_cpu(thermal_pressure_cpu, cpu);
>> + if (!cpu_thermal)
>> + return;
>> + spin_lock_irqsave(&cpu_thermal->lock, flags);
>> + thermal_pressure_update(cpu_thermal, cap_max_freq, max_freq, 1);
>> + }
>> +}


--
Regards
Thara