The output of callchains on stdio shows pipes to display callchain depth
and continuation.  But if --percent-limit option is given, it should
take it into account so that it can omit unnecessary pipes on the last
callchain node.

For example, when 0.03 percent limit is given:

Before)

  $ perf report --stdio --percent-limit 0.03
  ...
       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

                ^^^
                here

It's because there's a node which has 0.02% of overhead but it's now
shown due to the percent limit.  After applying this patch,

After)

  $ perf report --stdio --percent-limit 0.03
  ...
       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 <namhy...@kernel.org>
---
 tools/perf/ui/stdio/hist.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 7bf05e82766f..eae25efa684e 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -120,6 +120,21 @@ static size_t __callchain__fprintf_graph(FILE *fp, struct 
rb_root *root,
                        new_depth_mask &= ~(1 << (depth - 1));
 
                /*
+                * If the next node is under percent limit, remaining
+                * callchains won't be shown.  So no need to keep the pipes.
+                */
+               if (next) {
+                       struct callchain_node *next_child;
+
+                       next_child = rb_entry(next, struct callchain_node, 
rb_node);
+                       cumul = callchain_cumul_counts(next_child);
+                       percent = 100.0 * cumul / total_samples;
+
+                       if (percent < callchain_param.min_percent)
+                               new_depth_mask &= ~(1 << (depth - 1));
+               }
+
+               /*
                 * But we keep the older depth mask for the line separator
                 * to keep the level link until we reach the last child
                 */
-- 
2.6.4

Reply via email to