• Jin Yao's avatar
    perf report: Fix wrong iteration count in --branch-history · 394fc1c6
    Jin Yao authored
    [ Upstream commit a3366db0 ]
    
    By calculating the removed loops, we can get the iteration count.
    
    But the iteration count could be reported incorrectly, reporting
    impossibly high counts.
    
    That's because previous code uses the number of removed LBR entries for
    the iteration count. That's not good. Fix this by increasing the
    iteration count when a loop is detected.
    
    When matching the chain, the iteration count would be added up, finally we need
    to compute the average value when printing out.
    
    For example,
    
      $ perf report --branch-history --stdio --no-children
    
    Before:
    
      ---f2 +0
         |
         |--33.62%--f1 +9 (cycles:1)
         |          f1 +0
         |          main +22 (cycles:1)
         |          main +17
         |          main +38 (cycles:1)
         |          main +27
         |          f1 +26 (cycles:1)
         |          f1 +24
         |          f2 +27 (cycles:7)
         |          f2 +0
         |          f1 +19 (cycles:1)
         |          f1 +14
         |          f2 +27 (cycles:11)
         |          f2 +0
         |          f1 +9 (cycles:1 iter:2968 avg_cycles:3)
         |          f1 +0
         |          main +22 (cycles:1 iter:2968 avg_cycles:3)
         |          main +17
         |          main +38 (cycles:1 iter:2968 avg_cycles:3)
    
    2968 is an impossible high iteration count and avg_cycles is too small.
    
    After:
    
      ---f2 +0
         |
         |--33.62%--f1 +9 (cycles:1)
         |          f1 +0
         |          main +22 (cycles:1)
         |          main +17
         |          main +38 (cycles:1)
         |          main +27
         |          f1 +26 (cycles:1)
         |          f1 +24
         |          f2 +27 (cycles:7)
         |          f2 +0
         |          f1 +19 (cycles:1)
         |          f1 +14
         |          f2 +27 (cycles:11)
         |          f2 +0
         |          f1 +9 (cycles:1 iter:1 avg_cycles:23)
         |          f1 +0
         |          main +22 (cycles:1 iter:1 avg_cycles:23)
         |          main +17
         |          main +38 (cycles:1 iter:1 avg_cycles:23)
    
    avg_cycles:23 is the average cycles of this iteration.
    
    Fixes: c4ee0625 ("perf report: Calculate the average cycles of iterations")
    Signed-off-by: 's avatarJin Yao <yao.jin@linux.intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: http://lkml.kernel.org/r/1546582230-17507-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: 's avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: 's avatarSasha Levin <sashal@kernel.org>
    394fc1c6
Name
Last commit
Last update
..
Documentation Loading commit data...
arch Loading commit data...
bench Loading commit data...
examples/bpf Loading commit data...
include/bpf Loading commit data...
jvmti Loading commit data...
pmu-events Loading commit data...
python Loading commit data...
scripts Loading commit data...
tests Loading commit data...
trace Loading commit data...
ui Loading commit data...
util Loading commit data...
.gitignore Loading commit data...
Build Loading commit data...
CREDITS Loading commit data...
MANIFEST Loading commit data...
Makefile Loading commit data...
Makefile.config Loading commit data...
Makefile.perf Loading commit data...
builtin-annotate.c Loading commit data...
builtin-bench.c Loading commit data...
builtin-buildid-cache.c Loading commit data...
builtin-buildid-list.c Loading commit data...
builtin-c2c.c Loading commit data...
builtin-config.c Loading commit data...
builtin-data.c Loading commit data...
builtin-diff.c Loading commit data...
builtin-evlist.c Loading commit data...
builtin-ftrace.c Loading commit data...
builtin-help.c Loading commit data...
builtin-inject.c Loading commit data...
builtin-kallsyms.c Loading commit data...
builtin-kmem.c Loading commit data...
builtin-kvm.c Loading commit data...
builtin-list.c Loading commit data...
builtin-lock.c Loading commit data...
builtin-mem.c Loading commit data...
builtin-probe.c Loading commit data...
builtin-record.c Loading commit data...
builtin-report.c Loading commit data...
builtin-sched.c Loading commit data...
builtin-script.c Loading commit data...
builtin-stat.c Loading commit data...
builtin-timechart.c Loading commit data...
builtin-top.c Loading commit data...
builtin-trace.c Loading commit data...
builtin-version.c Loading commit data...
builtin.h Loading commit data...
check-headers.sh Loading commit data...
command-list.txt Loading commit data...
design.txt Loading commit data...
perf-archive.sh Loading commit data...
perf-completion.sh Loading commit data...
perf-read-vdso.c Loading commit data...
perf-sys.h Loading commit data...
perf-with-kcore.sh Loading commit data...
perf.c Loading commit data...
perf.h Loading commit data...