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

From: Quentin Perret
Date: Thu Apr 18 2019 - 06:14:27 EST


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.

> + 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);
> + }
> +}