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>,
Andi Kleen <andi@firstfloor.org>, David Ahern <dsahern@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 10/12] perf hists browser: Fix counting callchains when expand/collapse all
Date: Sun, 24 Jan 2016 22:53:33 +0900 [thread overview]
Message-ID: <1453643615-1616-11-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1453643615-1616-1-git-send-email-namhyung@kernel.org>
Likely to toggle folding state, when expanding/collapsing all entries it
should take into account percent limit of callchains.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/ui/browsers/hists.c | 48 ++++++++++++++++++++++++++++++------------
1 file changed, 34 insertions(+), 14 deletions(-)
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index a85f85e2b1ee..3bcd813f65d7 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -384,67 +384,85 @@ static bool hist_browser__toggle_fold(struct hist_browser *browser)
return false;
}
-static int callchain_node__set_folding_rb_tree(struct callchain_node *node, bool unfold)
+static int callchain_node__set_folding_rb_tree(struct callchain_node *node,
+ bool unfold, u64 total)
{
int n = 0;
struct rb_node *nd;
for (nd = rb_first(&node->rb_root); nd; nd = rb_next(nd)) {
- struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node);
+ struct callchain_node *child;
struct callchain_list *chain;
bool has_children = false;
+ double percent;
+ bool can_count;
+
+ child = rb_entry(nd, struct callchain_node, rb_node);
+ percent = 100.0 * callchain_cumul_hits(child) / total;
+ can_count = (percent >= callchain_param.min_percent);
list_for_each_entry(chain, &child->val, list) {
- ++n;
+ if (can_count)
+ ++n;
callchain_list__set_folding(chain, unfold);
has_children = chain->has_children;
}
if (has_children)
- n += callchain_node__set_folding_rb_tree(child, unfold);
+ n += callchain_node__set_folding_rb_tree(child, unfold,
+ total);
}
return n;
}
-static int callchain_node__set_folding(struct callchain_node *node, bool unfold)
+static int callchain_node__set_folding(struct callchain_node *node, bool unfold,
+ u64 total)
{
struct callchain_list *chain;
bool has_children = false;
int n = 0;
+ double percent = 100.0 * callchain_cumul_hits(node) / total;
+ bool can_count = (percent >= callchain_param.min_percent);
list_for_each_entry(chain, &node->val, list) {
- ++n;
+ if (can_count)
+ ++n;
callchain_list__set_folding(chain, unfold);
has_children = chain->has_children;
}
if (has_children)
- n += callchain_node__set_folding_rb_tree(node, unfold);
+ n += callchain_node__set_folding_rb_tree(node, unfold,
+ total);
return n;
}
-static int callchain__set_folding(struct rb_root *chain, bool unfold)
+static int callchain__set_folding(struct rb_root *chain, bool unfold, u64 total)
{
struct rb_node *nd;
int n = 0;
for (nd = rb_first(chain); nd; nd = rb_next(nd)) {
- struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node);
- n += callchain_node__set_folding(node, unfold);
+ struct callchain_node *node;
+
+ node = rb_entry(nd, struct callchain_node, rb_node);
+ n += callchain_node__set_folding(node, unfold, total);
}
return n;
}
-static void hist_entry__set_folding(struct hist_entry *he, bool unfold)
+static void hist_entry__set_folding(struct hist_entry *he, bool unfold,
+ u64 total)
{
hist_entry__init_have_children(he);
he->unfolded = unfold ? he->has_children : false;
if (he->has_children) {
- int n = callchain__set_folding(&he->sorted_chain, unfold);
+ int n = callchain__set_folding(&he->sorted_chain, unfold,
+ total);
he->nr_rows = unfold ? n : 0;
} else
he->nr_rows = 0;
@@ -455,12 +473,14 @@ __hist_browser__set_folding(struct hist_browser *browser, bool unfold)
{
struct rb_node *nd;
struct hists *hists = browser->hists;
+ u64 total = hists__total_period(hists);
+ struct hist_entry *he;
for (nd = rb_first(&hists->entries);
(nd = hists__filter_entries(nd, browser->min_pcnt)) != NULL;
nd = rb_next(nd)) {
- struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
- hist_entry__set_folding(he, unfold);
+ he = rb_entry(nd, struct hist_entry, rb_node);
+ hist_entry__set_folding(he, unfold, total);
browser->nr_callchain_rows += he->nr_rows;
}
}
--
2.6.4
next prev parent reply other threads:[~2016-01-24 13:56 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-24 13:53 [PATCHSET 00/12] perf tools: Apply percent-limit to callchains Namhyung Kim
2016-01-24 13:53 ` [PATCH 01/12] perf report: Apply --percent-limit to callchains also Namhyung Kim
2016-01-24 13:53 ` [PATCH 02/12] perf report: Apply callchain percent limit on --stdio Namhyung Kim
2016-01-24 13:53 ` [PATCH 03/12] perf report: Get rid of hist_entry__callchain_fprintf() Namhyung Kim
2016-01-24 13:53 ` [PATCH 04/12] perf report: Fix percent calculation on --stdio Namhyung Kim
2016-01-24 13:53 ` [PATCH 05/12] perf report: Hide output pipe for percent-limited callchains on stdio Namhyung Kim
2016-01-24 13:53 ` [PATCH 06/12] perf hists browser: Fix dump to show correct callchain style Namhyung Kim
2016-01-24 13:53 ` [PATCH 07/12] perf hists browser: Fix callchain_node__count_rows() Namhyung Kim
2016-01-26 11:46 ` Jiri Olsa
2016-01-26 12:32 ` Namhyung Kim
2016-01-24 13:53 ` [PATCH 08/12] perf hists browser: Apply callchain percent limit Namhyung Kim
2016-01-24 13:53 ` [PATCH 09/12] perf hists browser: Fix callchain counting when press ENTER key Namhyung Kim
2016-01-24 13:53 ` Namhyung Kim [this message]
2016-01-24 13:53 ` [PATCH 11/12] perf hists browser: Update percent base for fractal callchain mode Namhyung Kim
2016-01-24 13:53 ` [PATCH 12/12] perf report: Fix callchain percent limit on --gtk Namhyung Kim
2016-01-25 2:16 ` [PATCHSET 00/12] perf tools: Apply percent-limit to callchains Andi Kleen
2016-01-26 12:14 ` Jiri Olsa
2016-01-26 12:51 ` Namhyung Kim
2016-01-26 13:27 ` Jiri Olsa
2016-01-26 14:10 ` Namhyung Kim
2016-01-26 14:41 ` Jiri Olsa
2016-01-26 14:49 ` Namhyung Kim
2016-01-26 15:18 ` Jiri Olsa
2016-01-26 15:30 ` Arnaldo Carvalho de Melo
2016-01-26 15:41 ` Jiri Olsa
2016-01-26 15:54 ` Namhyung Kim
2016-01-26 16:15 ` Jiri Olsa
2016-01-27 13:21 ` 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=1453643615-1616-11-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=andi@firstfloor.org \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.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®