diff mbox series

[3/5] cpufreq: qcom-cpufreq-hw: Update offline CPUs per-cpu thermal pressure

Message ID 20211007080729.8262-4-lukasz.luba@arm.com (mailing list archive)
State Superseded
Headers show
Series Refactor thermal pressure update to avoid code duplication | expand

Commit Message

Lukasz Luba Oct. 7, 2021, 8:07 a.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 there is throttling
or throttling is removed.

Fixes: 275157b367f479 ("cpufreq: qcom-cpufreq-hw: Add dcvs interrupt support")
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 drivers/cpufreq/qcom-cpufreq-hw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Thara Gopinath Oct. 11, 2021, 9:17 p.m. UTC | #1
On 10/7/21 4:07 AM, 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 there is throttling
> or throttling is removed.
> 
> Fixes: 275157b367f479 ("cpufreq: qcom-cpufreq-hw: Add dcvs interrupt support")
> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>

Thanks for the fix.

Reviewed-by: Thara Gopinath <thara.gopinath@linaro.org>

> ---
>   drivers/cpufreq/qcom-cpufreq-hw.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
> index a2be0df7e174..0138b2ec406d 100644
> --- a/drivers/cpufreq/qcom-cpufreq-hw.c
> +++ b/drivers/cpufreq/qcom-cpufreq-hw.c
> @@ -304,7 +304,8 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data)
>   	if (capacity > max_capacity)
>   		capacity = max_capacity;
>   
> -	arch_set_thermal_pressure(policy->cpus, max_capacity - capacity);
> +	arch_set_thermal_pressure(policy->related_cpus,
> +				  max_capacity - capacity);
>   
>   	/*
>   	 * In the unlikely case policy is unregistered do not enable
>
Lukasz Luba Oct. 15, 2021, 12:13 p.m. UTC | #2
On 10/11/21 10:17 PM, Thara Gopinath wrote:
> 
> 
> On 10/7/21 4:07 AM, 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 there is throttling
>> or throttling is removed.
>>
>> Fixes: 275157b367f479 ("cpufreq: qcom-cpufreq-hw: Add dcvs interrupt 
>> support")
>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> 
> Thanks for the fix.
> 
> Reviewed-by: Thara Gopinath <thara.gopinath@linaro.org>
> 

Thank you for the review!
diff mbox series

Patch

diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
index a2be0df7e174..0138b2ec406d 100644
--- a/drivers/cpufreq/qcom-cpufreq-hw.c
+++ b/drivers/cpufreq/qcom-cpufreq-hw.c
@@ -304,7 +304,8 @@  static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data)
 	if (capacity > max_capacity)
 		capacity = max_capacity;
 
-	arch_set_thermal_pressure(policy->cpus, max_capacity - capacity);
+	arch_set_thermal_pressure(policy->related_cpus,
+				  max_capacity - capacity);
 
 	/*
 	 * In the unlikely case policy is unregistered do not enable