[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <50399556C9727B4D88A595C8584AAB375264F907@GSjpTKYDCembx32.service.hitachi.net>
Date: Thu, 10 Dec 2015 09:55:44 +0000
From: 平松雅巳 / HIRAMATU,MASAMI
<masami.hiramatsu.pt@...achi.com>
To: "'Namhyung Kim'" <namhyung@...nel.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>
CC: Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Jiri Olsa <jolsa@...hat.com>,
LKML <linux-kernel@...r.kernel.org>,
"David Ahern" <dsahern@...il.com>,
Frederic Weisbecker <fweisbec@...il.com>,
"Andi Kleen" <andi@...stfloor.org>,
Stephane Eranian <eranian@...gle.com>,
"Adrian Hunter" <adrian.hunter@...el.com>
Subject: RE: [PATCH/RFC 01/16] perf top: Delete half-processed hist entries
when exit
>From: Namhyung Kim [mailto:namhyung@...nel.org]
>
>After sample processing is done, hist entries are in both of
>hists->entries and hists->entries_in (or hists->entries_collapsed).
>So I guess perf report does not have leaks on hists.
>
>But for perf top, it's possible to have half-processed entries which
>are only in hists->entries_in. Eventually they will go to the
>hists->entries and get freed but they cannot be deleted by current
>hists__delete_entries(). This patch adds hists__delete_all_entries
>function to delete those entries.
>
This is tested under the refcnt debugger and I've reviewed it.
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Thanks!
>Cc: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
>Signed-off-by: Namhyung Kim <namhyung@...nel.org>
>---
> tools/perf/util/hist.c | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
>
>diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
>index 565ea3549894..56e97f5af598 100644
>--- a/tools/perf/util/hist.c
>+++ b/tools/perf/util/hist.c
>@@ -270,6 +270,8 @@ static void hists__delete_entry(struct hists *hists, struct hist_entry *he)
>
> if (sort__need_collapse)
> rb_erase(&he->rb_node_in, &hists->entries_collapsed);
>+ else
>+ rb_erase(&he->rb_node_in, hists->entries_in);
>
> --hists->nr_entries;
> if (!he->filtered)
>@@ -1567,11 +1569,33 @@ static int hists_evsel__init(struct perf_evsel *evsel)
> return 0;
> }
>
>+static void hists__delete_remaining_entries(struct rb_root *root)
>+{
>+ struct rb_node *node;
>+ struct hist_entry *he;
>+
>+ while (!RB_EMPTY_ROOT(root)) {
>+ node = rb_first(root);
>+ rb_erase(node, root);
>+
>+ he = rb_entry(node, struct hist_entry, rb_node_in);
>+ hist_entry__delete(he);
>+ }
>+}
>+
>+static void hists__delete_all_entries(struct hists *hists)
>+{
>+ hists__delete_entries(hists);
>+ hists__delete_remaining_entries(&hists->entries_in_array[0]);
>+ hists__delete_remaining_entries(&hists->entries_in_array[1]);
>+ hists__delete_remaining_entries(&hists->entries_collapsed);
>+}
>+
> static void hists_evsel__exit(struct perf_evsel *evsel)
> {
> struct hists *hists = evsel__hists(evsel);
>
>- hists__delete_entries(hists);
>+ hists__delete_all_entries(hists);
> }
>
> /*
>--
>2.6.2
Powered by blists - more mailing lists