diff mbox series

[v1] PM: EM: Decrement policy counter

Message ID 20220426144448.43682-1-pierre.gondois@arm.com
State Accepted
Commit c9d8923bfbcb63f15ea6cb2b5c8426fc3d96f643
Headers show
Series [v1] PM: EM: Decrement policy counter | expand

Commit Message

Pierre Gondois April 26, 2022, 2:44 p.m. UTC
From: Pierre Gondois <Pierre.Gondois@arm.com>

Fixes: e458716a92b57 ("PM: EM: Mark inefficiencies in CPUFreq")
In the above commit, cpufreq_cpu_get() is called without
a cpufreq_cpu_put(), permanently increasing the reference counts
of the policy struct.
Decrement the reference count once the policy struct is not used
anymore.

Tested-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 kernel/power/energy_model.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Vincent Donnefort April 26, 2022, 3:40 p.m. UTC | #1
On 26/04/2022 15:44, Pierre Gondois wrote:
> From: Pierre Gondois <Pierre.Gondois@arm.com>
> 
> Fixes: e458716a92b57 ("PM: EM: Mark inefficiencies in CPUFreq")
> In the above commit, cpufreq_cpu_get() is called without
> a cpufreq_cpu_put(), permanently increasing the reference counts
> of the policy struct.
> Decrement the reference count once the policy struct is not used
> anymore.


Not sure if the tag there will be caught properly. Usually it goes on
top of the Signed-off-by.

While at it:

Reviewed-by: Vincent Donnefort <vincent.donnefort@arm.com>

Thanks for fixing this.

> 
> Tested-by: Cristian Marussi <cristian.marussi@arm.com>
> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
> ---
>   kernel/power/energy_model.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
> index 0153b0ca7b23..6219aaa454b5 100644
> --- a/kernel/power/energy_model.c
> +++ b/kernel/power/energy_model.c
> @@ -259,6 +259,8 @@ static void em_cpufreq_update_efficiencies(struct device *dev)
>   			found++;
>   	}
>   
> +	cpufreq_cpu_put(policy);
> +
>   	if (!found)
>   		return;
>
Rafael J. Wysocki May 11, 2022, 5:17 p.m. UTC | #2
On Tue, Apr 26, 2022 at 5:40 PM Vincent Donnefort
<vincent.donnefort@arm.com> wrote:
>
> On 26/04/2022 15:44, Pierre Gondois wrote:
> > From: Pierre Gondois <Pierre.Gondois@arm.com>
> >
> > Fixes: e458716a92b57 ("PM: EM: Mark inefficiencies in CPUFreq")
> > In the above commit, cpufreq_cpu_get() is called without
> > a cpufreq_cpu_put(), permanently increasing the reference counts
> > of the policy struct.
> > Decrement the reference count once the policy struct is not used
> > anymore.
>
>
> Not sure if the tag there will be caught properly. Usually it goes on
> top of the Signed-off-by.
>
> While at it:
>
> Reviewed-by: Vincent Donnefort <vincent.donnefort@arm.com>
>
> Thanks for fixing this.

Applied as 5.19 material, thanks!
diff mbox series

Patch

diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
index 0153b0ca7b23..6219aaa454b5 100644
--- a/kernel/power/energy_model.c
+++ b/kernel/power/energy_model.c
@@ -259,6 +259,8 @@  static void em_cpufreq_update_efficiencies(struct device *dev)
 			found++;
 	}
 
+	cpufreq_cpu_put(policy);
+
 	if (!found)
 		return;