diff mbox series

[v3,1/3] thermal: cpufreq_cooling: Update also offline CPUs per-cpu thermal_pressure

Message ID 20210610150324.22919-2-lukasz.luba@arm.com
State Superseded
Headers show
Series Add allowed CPU capacity knowledge to EAS | expand

Commit Message

Lukasz Luba June 10, 2021, 3:03 p.m. UTC
The thermal pressure signal gives information to the scheduler about
reduced CPU capacity due to thermal. It is based on a value stored in a
per-cpu 'thermal_pressure' variable. The online CPUs will get the new
value there, while the offline won't. Unfortunately, when the CPU is back
online, the value read from per-cpu variable might be wrong (stale data).
This might affect the scheduler decisions, since it sees the CPU capacity
differently than what is actually available.

Fix it by making sure that all online+offline CPUs would get the proper
value in their per-cpu variable when thermal framework sets capping.

Fixes: f12e4f66ab6a3 ("thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping")
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 drivers/thermal/cpufreq_cooling.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Viresh Kumar June 14, 2021, 10:12 a.m. UTC | #1
On 10-06-21, 16:03, Lukasz Luba wrote:
> The thermal pressure signal gives information to the scheduler about

> reduced CPU capacity due to thermal. It is based on a value stored in a

> per-cpu 'thermal_pressure' variable. The online CPUs will get the new

> value there, while the offline won't. Unfortunately, when the CPU is back

> online, the value read from per-cpu variable might be wrong (stale data).

> This might affect the scheduler decisions, since it sees the CPU capacity

> differently than what is actually available.

> 

> Fix it by making sure that all online+offline CPUs would get the proper

> value in their per-cpu variable when thermal framework sets capping.

> 

> Fixes: f12e4f66ab6a3 ("thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping")

> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>

> ---

>  drivers/thermal/cpufreq_cooling.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c

> index eeb4e4b76c0b..43b1ae8a7789 100644

> --- a/drivers/thermal/cpufreq_cooling.c

> +++ b/drivers/thermal/cpufreq_cooling.c

> @@ -478,7 +478,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,

>  	ret = freq_qos_update_request(&cpufreq_cdev->qos_req, frequency);

>  	if (ret >= 0) {

>  		cpufreq_cdev->cpufreq_state = state;

> -		cpus = cpufreq_cdev->policy->cpus;

> +		cpus = cpufreq_cdev->policy->related_cpus;

>  		max_capacity = arch_scale_cpu_capacity(cpumask_first(cpus));

>  		capacity = frequency * max_capacity;

>  		capacity /= cpufreq_cdev->policy->cpuinfo.max_freq;


Acked-by: Viresh Kumar <viresh.kumar@linaro.org>


-- 
viresh
Lukasz Luba June 14, 2021, 10:21 a.m. UTC | #2
On 6/14/21 11:12 AM, Viresh Kumar wrote:
> On 10-06-21, 16:03, Lukasz Luba wrote:

>> The thermal pressure signal gives information to the scheduler about

>> reduced CPU capacity due to thermal. It is based on a value stored in a

>> per-cpu 'thermal_pressure' variable. The online CPUs will get the new

>> value there, while the offline won't. Unfortunately, when the CPU is back

>> online, the value read from per-cpu variable might be wrong (stale data).

>> This might affect the scheduler decisions, since it sees the CPU capacity

>> differently than what is actually available.

>>

>> Fix it by making sure that all online+offline CPUs would get the proper

>> value in their per-cpu variable when thermal framework sets capping.

>>

>> Fixes: f12e4f66ab6a3 ("thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping")

>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>

>> ---

>>   drivers/thermal/cpufreq_cooling.c | 2 +-

>>   1 file changed, 1 insertion(+), 1 deletion(-)

>>

>> diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c

>> index eeb4e4b76c0b..43b1ae8a7789 100644

>> --- a/drivers/thermal/cpufreq_cooling.c

>> +++ b/drivers/thermal/cpufreq_cooling.c

>> @@ -478,7 +478,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,

>>   	ret = freq_qos_update_request(&cpufreq_cdev->qos_req, frequency);

>>   	if (ret >= 0) {

>>   		cpufreq_cdev->cpufreq_state = state;

>> -		cpus = cpufreq_cdev->policy->cpus;

>> +		cpus = cpufreq_cdev->policy->related_cpus;

>>   		max_capacity = arch_scale_cpu_capacity(cpumask_first(cpus));

>>   		capacity = frequency * max_capacity;

>>   		capacity /= cpufreq_cdev->policy->cpuinfo.max_freq;

> 

> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

> 


Thank you Viresh!

Regards,
Lukasz
diff mbox series

Patch

diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c
index eeb4e4b76c0b..43b1ae8a7789 100644
--- a/drivers/thermal/cpufreq_cooling.c
+++ b/drivers/thermal/cpufreq_cooling.c
@@ -478,7 +478,7 @@  static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
 	ret = freq_qos_update_request(&cpufreq_cdev->qos_req, frequency);
 	if (ret >= 0) {
 		cpufreq_cdev->cpufreq_state = state;
-		cpus = cpufreq_cdev->policy->cpus;
+		cpus = cpufreq_cdev->policy->related_cpus;
 		max_capacity = arch_scale_cpu_capacity(cpumask_first(cpus));
 		capacity = frequency * max_capacity;
 		capacity /= cpufreq_cdev->policy->cpuinfo.max_freq;