Messages in this thread | | | Date | Mon, 28 Oct 2019 16:33:13 +0100 | From | Peter Zijlstra <> | Subject | Re: [Patch v4 5/6] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping |
| |
On Tue, Oct 22, 2019 at 04:34:24PM -0400, Thara Gopinath wrote: > Thermal governors can request for a cpu's maximum supported frequency > to be capped in case of an overheat event. This in turn means that the > maximum capacity available for tasks to run on the particular cpu is > reduced. Delta between the original maximum capacity and capped > maximum capacity is known as thermal pressure. Enable cpufreq cooling > device to update the thermal pressure in event of a capped > maximum frequency. > > Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org> > --- > drivers/thermal/cpu_cooling.c | 31 +++++++++++++++++++++++++++++-- > 1 file changed, 29 insertions(+), 2 deletions(-) > > diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c > index 391f397..2e6a979 100644 > --- a/drivers/thermal/cpu_cooling.c > +++ b/drivers/thermal/cpu_cooling.c > @@ -218,6 +218,23 @@ static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_cdev, > } > > /** > + * update_sched_max_capacity - update scheduler about change in cpu > + * max frequency. > + * @policy - cpufreq policy whose max frequency is capped.
Uhm, this function doesn't have a @policy argument.
> + */ > +static void update_sched_max_capacity(struct cpumask *cpus, > + unsigned int cur_max_freq, > + unsigned int max_freq) > +{ > + int cpu; > + unsigned long capacity = (cur_max_freq << SCHED_CAPACITY_SHIFT) / > + max_freq;
check your types and ranges. What units is _freq in and does 'freq * SCHED_CAPACITY' fit in 'unsigned int'? If so, why do you assign it to an 'unsigned long'?
> + > + for_each_cpu(cpu, cpus) > + update_thermal_pressure(cpu, capacity); > +}
> @@ -331,8 +349,17 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, > > cpufreq_cdev->cpufreq_state = state; > > - return dev_pm_qos_update_request(&cpufreq_cdev->qos_req, > - cpufreq_cdev->freq_table[state].frequency); > + ret = dev_pm_qos_update_request > + (&cpufreq_cdev->qos_req, > + cpufreq_cdev->freq_table[state].frequency); > + > + if (ret > 0) > + update_sched_max_capacity > + (cpufreq_cdev->policy->cpus, > + cpufreq_cdev->freq_table[state].frequency, > + cpufreq_cdev->policy->cpuinfo.max_freq);
Codingstyle wants that in { }.
> + > + return ret; > } > > /** > -- > 2.1.4 >
| |