Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1613684

[PATCH v1 0/5] perf report: Show branch type

From Jin Yao <yao.jin@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH v1 0/5] perf report: Show branch type
Date 2017-03-31 09:30 +0200
Message-ID <tqZap-1ug-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


It is often useful to know the branch types while analyzing branch
data. For example, a call is very different from a conditional branch.

Currently we have to look it up in binary while the binary may later
not be available and even the binary is available but user has to take
some time. It is very useful for user to check it directly in perf
report.

Perf already has support for disassembling the branch instruction
to get the branch type.

The patch series records the branch type and show the branch type with
other LBR information in callchain entry via perf report. The patch
series also adds the branch type summary at the end of
perf report --stdio.

To keep consistent on kernel and userspace and make the classification
more common, the patch adds the common branch type classification
in perf_event.h.

The common branch types are:

 JCC forward: Conditional forward jump
JCC backward: Conditional backward jump
         JMP: Jump imm
     IND_JMP: Jump reg/mem
        CALL: Call imm
    IND_CALL: Call reg/mem
         RET: Ret
  FAR_BRANCH: SYSCALL/SYSRET, IRQ, IRET, TSX Abort

An example:

1. Record branch type (new option "save_type")

perf record -g --branch-filter any,save_type <command>

2. Show the branch type statistics at the end of perf report --stdio

perf report --stdio

     JCC forward:  34.0%
    JCC backward:   3.6%
             JMP:   0.0%
         IND_JMP:   6.5%
            CALL:  26.6%
        IND_CALL:   0.0%
             RET:  29.3%
      FAR_BRANCH:   0.0%

3. Show branch type in callchain entry

perf report --branch-history --stdio --no-children

    --23.91%--main div.c:42 (RET cycles:2)
              compute_flag div.c:28 (RET cycles:2)
              compute_flag div.c:27 (RET cycles:1)
              rand rand.c:28 (RET cycles:1)
              rand rand.c:28 (RET cycles:1)
              __random random.c:298 (RET cycles:1)
              __random random.c:297 (JCC forward cycles:1)
              __random random.c:295 (JCC forward cycles:1)
              __random random.c:295 (JCC forward cycles:1)
              __random random.c:295 (JCC forward cycles:1)
              __random random.c:295 (RET cycles:9)

Jin Yao (5):
  perf/core: Define the common branch type classification
  perf/x86/intel: Record branch type
  perf record: Create a new option save_type in --branch-filter
  perf report: Show branch type statistics for stdio mode
  perf report: Show branch type in callchain entry

 arch/x86/events/intel/lbr.c              |  69 ++++++++++++-
 include/uapi/linux/perf_event.h          |  24 ++++-
 tools/include/uapi/linux/perf_event.h    |  24 ++++-
 tools/perf/Documentation/perf-record.txt |   1 +
 tools/perf/builtin-report.c              | 140 ++++++++++++++++++++++++++
 tools/perf/util/callchain.c              | 168 ++++++++++++++++++++-----------
 tools/perf/util/callchain.h              |  13 +++
 tools/perf/util/event.h                  |   3 +-
 tools/perf/util/hist.c                   |   5 +-
 tools/perf/util/parse-branch-options.c   |   1 +
 10 files changed, 381 insertions(+), 67 deletions(-)

-- 
2.7.4

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH v1 0/5] perf report: Show branch type Jin Yao <yao.jin@linux.intel.com> - 2017-03-31 09:30 +0200
  [PATCH v1 1/5] perf/core: Define the common branch type classification Jin Yao <yao.jin@linux.intel.com> - 2017-03-31 09:30 +0200
    Re: [PATCH v1 1/5] perf/core: Define the common branch type  classification Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-04-04 16:20 +0200
      Re: [PATCH v1 1/5] perf/core: Define the common branch type  classification "Jin, Yao" <yao.jin@linux.intel.com> - 2017-04-04 18:00 +0200
        Re: [PATCH v1 1/5] perf/core: Define the common branch type  classification Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-04-04 18:20 +0200
          Re: [PATCH v1 1/5] perf/core: Define the common branch type  classification "Jin, Yao" <yao.jin@linux.intel.com> - 2017-04-06 02:10 +0200
      Re: [PATCH v1 1/5] perf/core: Define the common branch type  classification Peter Zijlstra <peterz@infradead.org> - 2017-04-06 09:00 +0200
        Re: [PATCH v1 1/5] perf/core: Define the common branch type  classification "Jin, Yao" <yao.jin@linux.intel.com> - 2017-04-06 10:30 +0200
          Re: [PATCH v1 1/5] perf/core: Define the common branch type  classification Peter Zijlstra <peterz@infradead.org> - 2017-04-06 11:30 +0200
            Re: [PATCH v1 1/5] perf/core: Define the common branch type  classification "Jin, Yao" <yao.jin@linux.intel.com> - 2017-04-06 16:50 +0200
              Re: [PATCH v1 1/5] perf/core: Define the common branch type  classification Peter Zijlstra <peterz@infradead.org> - 2017-04-06 19:00 +0200
                Re: [PATCH v1 1/5] perf/core: Define the common branch type  classification "Jin, Yao" <yao.jin@linux.intel.com> - 2017-04-07 04:20 +0200
  [PATCH v1 5/5] perf report: Show branch type in callchain entry Jin Yao <yao.jin@linux.intel.com> - 2017-03-31 09:30 +0200
  [PATCH v1 4/5] perf report: Show branch type statistics for stdio mode Jin Yao <yao.jin@linux.intel.com> - 2017-03-31 09:30 +0200
  [PATCH v1 3/5] perf record: Create a new option save_type in --branch-filter Jin Yao <yao.jin@linux.intel.com> - 2017-03-31 09:30 +0200

csiph-web