Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1411078 > unrolled thread
| Started by | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| First post | 2016-06-01 12:40 +0200 |
| Last post | 2016-06-02 14:10 +0200 |
| Articles | 6 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/8] cpufreq: powerenv: Fix memory leak Viresh Kumar <viresh.kumar@linaro.org> - 2016-06-01 12:40 +0200
Re: [PATCH 3/8] cpufreq: powerenv: Fix memory leak Michael Ellerman <mpe@ellerman.id.au> - 2016-06-02 13:10 +0200
Re: [PATCH 3/8] cpufreq: powerenv: Fix memory leak Viresh Kumar <viresh.kumar@linaro.org> - 2016-06-02 13:30 +0200
Re: [PATCH 3/8] cpufreq: powerenv: Fix memory leak Michael Ellerman <mpe@ellerman.id.au> - 2016-06-02 13:40 +0200
Re: [PATCH 3/8] cpufreq: powerenv: Fix memory leak Viresh Kumar <viresh.kumar@linaro.org> - 2016-06-02 13:50 +0200
Re: [PATCH 3/8] cpufreq: powerenv: Fix memory leak Michael Ellerman <mpe@ellerman.id.au> - 2016-06-02 14:10 +0200
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2016-06-01 12:40 +0200 |
| Subject | [PATCH 3/8] cpufreq: powerenv: Fix memory leak |
| Message-ID | <rFbJ7-7eG-21@gated-at.bofh.it> |
The policy is copied (unnecessarily) and is never freed. Fix it by just
getting a reference to the existing policy structure and putting it
back.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/powernv-cpufreq.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 54c45368e3f1..96bb4acd366e 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -756,15 +756,18 @@ void powernv_cpufreq_work_fn(struct work_struct *work)
chip->restore = false;
for_each_cpu(cpu, &mask) {
+ struct cpufreq_policy *policy = cpufreq_cpu_get(cpu)
int index;
- struct cpufreq_policy policy;
- cpufreq_get_policy(&policy, cpu);
- cpufreq_frequency_table_target(&policy, policy.freq_table,
- policy.cur,
+ if (!policy)
+ continue;
+
+ cpufreq_frequency_table_target(policy, policy->freq_table,
+ policy->cur,
CPUFREQ_RELATION_C, &index);
- powernv_cpufreq_target_index(&policy, index);
- cpumask_andnot(&mask, &mask, policy.cpus);
+ powernv_cpufreq_target_index(policy, index);
+ cpumask_andnot(&mask, &mask, policy->cpus);
+ cpufreq_cpu_put(policy);
}
out:
put_online_cpus();
--
2.7.1.410.g6faf27b
[toc] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2016-06-02 13:10 +0200 |
| Message-ID | <rFyFJ-5bR-31@gated-at.bofh.it> |
| In reply to | #1411078 |
On Wed, 2016-06-01 at 16:04 +0530, Viresh Kumar wrote: > The policy is copied (unnecessarily) and is never freed. Fix it by just > getting a reference to the existing policy structure and putting it > back. > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> When was it broken, always? Cc: stable ? cheers
[toc] | [prev] | [next] | [standalone]
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2016-06-02 13:30 +0200 |
| Message-ID | <rFyZ3-5ib-5@gated-at.bofh.it> |
| In reply to | #1412134 |
On 02-06-16, 21:08, Michael Ellerman wrote:
> On Wed, 2016-06-01 at 16:04 +0530, Viresh Kumar wrote:
>
> > The policy is copied (unnecessarily) and is never freed. Fix it by just
> > getting a reference to the existing policy structure and putting it
> > back.
> >
> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
>
> When was it broken, always?
>
> Cc: stable ?
Its a small memory leak and its not that we will fail on something. So
didn't bother to add those details, but in case they are required:
Cc: <stable@vger.kernel.org> # 4.3+
Fixes: 227942809b52 ("cpufreq: powernv: Restore cpu frequency to policy->cur on unthrottling")
--
viresh
[toc] | [prev] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2016-06-02 13:40 +0200 |
| Message-ID | <rFz8J-5lj-7@gated-at.bofh.it> |
| In reply to | #1412140 |
On Thu, 2016-06-02 at 16:52 +0530, Viresh Kumar wrote:
> On 02-06-16, 21:08, Michael Ellerman wrote:
> > On Wed, 2016-06-01 at 16:04 +0530, Viresh Kumar wrote:
> >
> > > The policy is copied (unnecessarily) and is never freed. Fix it by just
> > > getting a reference to the existing policy structure and putting it
> > > back.
> > >
> > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> >
> > When was it broken, always?
> >
> > Cc: stable ?
>
> Its a small memory leak and its not that we will fail on something. So
> didn't bother to add those details, but in case they are required:
>
> Cc: <stable@vger.kernel.org> # 4.3+
> Fixes: 227942809b52 ("cpufreq: powernv: Restore cpu frequency to policy->cur on unthrottling")
OK. I can't actually see where the copy is?
But if we are leaking even a small amount of memory in a loop like that, in a
function that's run semi-regularly, then it's going to add up eventually.
cheers
[toc] | [prev] | [next] | [standalone]
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2016-06-02 13:50 +0200 |
| Message-ID | <rFzip-5oX-23@gated-at.bofh.it> |
| In reply to | #1412141 |
On 02-06-16, 21:37, Michael Ellerman wrote:
> On Thu, 2016-06-02 at 16:52 +0530, Viresh Kumar wrote:
> > On 02-06-16, 21:08, Michael Ellerman wrote:
> > > On Wed, 2016-06-01 at 16:04 +0530, Viresh Kumar wrote:
> > >
> > > > The policy is copied (unnecessarily) and is never freed. Fix it by just
> > > > getting a reference to the existing policy structure and putting it
> > > > back.
> > > >
> > > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> > >
> > > When was it broken, always?
> > >
> > > Cc: stable ?
> >
> > Its a small memory leak and its not that we will fail on something. So
> > didn't bother to add those details, but in case they are required:
> >
> > Cc: <stable@vger.kernel.org> # 4.3+
> > Fixes: 227942809b52 ("cpufreq: powernv: Restore cpu frequency to policy->cur on unthrottling")
>
> OK. I can't actually see where the copy is?
>
> But if we are leaking even a small amount of memory in a loop like that, in a
> function that's run semi-regularly, then it's going to add up eventually.
Urg, it wasn't a memory leak actually. I misread.
I somehow thought that cpufreq_get_policy() is also allocating memory
for the policy, but it just memcpy's it into the callers buffer. So,
that's not a problem really.
This patch should be just dropped. Sorry for the noise.
--
viresh
[toc] | [prev] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2016-06-02 14:10 +0200 |
| Message-ID | <rFzBL-5Mk-5@gated-at.bofh.it> |
| In reply to | #1412149 |
On Thu, 2016-06-02 at 17:13 +0530, Viresh Kumar wrote:
> On 02-06-16, 21:37, Michael Ellerman wrote:
> > On Thu, 2016-06-02 at 16:52 +0530, Viresh Kumar wrote:
> > > On 02-06-16, 21:08, Michael Ellerman wrote:
> > > > On Wed, 2016-06-01 at 16:04 +0530, Viresh Kumar wrote:
> > > >
> > > > > The policy is copied (unnecessarily) and is never freed. Fix it by just
> > > > > getting a reference to the existing policy structure and putting it
> > > > > back.
> > > > >
> > > > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > >
> > > > When was it broken, always?
> > > >
> > > > Cc: stable ?
> > >
> > > Its a small memory leak and its not that we will fail on something. So
> > > didn't bother to add those details, but in case they are required:
> > >
> > > Cc: <stable@vger.kernel.org> # 4.3+
> > > Fixes: 227942809b52 ("cpufreq: powernv: Restore cpu frequency to policy->cur on unthrottling")
> >
> > OK. I can't actually see where the copy is?
> >
> > But if we are leaking even a small amount of memory in a loop like that, in a
> > function that's run semi-regularly, then it's going to add up eventually.
>
> Urg, it wasn't a memory leak actually. I misread.
>
> I somehow thought that cpufreq_get_policy() is also allocating memory
> for the policy, but it just memcpy's it into the callers buffer. So,
> that's not a problem really.
>
> This patch should be just dropped. Sorry for the noise.
OK, no worries.
cheers
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web