2022-04-26 21:13:08

by Pierre Gondois

[permalink] [raw]
Subject: [PATCH v1] PM: EM: Decrement policy counter

From: Pierre Gondois <[email protected]>

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 <[email protected]>
Signed-off-by: Pierre Gondois <[email protected]>
---
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;

--
2.25.1


2022-04-27 07:14:59

by Vincent Donnefort

[permalink] [raw]
Subject: Re: [PATCH v1] PM: EM: Decrement policy counter

On 26/04/2022 15:44, Pierre Gondois wrote:
> From: Pierre Gondois <[email protected]>
>
> 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 <[email protected]>

Thanks for fixing this.

>
> Tested-by: Cristian Marussi <[email protected]>
> Signed-off-by: Pierre Gondois <[email protected]>
> ---
> 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;
>

2022-05-11 23:16:43

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v1] PM: EM: Decrement policy counter

On Tue, Apr 26, 2022 at 5:40 PM Vincent Donnefort
<[email protected]> wrote:
>
> On 26/04/2022 15:44, Pierre Gondois wrote:
> > From: Pierre Gondois <[email protected]>
> >
> > 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 <[email protected]>
>
> Thanks for fixing this.

Applied as 5.19 material, thanks!