aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2016-01-27 10:40:56 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-02-01 15:46:27 -0500
commit59c624e2391080fa6315a376a4ee74d0eb393d1d (patch)
tree60ebc8fb9757a0306824019bcfb3729ed619c89c /tools/perf/ui
parent5eca104eee7edfe7155523849750ced539b16e94 (diff)
perf hists browser: Fix percent display in callchains
When there's only a single callchain, perf doesn't print its percentage in front of the symbols. This is because it assumes that the percentage is same as parents. But if a percent limit is applied, it's possible that there are actually a couple of child nodes but only one of them is shown. In this case it should display the percent to prevent misunderstanding of its percentage is same as the parent's. For example, let's see the following callchain. $ perf report --no-children --percent-limit 0.01 --tui ... - 0.06% sleep [kernel.vmlinux] [k] kmem_cache_alloc_trace kmem_cache_alloc_trace - perf_event_mmap - 0.04% mmap_region do_mmap_pgoff - vm_mmap_pgoff + 0.02% sys_mmap_pgoff + 0.02% vm_mmap + 0.02% mprotect_fixup Current code omits the percent if 'mmap_region' becomes the only node when percent limit is set to 0.03%, its percent is not 0.06% but users will assume it incorrectly. Before: $ perf report --no-children --percent-limit 0.03 --tui ... 0.06% sleep [kernel.vmlinux] [k] kmem_cache_alloc_trace kmem_cache_alloc_trace - perf_event_mmap - mmap_region do_mmap_pgoff vm_mmap_pgoff After: $ perf report --no-children --percent-limit 0.03 --tui ... 0.06% sleep [kernel.vmlinux] [k] kmem_cache_alloc_trace kmem_cache_alloc_trace - perf_event_mmap - 0.04% mmap_region do_mmap_pgoff vm_mmap_pgoff Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1453909257-26015-10-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui')
-rw-r--r--tools/perf/ui/browsers/hists.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 41dbb79c992e..61d578bf4ffd 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -657,10 +657,24 @@ static int hist_browser__show_callchain_list(struct hist_browser *browser,
657 return 1; 657 return 1;
658} 658}
659 659
660static bool check_percent_display(struct rb_node *node, u64 parent_total)
661{
662 struct callchain_node *child;
663
664 if (node == NULL)
665 return false;
666
667 if (rb_next(node))
668 return true;
669
670 child = rb_entry(node, struct callchain_node, rb_node);
671 return callchain_cumul_hits(child) != parent_total;
672}
673
660static int hist_browser__show_callchain_flat(struct hist_browser *browser, 674static int hist_browser__show_callchain_flat(struct hist_browser *browser,
661 struct rb_root *root, 675 struct rb_root *root,
662 unsigned short row, u64 total, 676 unsigned short row, u64 total,
663 u64 parent_total __maybe_unused, 677 u64 parent_total,
664 print_callchain_entry_fn print, 678 print_callchain_entry_fn print,
665 struct callchain_print_arg *arg, 679 struct callchain_print_arg *arg,
666 check_output_full_fn is_output_full) 680 check_output_full_fn is_output_full)
@@ -670,7 +684,7 @@ static int hist_browser__show_callchain_flat(struct hist_browser *browser,
670 bool need_percent; 684 bool need_percent;
671 685
672 node = rb_first(root); 686 node = rb_first(root);
673 need_percent = node && rb_next(node); 687 need_percent = check_percent_display(node, parent_total);
674 688
675 while (node) { 689 while (node) {
676 struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node); 690 struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node);
@@ -764,7 +778,7 @@ static char *hist_browser__folded_callchain_str(struct hist_browser *browser,
764static int hist_browser__show_callchain_folded(struct hist_browser *browser, 778static int hist_browser__show_callchain_folded(struct hist_browser *browser,
765 struct rb_root *root, 779 struct rb_root *root,
766 unsigned short row, u64 total, 780 unsigned short row, u64 total,
767 u64 parent_total __maybe_unused, 781 u64 parent_total,
768 print_callchain_entry_fn print, 782 print_callchain_entry_fn print,
769 struct callchain_print_arg *arg, 783 struct callchain_print_arg *arg,
770 check_output_full_fn is_output_full) 784 check_output_full_fn is_output_full)
@@ -774,7 +788,7 @@ static int hist_browser__show_callchain_folded(struct hist_browser *browser,
774 bool need_percent; 788 bool need_percent;
775 789
776 node = rb_first(root); 790 node = rb_first(root);
777 need_percent = node && rb_next(node); 791 need_percent = check_percent_display(node, parent_total);
778 792
779 while (node) { 793 while (node) {
780 struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node); 794 struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node);
@@ -863,7 +877,7 @@ static int hist_browser__show_callchain_graph(struct hist_browser *browser,
863 percent_total = parent_total; 877 percent_total = parent_total;
864 878
865 node = rb_first(root); 879 node = rb_first(root);
866 need_percent = node && rb_next(node); 880 need_percent = check_percent_display(node, parent_total);
867 881
868 while (node) { 882 while (node) {
869 struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node); 883 struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node);