Messages in this thread |  | | Date | Mon, 23 Dec 2019 17:54:58 +0000 | From | Ionela Voinescu <> | Subject | Re: [Patch v6 6/7] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping |
| |
On Wednesday 11 Dec 2019 at 23:11:47 (-0500), Thara Gopinath wrote: [...] > @@ -430,6 +430,10 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, > unsigned long state) > { > struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; > + struct cpumask *cpus; > + unsigned int frequency; > + unsigned long capacity; > + int ret; > > /* Request state should be less than max_level */ > if (WARN_ON(state > cpufreq_cdev->max_level)) > @@ -441,8 +445,19 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, > > cpufreq_cdev->cpufreq_state = state; > > - return freq_qos_update_request(&cpufreq_cdev->qos_req, > - get_state_freq(cpufreq_cdev, state)); > + frequency = get_state_freq(cpufreq_cdev, state); > + > + ret = freq_qos_update_request(&cpufreq_cdev->qos_req, frequency); > + > + if (ret > 0) { > + cpus = cpufreq_cdev->policy->cpus; > + capacity = frequency * > + arch_scale_cpu_capacity(cpumask_first(cpus)); > + capacity /= cpufreq_cdev->policy->cpuinfo.max_freq; > + arch_set_thermal_pressure(cpus, capacity);
Given that you already get a CPU's capacity (orig) here, why don't you pass thermal pressure directly to arch_set_thermal_pressure, rather than passing the capped capacity and subtracting it later from the same CPU capacity (arch_scale_cpu_capacity)?
If my math is correct this would work nicely: pressure = cpufreq_cdev->policy->cpuinfo.max_freq; pressure -= frequency; pressure *= arch_scale_cpu_capacity(cpumask_first(cpus); pressure /= cpufreq_cdev->policy->cpuinfo.max_freq;
Thanks, Ionela.
> + } > + > + return ret; > } > > /* Bind cpufreq callbacks to thermal cooling device ops */ > -- > 2.1.4 >
|  |