• 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...
LICENSES Loading commit data...
arch Loading commit data...
block Loading commit data...
certs Loading commit data...
crypto Loading commit data...
drivers Loading commit data...
firmware Loading commit data...
fs Loading commit data...
include Loading commit data...
init Loading commit data...
ipc Loading commit data...
kernel Loading commit data...
lib Loading commit data...
mm Loading commit data...
net Loading commit data...
samples Loading commit data...
scripts Loading commit data...
security Loading commit data...
sound Loading commit data...
tools Loading commit data...
usr Loading commit data...
virt Loading commit data...
.clang-format Loading commit data...
.cocciconfig Loading commit data...
.get_maintainer.ignore Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Kbuild Loading commit data...
Kconfig Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README Loading commit data...