linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: adrian.hunter@intel.com, andi@firstfloor.org,
	a.p.zijlstra@chello.nl, fweisbec@gmail.com, namhyung@kernel.org,
	acme@redhat.com, masami.hiramatsu.pt@hitachi.com, hpa@zytor.com,
	tglx@linutronix.de, eranian@google.com, jolsa@redhat.com,
	mingo@kernel.org, dsahern@gmail.com,
	linux-kernel@vger.kernel.org
Subject: [tip:perf/core] perf top: Delete half-processed hist entries when exit
Date: Mon, 14 Dec 2015 00:15:10 -0800	[thread overview]
Message-ID: <tip-61fa0e94ca6ab62db5e095a5528150bf9962196d@git.kernel.org> (raw)
In-Reply-To: <1449734015-9148-2-git-send-email-namhyung@kernel.org>

Commit-ID:  61fa0e94ca6ab62db5e095a5528150bf9962196d
Gitweb:     http://git.kernel.org/tip/61fa0e94ca6ab62db5e095a5528150bf9962196d
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Thu, 10 Dec 2015 16:53:20 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 10 Dec 2015 15:56:58 -0300

perf top: Delete half-processed hist entries when exit

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.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-and-Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1449734015-9148-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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 565ea35..56e97f5 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);
 }
 
 /*

  parent reply	other threads:[~2015-12-14  8:15 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10  7:53 [PATCHSET 00/16] perf top: Add multi-thread support (v1) Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 01/16] perf top: Delete half-processed hist entries when exit Namhyung Kim
2015-12-10  9:55   ` 平松雅巳 / HIRAMATU,MASAMI
2015-12-10 18:57     ` Arnaldo Carvalho de Melo
2015-12-14  8:15   ` tip-bot for Namhyung Kim [this message]
2015-12-10  7:53 ` [PATCH/RFC 02/16] perf top: Fix and cleanup perf_top__record_precise_ip() Namhyung Kim
2015-12-10 19:04   ` Arnaldo Carvalho de Melo
2015-12-11  2:27     ` Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 03/16] perf top: Factor out warnings about kernel addresses and symbols Namhyung Kim
2015-12-10 19:07   ` Arnaldo Carvalho de Melo
2015-12-14  1:44     ` Namhyung Kim
2015-12-14  2:02       ` Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 04/16] perf top: Factor out warnings in perf_top__record_precise_ip() Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 05/16] perf top: Show warning messages in the display thread Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 06/16] perf top: Get rid of access to hists->lock in perf_top__record_precise_ip() Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 07/16] perf hists: Pass hists struct to hist_entry_iter struct Namhyung Kim
2015-12-13 23:15   ` Jiri Olsa
2015-12-14  1:45     ` Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 08/16] perf tools: Export a couple of hist functions Namhyung Kim
2015-12-13 23:17   ` Jiri Olsa
2015-12-10  7:53 ` [PATCH/RFC 09/16] perf tools: Update hist entry's hists pointer Namhyung Kim
2015-12-13 23:23   ` Jiri Olsa
2015-12-13 23:28     ` Jiri Olsa
2015-12-14  1:51       ` Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 10/16] perf hist: Add events_stats__add() and hists__add_stats() Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 11/16] perf top: Implement basic parallel processing Namhyung Kim
2015-12-14  9:23   ` Jiri Olsa
2015-12-14  9:35     ` Jiri Olsa
2015-12-15  2:08       ` Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 12/16] perf tools: Reduce lock contention when processing events Namhyung Kim
2015-12-14  8:43   ` Jiri Olsa
2015-12-15  2:03     ` Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 13/16] perf top: Protect the seen list using mutex Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 14/16] perf top: Separate struct perf_top_stats Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 15/16] perf top: Add --num-thread option Namhyung Kim
2015-12-10  7:53 ` [PATCH/RFC 16/16] perf tools: Skip dso front cache for multi-threaded lookup Namhyung Kim
2015-12-10  8:01 ` [PATCHSET 00/16] perf top: Add multi-thread support (v1) Ingo Molnar
2015-12-10  8:49   ` Namhyung Kim
2015-12-11  8:11     ` Ingo Molnar
2015-12-11 15:01       ` David Ahern
2015-12-14  1:12         ` Namhyung Kim
2015-12-14  9:26         ` Peter Zijlstra
2015-12-14  9:38           ` Ingo Molnar
2015-12-14 14:55             ` David Ahern
2015-12-14 16:26               ` Arnaldo Carvalho de Melo
2015-12-14 16:41                 ` Peter Zijlstra
2015-12-14 17:52                   ` Arnaldo Carvalho de Melo
2015-12-14 16:38             ` Namhyung Kim
2015-12-14 16:56               ` Peter Zijlstra
2015-12-14 17:11                 ` Namhyung Kim
2015-12-14 14:46           ` David Ahern
2015-12-14 17:06             ` Namhyung Kim
2015-12-14 17:54               ` Arnaldo Carvalho de Melo
2015-12-14 16:25           ` Namhyung Kim
2015-12-14 16:44             ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-61fa0e94ca6ab62db5e095a5528150bf9962196d@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).