From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: andi@firstfloor.org, acme@redhat.com, mingo@kernel.org,
eranian@google.com, namhyung@kernel.org, tglx@linutronix.de,
wangnan0@huawei.com, dsahern@gmail.com, jolsa@kernel.org,
peterz@infradead.org, hpa@zytor.com,
linux-kernel@vger.kernel.org
Subject: [tip:perf/core] perf hists: Add more helper functions for the hierarchy mode
Date: Sat, 27 Feb 2016 01:41:19 -0800 [thread overview]
Message-ID: <tip-a7b5895b91fb97f2b0dcc2e3ce47413c18d19ca5@git.kernel.org> (raw)
In-Reply-To: <1456488800-28124-1-git-send-email-namhyung@kernel.org>
Commit-ID: a7b5895b91fb97f2b0dcc2e3ce47413c18d19ca5
Gitweb: http://git.kernel.org/tip/a7b5895b91fb97f2b0dcc2e3ce47413c18d19ca5
Author: Namhyung Kim <namhyung@kernel.org>
AuthorDate: Fri, 26 Feb 2016 21:13:16 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 26 Feb 2016 11:20:35 -0300
perf hists: Add more helper functions for the hierarchy mode
The hists__overhead_width() is to calculate width occupied by the
overhead (and others) columns before the sort columns.
The hist_entry__has_hiearchy_children() is to check whether an entry has
lower entries (children) in the hierarchy to be shown in the output.
This means the children should not be filtered out and above the percent
limit.
These two functions will be used to show information when all children
of an entry is omitted by the percent limit (or filter).
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1456488800-28124-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/ui/hist.c | 22 ++++++++++++++++++++++
tools/perf/util/hist.c | 25 +++++++++++++++++++++++++
tools/perf/util/hist.h | 3 +++
3 files changed, 50 insertions(+)
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index edbf854..7c0585c 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -643,6 +643,28 @@ unsigned int hists__sort_list_width(struct hists *hists)
return ret;
}
+unsigned int hists__overhead_width(struct hists *hists)
+{
+ struct perf_hpp_fmt *fmt;
+ int ret = 0;
+ bool first = true;
+ struct perf_hpp dummy_hpp;
+
+ hists__for_each_format(hists, fmt) {
+ if (perf_hpp__is_sort_entry(fmt) || perf_hpp__is_dynamic_entry(fmt))
+ break;
+
+ if (first)
+ first = false;
+ else
+ ret += 2;
+
+ ret += fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists));
+ }
+
+ return ret;
+}
+
void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists)
{
if (perf_hpp__is_sort_entry(fmt))
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 1c53042..e716919 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1582,6 +1582,31 @@ struct rb_node *rb_hierarchy_prev(struct rb_node *node)
return &he->rb_node;
}
+bool hist_entry__has_hierarchy_children(struct hist_entry *he, float limit)
+{
+ struct rb_node *node;
+ struct hist_entry *child;
+ float percent;
+
+ if (he->leaf)
+ return false;
+
+ node = rb_first(&he->hroot_out);
+ child = rb_entry(node, struct hist_entry, rb_node);
+
+ while (node && child->filtered) {
+ node = rb_next(node);
+ child = rb_entry(node, struct hist_entry, rb_node);
+ }
+
+ if (node)
+ percent = hist_entry__get_percent_limit(child);
+ else
+ percent = 0;
+
+ return node && percent >= limit;
+}
+
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 722aa44..da3e7b6 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -410,6 +410,7 @@ static inline int script_browse(const char *script_opt __maybe_unused)
#endif
unsigned int hists__sort_list_width(struct hists *hists);
+unsigned int hists__overhead_width(struct hists *hists);
void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
struct perf_sample *sample, bool nonany_branch_mode);
@@ -439,4 +440,6 @@ static inline struct rb_node *rb_hierarchy_next(struct rb_node *node)
#define HIERARCHY_INDENT 3
+bool hist_entry__has_hierarchy_children(struct hist_entry *he, float limit);
+
#endif /* __PERF_HIST_H */
prev parent reply other threads:[~2016-02-27 9:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-26 12:13 [PATCH 1/5] perf hists: Add more helper functions for the hierarchy mode Namhyung Kim
2016-02-26 12:13 ` [PATCH 2/5] perf report: Show message for percent limit on stdio Namhyung Kim
2016-02-26 14:15 ` Arnaldo Carvalho de Melo
2016-02-27 9:41 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-03-30 14:12 ` [PATCH 2/5] " Arnaldo Carvalho de Melo
2016-03-30 16:12 ` Namhyung Kim
2016-02-26 12:13 ` [PATCH 3/5] perf hists browser: Cleanup hist_browser__update_percent_limit() Namhyung Kim
2016-02-27 9:42 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-26 12:13 ` [PATCH 4/5] perf hists browser: Show message for percent limit Namhyung Kim
2016-02-27 9:42 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-26 12:13 ` [PATCH 5/5] perf report: Show message for percent limit on gtk Namhyung Kim
2016-02-27 9:42 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-27 9:41 ` tip-bot for Namhyung Kim [this message]
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-a7b5895b91fb97f2b0dcc2e3ce47413c18d19ca5@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=andi@firstfloor.org \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--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