From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Jiri Olsa <jolsa@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
David Ahern <dsahern@gmail.com>,
Stephane Eranian <eranian@google.com>,
Andi Kleen <andi@firstfloor.org>, Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 10/21] perf hists: Add helper functions for hierarchy mode
Date: Tue, 2 Feb 2016 23:39:52 +0900 [thread overview]
Message-ID: <1454424003-19031-11-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1454424003-19031-1-git-send-email-namhyung@kernel.org>
The rb_hierarchy_{next,prev,last} functions are to traverse all
hist entries in a hierarchy. They will be used by various function
which supports hierarchy output.
Acked-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/hist.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/hist.h | 8 ++++++++
2 files changed, 53 insertions(+)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index b0840f9bfe98..3d9709473b0c 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1416,6 +1416,51 @@ void hists__output_resort(struct hists *hists, struct ui_progress *prog)
}
}
+struct rb_node *rb_hierarchy_last(struct rb_node *node)
+{
+ struct hist_entry *he = rb_entry(node, struct hist_entry, rb_node);
+
+ while (he->unfolded && !he->leaf) {
+ node = rb_last(&he->hroot_out);
+ he = rb_entry(node, struct hist_entry, rb_node);
+ }
+ return node;
+}
+
+struct rb_node *rb_hierarchy_next(struct rb_node *node)
+{
+ struct hist_entry *he = rb_entry(node, struct hist_entry, rb_node);
+
+ if (!he->leaf && he->unfolded)
+ node = rb_first(&he->hroot_out);
+ else
+ node = rb_next(node);
+
+ while (node == NULL) {
+ he = he->parent_he;
+ if (he == NULL)
+ break;
+
+ node = rb_next(&he->rb_node);
+ }
+ return node;
+}
+
+struct rb_node *rb_hierarchy_prev(struct rb_node *node)
+{
+ struct hist_entry *he = rb_entry(node, struct hist_entry, rb_node);
+
+ node = rb_prev(node);
+ if (node)
+ return rb_hierarchy_last(node);
+
+ he = he->parent_he;
+ if (he == NULL)
+ return NULL;
+
+ return &he->rb_node;
+}
+
static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h,
enum hist_filter filter)
{
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 9c72f8331d1c..487cb677d48e 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -381,4 +381,12 @@ int parse_filter_percentage(const struct option *opt __maybe_unused,
const char *arg, int unset __maybe_unused);
int perf_hist_config(const char *var, const char *value);
+#define HIERARCHY_INDENT 3
+
+int perf_hpp__count_sort_keys(void);
+
+struct rb_node *rb_hierarchy_last(struct rb_node *node);
+struct rb_node *rb_hierarchy_next(struct rb_node *node);
+struct rb_node *rb_hierarchy_prev(struct rb_node *node);
+
#endif /* __PERF_HIST_H */
--
2.6.4
next prev parent reply other threads:[~2016-02-02 14:41 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-02 14:39 [PATCHSET 00/21] perf tools: Add support for hierachy view (v4) Namhyung Kim
2016-02-02 14:39 ` [PATCH 01/21] perf callchain: Check return value of add_child() Namhyung Kim
2016-02-02 14:39 ` [PATCH 02/21] perf callchain: Check return value of fill_node() Namhyung Kim
2016-02-02 14:39 ` [PATCH 03/21] perf callchain: Add enum match_result for match_chain() Namhyung Kim
2016-02-02 14:39 ` [PATCH 04/21] perf callchain: Check return value of split_add_child() Namhyung Kim
2016-02-02 14:39 ` [PATCH 05/21] perf callchain: Check return value of append_chain_children() Namhyung Kim
2016-02-02 14:39 ` [PATCH 06/21] perf hists: Return error from hists__collapse_resort() Namhyung Kim
2016-02-02 16:52 ` Arnaldo Carvalho de Melo
2016-02-02 16:56 ` Arnaldo Carvalho de Melo
2016-02-03 14:10 ` Namhyung Kim
2016-02-02 14:39 ` [PATCH 07/21] perf report: Check error during report__collapse_hists() Namhyung Kim
2016-02-02 14:39 ` [PATCH 08/21] perf hists: Basic support of hierarchical report view Namhyung Kim
2016-02-02 14:39 ` [PATCH 09/21] perf hists: Resort hist entries with hierarchy Namhyung Kim
2016-02-02 14:39 ` Namhyung Kim [this message]
2016-02-02 14:39 ` [PATCH 11/21] perf hists: Support filtering in hierarchy mode Namhyung Kim
2016-02-02 14:39 ` [PATCH 12/21] perf ui/stdio: Implement hierarchy output mode Namhyung Kim
2016-02-02 14:39 ` [PATCH 13/21] perf ui/stdio: Align column header for hierarchy output Namhyung Kim
2016-02-02 14:39 ` [PATCH 14/21] perf hists browser: Count number of hierarchy entries Namhyung Kim
2016-02-02 14:39 ` [PATCH 15/21] perf hists browser: Support collapsing/expanding whole entries in hierarchy Namhyung Kim
2016-02-02 14:39 ` [PATCH 16/21] perf hists browser: Implement hierarchy output Namhyung Kim
2016-02-02 14:39 ` [PATCH 17/21] perf hists browser: Align column header in hierarchy mode Namhyung Kim
2016-02-02 14:40 ` [PATCH 18/21] perf ui/gtk: Implement hierarchy output mode Namhyung Kim
2016-02-02 14:40 ` [PATCH 19/21] perf report: Add --hierarchy option Namhyung Kim
2016-02-02 14:40 ` [PATCH 20/21] perf hists: Support decaying in hierarchy mode Namhyung Kim
2016-02-02 14:40 ` [PATCH 21/21] perf top: Add --hierarchy option Namhyung Kim
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=1454424003-19031-11-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=andi@firstfloor.org \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=wangnan0@huawei.com \
/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
all inboxes | Powered by JetHome®