1. 05 6月, 2019 14 次提交
    • A
      perf intel-pt: Accumulate cycle count from TSC/TMA/MTC packets · 3f055167
      Adrian Hunter 提交于
      When CYC packets are not available, it is still possible to count cycles
      using TSC/TMA/MTC timestamps.
      
      As the timestamp increments in TSC ticks, convert to CPU cycles using
      the current core-to-bus ratio.
      
      Do not accumulate cycles when control flow packet generation is not
      enabled, nor when time has been "lost", typically due to mwait, which is
      indicated by a TSC/TMA packet that is not part of PSB+.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/20190520113728.14389-12-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3f055167
    • A
      perf intel-pt: Re-factor TIP cases in intel_pt_walk_to_ip · f3c98c4b
      Adrian Hunter 提交于
      To make it easier to add new code for different TIP cases, separate each
      case.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/20190520113728.14389-11-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f3c98c4b
    • A
      perf intel-pt: Record when decoding PSB+ packets · 9bc668e3
      Adrian Hunter 提交于
      In preparation for using MTC packets to count cycles, record whether
      decoding is between a PSB and PSBEND packets.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/20190520113728.14389-10-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9bc668e3
    • A
      perf script: Add output of IPC ratio · 68fb45bf
      Adrian Hunter 提交于
      Add field 'ipc' to display instructions-per-cycle.
      
      Example:
      
       perf record -e intel_pt/cyc/u ls
       perf script --insn-trace --xed -F+ipc,-dso,-cpu,-tid
      
       ls  2670177.697113434:  7f0dfdbcd090 _start+0x0      mov %rsp, %rdi   IPC: 0.00 (1/877)
       ls  2670177.697113434:  7f0dfdbcd093 _start+0x3      callq  0x7f0dfdbce030
       ls  2670177.697113434:  7f0dfdbce030 _dl_start+0x0   pushq  %rbp
       ls  2670177.697113434:  7f0dfdbce031 _dl_start+0x1   mov %rsp, %rbp
       ls  2670177.697113434:  7f0dfdbce034 _dl_start+0x4   pushq  %r15
       ls  2670177.697113434:  7f0dfdbce036 _dl_start+0x6   pushq  %r14
       ls  2670177.697113434:  7f0dfdbce038 _dl_start+0x8   pushq  %r13
       ls  2670177.697113434:  7f0dfdbce03a _dl_start+0xa   pushq  %r12
       ls  2670177.697113434:  7f0dfdbce03c _dl_start+0xc   mov %rdi, %r12
       ls  2670177.697113434:  7f0dfdbce03f _dl_start+0xf   pushq  %rbx
       ls  2670177.697113434:  7f0dfdbce040 _dl_start+0x10  sub $0x38, %rsp
       ls  2670177.697113434:  7f0dfdbce044 _dl_start+0x14  rdtsc
       ls  2670177.697113434:  7f0dfdbce046 _dl_start+0x16  mov %eax, %eax
       ls  2670177.697113434:  7f0dfdbce048 _dl_start+0x18  shl $0x20, %rdx
       ls  2670177.697113434:  7f0dfdbce04c _dl_start+0x1c  or %rax, %rdx
       ls  2670177.697114471:  7f0dfdbce04f _dl_start+0x1f  movq  0x27e22(%rip), %rax        IPC: 0.00 (15/1685)
       ls  2670177.697116177:  7f0dfdbce056 _dl_start+0x26  movq  %rdx, 0x27683(%rip)        IPC: 0.00 (1/881)
      
      Note, the IPC values are low due to page faults at the beginning of
      execution. The additional cycles are due to the time to enter the
      kernel, not the actual kernel page fault handler.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/20190520113728.14389-9-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      68fb45bf
    • A
      perf intel-pt: Add support for samples to contain IPC ratio · 5b1dc0fd
      Adrian Hunter 提交于
      Copy the incremental instruction count and cycle count onto 'instructions'
      and 'branches' samples.
      
      Because Intel PT does not update the cycle count on every branch or
      instruction, the incremental values will often be zero.
      
      When there are values, they will be the number of instructions and
      number of cycles since the last update, and thus represent the average
      IPC since the last IPC value.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/20190520113728.14389-8-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5b1dc0fd
    • A
      perf tools: Add IPC information to perf_sample · 61d276f4
      Adrian Hunter 提交于
      Add counts of instructions and cycles, in order to represent
      instructions-per-cycle (IPC).
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/20190520113728.14389-7-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      61d276f4
    • A
      perf intel-pt: Accumulate cycle count from CYC packets · 7b4b4f83
      Adrian Hunter 提交于
      In preparation for providing instructions-per-cycle (IPC) information,
      accumulate cycle count from CYC packets.
      
      Although CYC packets are optional (requires config term 'cyc' to enable
      cycle-accurate mode when recording), the simplest way to count cycles is
      with CYC packets.
      
      The first complication is that cycles must be counted only when also
      counting instructions.
      
      That means when control flow packet generation is enabled i.e. between
      TIP.PGE and TIP.PGD packets.
      
      Also, sampling the cycle count follows the same rules as sampling the
      timestamp, that is, not before the instruction to which the decoder is
      walking is reached.
      
      In addition, the cycle count is not accurate for any but the first
      branch of a TNT packet.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/20190520113728.14389-6-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7b4b4f83
    • A
      perf intel-pt: Factor out intel_pt_update_sample_time · 948e9dc8
      Adrian Hunter 提交于
      To eliminate some duplication and make the code more understandable,
      factor out intel_pt_update_sample_time.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/20190520113728.14389-5-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      948e9dc8
    • A
      perf record: Allow mixing --user-regs with --call-graph=dwarf · d194d8fc
      Alexey Budankov 提交于
      When DWARF stacks were requested and at the same time that the user
      specifies a register set using the --user-regs option the full register
      context was being captured on samples:
      
        $ perf record -g --call-graph dwarf,1024 --user-regs=IP,SP,BP -- stack_test2.g.O3
      
        188143843893585 0x6b48 [0x4f8]: PERF_RECORD_SAMPLE(IP, 0x4002): 23828/23828: 0x401236 period: 1363819 addr: 0x7ffedbdd51ac
        ... FP chain: nr:0
        ... user regs: mask 0xff0fff ABI 64-bit
        .... AX    0x53b
        .... BX    0x7ffedbdd3cc0
        .... CX    0xffffffff
        .... DX    0x33d3a
        .... SI    0x7f09b74c38d0
        .... DI    0x0
        .... BP    0x401260
        .... SP    0x7ffedbdd3cc0
        .... IP    0x401236
        .... FLAGS 0x20a
        .... CS    0x33
        .... SS    0x2b
        .... R8    0x7f09b74c3800
        .... R9    0x7f09b74c2da0
        .... R10   0xfffffffffffff3ce
        .... R11   0x246
        .... R12   0x401070
        .... R13   0x7ffedbdd5db0
        .... R14   0x0
        .... R15   0x0
        ... ustack: size 1024, offset 0xe0
         . data_src: 0x5080021
         ... thread: stack_test2.g.O:23828
         ...... dso: /root/abudanko/stacks/stack_test2.g.O3
      
      I.e. the --user-regs=IP,SP,BP was being ignored, being overridden by the
      needs of --call-graph=dwarf.
      
      After applying the change in this patch the sample data contains the
      user specified register, but making sure that at least the minimal set
      of register needed for DWARF unwinding (DWARF_MINIMAL_REGS) is
      requested.
      
      The user is warned that DWARF unwinding may not work if extra registers
      end up being needed.
      
        -g call-graph dwarf,K                         full_regs
        --user-regs=user_regs                         user_regs
        -g call-graph dwarf,K --user-regs=user_regs	user_regs + DWARF_MINIMAL_REGS
      
        $ perf record -g --call-graph dwarf,1024 --user-regs=BP -- ls
        WARNING: The use of --call-graph=dwarf may require all the user registers, specifying a subset with --user-regs may render DWARF unwinding unreliable, so the minimal registers set (IP, SP) is explicitly forced.
        arch   COPYING	Documentation  include	Kbuild	 lbuild    MAINTAINERS	modules.builtin		 Module.symvers  perf.data.old	scripts   System.map  virt
        block  CREDITS	drivers        init	Kconfig  lib	   Makefile	modules.builtin.modinfo  net		 README		security  tools       vmlinux
        certs  crypto	fs	       ipc	kernel	 LICENSES  mm		modules.order		 perf.data	 samples	sound	  usr	      vmlinux.o
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.030 MB perf.data (10 samples) ]
      
        188368474305373 0x5e40 [0x470]: PERF_RECORD_SAMPLE(IP, 0x4002): 23839/23839: 0x401236 period: 1260507 addr: 0x7ffd3d85e96c
        ... FP chain: nr:0
        ... user regs: mask 0x1c0 ABI 64-bit
        .... BP    0x401260
        .... SP    0x7ffd3d85cc20
        .... IP    0x401236
        ... ustack: size 1024, offset 0x58
         . data_src: 0x5080021
      
      Committer notes:
      
      Detected build failures on arches where PERF_REGS_ is not available,
      such as debian:experimental-x-{mips,mips64,mipsel}, fedora 24 and 30 for
      ARC uClibc and glibc, reported to Alexey that provided a patch moving
      the DWARF_MINIMAL_REGS from evsel.c to util/perf_regs.h, where it is
      guarded by an HAVE_PERF_REGS_SUPPORT ifdef.
      
      Committer testing:
      
        # perf record --user-regs=bp,ax -a sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.955 MB perf.data (1773 samples) ]
        # perf script -F+uregs | grep AX: | head -5
           perf 1719 [000] 181.272398:    1 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffef828fb00
           perf 1719 [000] 181.272402:    1 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffef828fb00
           perf 1719 [000] 181.272403:    8 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffef828fb00
           perf 1719 [000] 181.272405:  181 cycles: ffffffffba06a7c6 native_write_msr+0x6 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffef828fb00
           perf 1719 [000] 181.272406: 4405 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffef828fb00
        # perf record --call-graph=dwarf --user-regs=bp,ax -a sleep 1
        WARNING: The use of --call-graph=dwarf may require all the user registers, specifying a subset with --user-regs may render DWARF unwinding unreliable, so the minimal registers set (IP, SP) is explicitly forced.
        [ perf record: Woken up 55 times to write data ]
        [ perf record: Captured and wrote 24.184 MB perf.data (2841 samples) ]
        [root@quaco ~]# perf script --hide-call-graph -F+uregs | grep AX: | head -5
           perf 1729 [000] 211.268006:    1 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffc8679abb0 SP:0x7ffc8679ab78 IP:0x7fa75223a0db
           perf 1729 [000] 211.268014:    1 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffc8679abb0 SP:0x7ffc8679ab78 IP:0x7fa75223a0db
           perf 1729 [000] 211.268017:    5 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffc8679abb0 SP:0x7ffc8679ab78 IP:0x7fa75223a0db
           perf 1729 [000] 211.268020:   48 cycles: ffffffffba06a7c6 native_write_msr+0x6 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffc8679abb0 SP:0x7ffc8679ab78 IP:0x7fa75223a0db
           perf 1729 [000] 211.268024:  490 cycles: ffffffffba00e471 intel_bts_enable_local+0x21 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffc8679abb0 SP:0x7ffc8679ab78 IP:0x7fa75223a0db
        #
      Signed-off-by: NAlexey Budankov <alexey.budankov@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/e7fd37b1-af22-0d94-a0dc-5895e803bbfe@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d194d8fc
    • L
      perf symbols: Remove unused variable 'err' · e5f177a5
      Leo Yan 提交于
      Variable 'err' is defined but never used in function symsrc__init(),
      remove it and directly return -1 at the end of the function.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190530093801.20510-1-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e5f177a5
    • A
      perf data: Document directory format header: HEADER_DIR_FORMAT · 0da6ae94
      Arnaldo Carvalho de Melo 提交于
      We forgot to update the perf.data file format document for the
      HEADER_DIR_FORMAT header, do it now from comments in the patch
      introducing it.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Chong Jiang <chongjiang@chromium.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Simon Que <sque@chromium.org>
      Fixes: 258031c0 ("perf header: Add DIR_FORMAT feature to describe directory data")
      Link: https://lkml.kernel.org/n/tip-jbrzb7ijb5al33gi8br6f9rr@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0da6ae94
    • A
      perf data: Document clockid header: HEADER_CLOCKID · a9de7cfc
      Arnaldo Carvalho de Melo 提交于
      We forgot to update the perf.data file format document for the
      HEADER_CLOCKID header, do it now from comments in the patch introducing
      it.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Chong Jiang <chongjiang@chromium.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Simon Que <sque@chromium.org>
      Fixes: cf790516 ("perf record: Encode -k clockid frequency into Perf trace")
      Link: https://lkml.kernel.org/n/tip-slhnjp06027j3ae17qqetzxj@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a9de7cfc
    • A
      perf data: Document memory topology header: HEADER_MEM_TOPOLOGY · 835fbf12
      Arnaldo Carvalho de Melo 提交于
      We forgot to update the perf.data file format document for the
      HEADER_MEM_TOPOLOGY header, do it now from comments in the patch
      introducing it.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Chong Jiang <chongjiang@chromium.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Simon Que <sque@chromium.org>
      Fixes: e2091ced ("perf tools: Add MEM_TOPOLOGY feature to perf data file")
      Link: https://lkml.kernel.org/n/tip-h5lcm1nbe9ztxwm61gmadd56@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      835fbf12
    • S
      perf data: Add description of header HEADER_BPF_PROG_INFO and HEADER_BPF_BTF · 8e21be4f
      Song Liu 提交于
      This patch addes description of HEADER_BPF_PROG_INFO and HEADER_BPF_BTF to
      perf.data-file-format.txt.
      Requested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Fixes: 606f972b ("perf bpf: Save bpf_prog_info information as headers to perf.data")
      Link: http://lkml.kernel.org/r/20190521064406.2498925-1-songliubraving@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8e21be4f
  2. 03 6月, 2019 26 次提交