* [PATCH] perf evsel: Fix memory leaks on evsel->counts
@ 2013-01-25 1:44 Namhyung Kim
2013-01-25 2:45 ` Arnaldo Carvalho de Melo
2013-01-31 10:57 ` [tip:perf/core] " tip-bot for Namhyung Kim
0 siblings, 2 replies; 4+ messages in thread
From: Namhyung Kim @ 2013-01-25 1:44 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML, Namhyung Kim,
Stephane Eranian
From: Namhyung Kim <namhyung.kim@lge.com>
The ->counts field was never freed in the current code. Add
perf_evsel__free_counts() function to free it properly.
Cc: Stephane Eranian <eranian@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
This patch is based on Stephane's interval printing patchset v6.
tools/perf/builtin-stat.c | 1 +
tools/perf/tests/open-syscall-all-cpus.c | 1 +
tools/perf/util/evsel.c | 5 +++++
tools/perf/util/evsel.h | 1 +
4 files changed, 8 insertions(+)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 493043abd164..0368a1036ad6 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1372,6 +1372,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
out_free_fd:
list_for_each_entry(pos, &evsel_list->entries, node) {
perf_evsel__free_stat_priv(pos);
+ perf_evsel__free_counts(pos);
perf_evsel__free_prev_raw_counts(pos);
}
perf_evlist__delete_maps(evsel_list);
diff --git a/tools/perf/tests/open-syscall-all-cpus.c b/tools/perf/tests/open-syscall-all-cpus.c
index 9b920a0cce79..b0657a9ccda6 100644
--- a/tools/perf/tests/open-syscall-all-cpus.c
+++ b/tools/perf/tests/open-syscall-all-cpus.c
@@ -98,6 +98,7 @@ int test__open_syscall_event_on_all_cpus(void)
}
}
+ perf_evsel__free_counts(evsel);
out_close_fd:
perf_evsel__close_fd(evsel, 1, threads->nr);
out_evsel_delete:
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index dbdcca43cac6..baa26ddbcc7b 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -640,6 +640,11 @@ void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
}
}
+void perf_evsel__free_counts(struct perf_evsel *evsel)
+{
+ free(evsel->counts);
+}
+
void perf_evsel__exit(struct perf_evsel *evsel)
{
assert(list_empty(&evsel->node));
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 3a4cd60044ea..cbf42322a27e 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -117,6 +117,7 @@ int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus);
void perf_evsel__free_fd(struct perf_evsel *evsel);
void perf_evsel__free_id(struct perf_evsel *evsel);
+void perf_evsel__free_counts(struct perf_evsel *evsel);
void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
void __perf_evsel__set_sample_bit(struct perf_evsel *evsel,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] perf evsel: Fix memory leaks on evsel->counts
2013-01-25 1:44 [PATCH] perf evsel: Fix memory leaks on evsel->counts Namhyung Kim
@ 2013-01-25 2:45 ` Arnaldo Carvalho de Melo
2013-01-29 16:26 ` Arnaldo Carvalho de Melo
2013-01-31 10:57 ` [tip:perf/core] " tip-bot for Namhyung Kim
1 sibling, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-01-25 2:45 UTC (permalink / raw)
To: Namhyung Kim
Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML, Namhyung Kim,
Stephane Eranian
Em Fri, Jan 25, 2013 at 10:44:44AM +0900, Namhyung Kim escreveu:
> From: Namhyung Kim <namhyung.kim@lge.com>
>
> The ->counts field was never freed in the current code. Add
> perf_evsel__free_counts() function to free it properly.
I still haven't applied Stephane's patches, that his one depends on,
will do it tomorrow.
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf evsel: Fix memory leaks on evsel->counts
2013-01-25 2:45 ` Arnaldo Carvalho de Melo
@ 2013-01-29 16:26 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-01-29 16:26 UTC (permalink / raw)
To: Namhyung Kim
Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML, Namhyung Kim,
Stephane Eranian
Em Thu, Jan 24, 2013 at 11:45:58PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Jan 25, 2013 at 10:44:44AM +0900, Namhyung Kim escreveu:
> > From: Namhyung Kim <namhyung.kim@lge.com>
> >
> > The ->counts field was never freed in the current code. Add
> > perf_evsel__free_counts() function to free it properly.
>
> I still haven't applied Stephane's patches, that his one depends on,
> will do it tomorrow.
Done, applied, thanks!
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip:perf/core] perf evsel: Fix memory leaks on evsel->counts
2013-01-25 1:44 [PATCH] perf evsel: Fix memory leaks on evsel->counts Namhyung Kim
2013-01-25 2:45 ` Arnaldo Carvalho de Melo
@ 2013-01-31 10:57 ` tip-bot for Namhyung Kim
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Namhyung Kim @ 2013-01-31 10:57 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, eranian, paulus, hpa, mingo, a.p.zijlstra,
namhyung.kim, namhyung, tglx
Commit-ID: 43f8e76e6b96eb1327cff62ac1cc733a51f31068
Gitweb: http://git.kernel.org/tip/43f8e76e6b96eb1327cff62ac1cc733a51f31068
Author: Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Fri, 25 Jan 2013 10:44:44 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 30 Jan 2013 10:37:04 -0300
perf evsel: Fix memory leaks on evsel->counts
The ->counts field was never freed in the current code. Add
perf_evsel__free_counts() function to free it properly.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1359078284-32080-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-stat.c | 1 +
tools/perf/tests/open-syscall-all-cpus.c | 1 +
tools/perf/util/evsel.c | 5 +++++
tools/perf/util/evsel.h | 1 +
4 files changed, 8 insertions(+)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 493043a..0368a10 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1372,6 +1372,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
out_free_fd:
list_for_each_entry(pos, &evsel_list->entries, node) {
perf_evsel__free_stat_priv(pos);
+ perf_evsel__free_counts(pos);
perf_evsel__free_prev_raw_counts(pos);
}
perf_evlist__delete_maps(evsel_list);
diff --git a/tools/perf/tests/open-syscall-all-cpus.c b/tools/perf/tests/open-syscall-all-cpus.c
index 9b920a0..b0657a9 100644
--- a/tools/perf/tests/open-syscall-all-cpus.c
+++ b/tools/perf/tests/open-syscall-all-cpus.c
@@ -98,6 +98,7 @@ int test__open_syscall_event_on_all_cpus(void)
}
}
+ perf_evsel__free_counts(evsel);
out_close_fd:
perf_evsel__close_fd(evsel, 1, threads->nr);
out_evsel_delete:
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index dbdcca4..baa26dd 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -640,6 +640,11 @@ void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
}
}
+void perf_evsel__free_counts(struct perf_evsel *evsel)
+{
+ free(evsel->counts);
+}
+
void perf_evsel__exit(struct perf_evsel *evsel)
{
assert(list_empty(&evsel->node));
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 3a4cd60..cbf4232 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -117,6 +117,7 @@ int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus);
void perf_evsel__free_fd(struct perf_evsel *evsel);
void perf_evsel__free_id(struct perf_evsel *evsel);
+void perf_evsel__free_counts(struct perf_evsel *evsel);
void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
void __perf_evsel__set_sample_bit(struct perf_evsel *evsel,
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-31 10:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-25 1:44 [PATCH] perf evsel: Fix memory leaks on evsel->counts Namhyung Kim
2013-01-25 2:45 ` Arnaldo Carvalho de Melo
2013-01-29 16:26 ` Arnaldo Carvalho de Melo
2013-01-31 10:57 ` [tip:perf/core] " tip-bot for Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).