linux/tools/perf/scripts/python
Adrian Hunter ae8b887c00 perf scripts python: exported-sql-viewer.py: Add call tree
Add a new report to display a call tree. The Call Tree report is very
similar to the Context-Sensitive Call Graph, but the data is not
aggregated. Also the 'Count' column, which would be always 1, is replaced
by the 'Call Time'.

Committer testing:

  $ cat simple-retpoline.c
  /*

    https://lkml.kernel.org/r/20190109091835.5570-6-adrian.hunter@intel.com

  $ gcc -ggdb3 -Wall -Wextra -O2 -o simple-retpoline simple-retpoline.c
  $ objdump -d simple-retpoline
  */

  __attribute__((noinline)) int bar(void)
  {
          return -1;
  }

  int foo(void)
  {
          return bar() + 1;
  }

  __attribute__((indirect_branch("thunk"))) int main()
  {
          int (*volatile fn)(void) = foo;

          fn();
          return fn();
  }
  $
  $ perf record -o simple-retpoline.perf.data -e intel_pt/cyc/u ./simple-retpoline
  $ perf script -i simple-retpoline.perf.data --itrace=be -s ~acme/libexec/perf-core/scripts/python/export-to-sqlite.py simple-retpoline.db branches calls
  $ python ~acme/libexec/perf-core/scripts/python/exported-sql-viewer.py simple-retpoline.db

And in the GUI select:

    "Reports"
      "Call Tree"

    Call Path                 | Object          | Call Time (ns) | Time (ns) | Time (%) | Branch Count | Brach Count (%) |
    > simple-retpolin
      > PID:TID
        > _start                ld-2.28.so       2193855505777      156267      100.0       10602          100.0
            unknown             unknown          2193855506010        2276        1.5           1            0.0
          > _dl_start           ld-2.28.so       2193855508286      137047       87.7       10088           95.2
          > _dl_init            ld-2.28.so       2193855645444        9142        5.9         326            3.1
          > _start              simple-retpoline 2193855654587        7457        4.8         182            1.7
            > __libc_start_main <SNIP>
              <SNIP>
              > main            simple-retpoline 2193855657493          32        0.5          12            6.7
                > foo           simple-retpoline 2193855657493          14       43.8           5           41.7
              <SNIP>

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: https://lkml.kernel.org/n/tip-enf0w96gqzfpv4fi16pw9ovc@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-03-01 15:04:16 -03:00
..
bin perf script powerpc: Python script for hypervisor call statistics 2018-06-06 12:52:06 -03:00
Perf-Trace-Util perf tools: Rename build libperf to perf 2019-02-14 15:18:08 -03:00
check-perf-trace.py perf script: Add callchain to generic and tracepoint events 2014-07-16 17:57:33 -03:00
compaction-times.py perf scripts python: Add new compaction-times script 2015-08-28 14:53:40 -03:00
event_analyzing_sample.py License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
export-to-postgresql.py perf scripts python: export-to-postgresql.py: Export calls parent_id 2019-03-01 14:53:33 -03:00
export-to-sqlite.py perf scripts python: export-to-sqlite.py: Export calls parent_id 2019-03-01 14:52:29 -03:00
exported-sql-viewer.py perf scripts python: exported-sql-viewer.py: Add call tree 2019-03-01 15:04:16 -03:00
failed-syscalls-by-pid.py perf script python: Add Python3 support to failed-syscalls-by-pid.py 2019-02-25 17:16:48 -03:00
futex-contention.py perf script: Add callchain to generic and tracepoint events 2014-07-16 17:57:33 -03:00
intel-pt-events.py perf intel-pt: Add example script for power events and PTWRITE 2017-06-30 11:50:53 -03:00
mem-phys-addr.py perf script python: Add Python3 support to mem-phys-addr.py 2019-02-25 17:16:51 -03:00
net_dropmonitor.py perf script python: Add Python3 support to net_dropmonitor.py 2019-02-25 17:16:55 -03:00
netdev-times.py perf script python: Add Python3 support to netdev-times.py 2019-02-25 17:16:42 -03:00
powerpc-hcalls.py perf script python: Add Python3 support to powerpc-hcalls.py 2019-02-25 17:16:57 -03:00
sched-migration.py perf script python: Remove explicit shebang from Python scripts 2019-01-25 15:12:10 +01:00
sctop.py perf script python: Add Python3 support to sctop.py 2019-02-25 17:17:03 -03:00
stackcollapse.py perf script python: Add Python3 support to stackcollapse.py 2019-02-25 17:17:05 -03:00
stat-cpi.py perf script python: Add Python3 support to stat-cpi.py 2019-02-25 17:17:07 -03:00
syscall-counts-by-pid.py perf script python: Add Python3 support to syscall-counts-by-pid.py 2019-02-25 17:17:13 -03:00
syscall-counts.py perf script python: Add Python3 support to syscall-counts.py 2019-02-25 17:17:10 -03:00