[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-70642850fa581df219d7bc03cd7aca6e1956968c@git.kernel.org>
Date: Wed, 24 Feb 2016 23:42:46 -0800
From: tip-bot for Namhyung Kim <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: acme@...hat.com, wangnan0@...wei.com, hpa@...or.com,
jolsa@...nel.org, dsahern@...il.com, namhyung@...nel.org,
peterz@...radead.org, tglx@...utronix.de, eranian@...gle.com,
mingo@...nel.org, andi@...stfloor.org, linux-kernel@...r.kernel.org
Subject: [tip:perf/core] perf hists: Resort after filtering hierarchy
Commit-ID: 70642850fa581df219d7bc03cd7aca6e1956968c
Gitweb: http://git.kernel.org/tip/70642850fa581df219d7bc03cd7aca6e1956968c
Author: Namhyung Kim <namhyung@...nel.org>
AuthorDate: Thu, 25 Feb 2016 00:13:39 +0900
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Wed, 24 Feb 2016 20:21:11 -0300
perf hists: Resort after filtering hierarchy
In hierarchy mode, a filter can affect periods of entries in upper
hierarchy. So it needs to resort the hists after filter.
For example, let's look at following example:
Overhead Command / Shared Object / Symbol
------------ --------------------------------
30.00% perf
20.00% perf
10.00% main
5.00% pr_debug
5.00% memcpy
10.00% [kernel.vmlinux]
8.00% memset
2.00% cpu_idle
If we apply simbol filter for 'mem' it should look like this
13.00% perf
8.00% [kernel.vmlinux]
8.00% memset
5.00% perf
5.00% memcpy
Signed-off-by: Namhyung Kim <namhyung@...nel.org>
Cc: Andi Kleen <andi@...stfloor.org>
Cc: David Ahern <dsahern@...il.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Stephane Eranian <eranian@...gle.com>
Cc: Wang Nan <wangnan0@...wei.com>
Link: http://lkml.kernel.org/r/1456326830-30456-8-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/hist.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index dbab977..a44bf5a 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1666,9 +1666,47 @@ static void hists__filter_by_type(struct hists *hists, int type, filter_fn_t fil
}
}
+static void resort_filtered_entry(struct rb_root *root, struct hist_entry *he)
+{
+ struct rb_node **p = &root->rb_node;
+ struct rb_node *parent = NULL;
+ struct hist_entry *iter;
+ struct rb_root new_root = RB_ROOT;
+ struct rb_node *nd;
+
+ while (*p != NULL) {
+ parent = *p;
+ iter = rb_entry(parent, struct hist_entry, rb_node);
+
+ if (hist_entry__sort(he, iter) > 0)
+ p = &(*p)->rb_left;
+ else
+ p = &(*p)->rb_right;
+ }
+
+ rb_link_node(&he->rb_node, parent, p);
+ rb_insert_color(&he->rb_node, root);
+
+ if (he->leaf || he->filtered)
+ return;
+
+ nd = rb_first(&he->hroot_out);
+ while (nd) {
+ struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
+
+ nd = rb_next(nd);
+ rb_erase(&h->rb_node, &he->hroot_out);
+
+ resort_filtered_entry(&new_root, h);
+ }
+
+ he->hroot_out = new_root;
+}
+
static void hists__filter_hierarchy(struct hists *hists, int type, const void *arg)
{
struct rb_node *nd;
+ struct rb_root new_root = RB_ROOT;
hists->stats.nr_non_filtered_samples = 0;
@@ -1712,6 +1750,22 @@ static void hists__filter_hierarchy(struct hists *hists, int type, const void *a
nd = __rb_hierarchy_next(&h->rb_node, HMD_FORCE_SIBLING);
}
}
+
+ /*
+ * resort output after applying a new filter since filter in a lower
+ * hierarchy can change periods in a upper hierarchy.
+ */
+ nd = rb_first(&hists->entries);
+ while (nd) {
+ struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
+
+ nd = rb_next(nd);
+ rb_erase(&h->rb_node, &hists->entries);
+
+ resort_filtered_entry(&new_root, h);
+ }
+
+ hists->entries = new_root;
}
void hists__filter_by_thread(struct hists *hists)
Powered by blists - more mailing lists