1. 28 Aug, 2015 1 commit
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · d1ee8bc1
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      User visible changes:
      
        - Add support for using several Intel PT features (CYC, MTC packets), the
          relevant documentation was updated: tools/perf/Documentation/intel-pt.txt,
          briefly describing those packets, its purposes, how to configure them in
          the event config terms and relevant external documentation for further
          reading. (Adrian Hunter)
      
        - Introduce support for probing at an absolute address, for user and kernel
          'perf probe's, useful when one have the symbol maps on a developer machine
          but not on an embedded system. (Wang Nan)
      
        - Fix 'perf probe' list results when a symbol can't be found or the
          address is zero and when an offset is provided without a function (Wang Nan)
      
        - Do not print '0x (null)' in uprobes when offset is zero (Wang Nan)
      
        - Clear the progress bar at the end of a ordered_events flush, fixing
          an UI artifact when, after ordering the events the screen doesn't get
          completely redraw, for instance, when an error window covers just the
          center of the screen and waits for user input. (Arnaldo Carvalho de Melo)
      
        - Fix 'annotate' segfault by resetting the dso find_symbol cache when removing
          symbols. (Arnaldo Carvalho de Melo)
      
      Infrastructure changes:
      
        - Allow duplicate objects in the object list, just like it is possible to have
          things like this, in the kernel:
      
            drivers/Makefile:obj-$(CONFIG_PCI)        += usb/
            drivers/Makefile:obj-$(CONFIG_USB_GADGET) += usb/
      
          (Jiri Olsa)
      
        - Fix Intel PT 'instructions' sample period. (Adrian Hunter)
      
        - Prevent segfault when reading probe point with absolute address. (Wang Nan)
      
      Build fixes:
      
        - Fix tarball build broken by pt/bts. (Adrian Hunter)
      
        - Remove export.h from MANIFEST, fixing the perf tarball make target. (Jiri Olsa)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d1ee8bc1
  2. 26 Aug, 2015 8 commits
  3. 24 Aug, 2015 13 commits
    • Adrian Hunter's avatar
      perf tools: Update Intel PT documentation · 9d1bf02a
      Adrian Hunter authored
      Update Intel PT documentation to describe new features.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-26-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9d1bf02a
    • Adrian Hunter's avatar
      perf tools: Add Intel PT support for decoding TRACESTOP packets · 7eacca3e
      Adrian Hunter authored
      A TRACESTOP packet is produced when an Intel PT trace enters a defined
      region of the address space at which point the tracing stops.
      
      This patch just adds decoder support.
      
      Support for specifying TRACESTOP regions is left until later.
      
      For details refer to the June 2015 or later Intel 64 and IA-32
      Architectures SDM Chapter 36 Intel Processor Trace.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-25-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7eacca3e
    • Adrian Hunter's avatar
      perf tools: Add Intel PT support for using CYC packets · 0de802ab
      Adrian Hunter authored
      CYC packets are a new Intel PT feature.
      
      CYC packets provide even finer grain timestamp information than MTC and
      TSC packets.  A CYC packet contains the number of CPU cycles since the
      last CYC packet. Unlike MTC and TSC packets, CYC packets are only sent
      when another packet is also sent.
      
      Support for this feature is indicated by:
      
      /sys/bus/event_source/devices/intel_pt/caps/psb_cyc
      
      which contains "1" if the feature is supported and "0" otherwise.
      
      CYC packets can be requested using a PMU config term e.g. perf record -e
      intel_pt/cyc/u sleep 1
      
      The frequency of CYC packets can also be specified.  e.g. perf record -e
      intel_pt/cyc,cyc_thresh=2/u sleep 1
      
      CYC packets are not requested by default.
      
      Valid cyc_thresh values are given by:
      
      /sys/bus/event_source/devices/intel_pt/caps/cycle_thresholds
      
      which contains a hexadecimal value, the bits of which represent valid
      values e.g. bit 2 set means value 2 is valid.
      
      The value represents the minimum number of CPU cycles that must have
      passed before a CYC packet can be sent.  The number of CPU cycles is:
      
          2 ^ (value - 1)
      
      e.g. value 4 means 8 CPU cycles must pass before a CYC packet can be
      sent.  Note a CYC packet is still only sent when another packet is sent,
      not at, e.g. every 8 CPU cycles.
      
      If an invalid value is entered, the error message will give a list of
      valid values e.g.
      
          $ perf record -e intel_pt/cyc,cyc_thresh=15/u uname
          Invalid cyc_thresh for intel_pt. Valid values are: 0-12
      
      tools/perf/Documentation/intel-pt.txt is updated in a later patch as
      there are a number of new features being added.
      
      For more information refer to the June 2015 or later Intel 64 and IA-32
      Architectures SDM Chapter 36 Intel Processor Trace.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-24-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0de802ab
    • Adrian Hunter's avatar
      perf tools: Add Intel PT support for decoding CYC packets · cc336186
      Adrian Hunter authored
      CYC packets provide even finer grain timestamp information than MTC and
      TSC packets.  A CYC packet contains the number of CPU cycles since the
      last CYC packet.
      
      This patch just adds decoder support.  The CPU frequency can be related
      to TSC using the Maximum Non-Turbo Ratio in combination with the CBR
      (core-to-bus ratio) packet.  However more accuracy is achieved by simply
      interpolating the number of cycles between other timing packets like MTC
      or TSC.  This patch takes the latter approach.
      
      Support for a default value and validation of values is provided by a
      later patch. Also documentation is updated in a separate patch.
      
      For details refer to the June 2015 or later Intel 64 and IA-32
      Architectures SDM Chapter 36 Intel Processor Trace.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-23-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cc336186
    • Adrian Hunter's avatar
      perf tools: Add Intel PT support for using MTC packets · b45fc0bf
      Adrian Hunter authored
      MTC packets are a new Intel PT feature.
      
      MTC packets provide finer grain timestamp information than TSC packets.
      
      Support for this feature is indicated by:
      
        /sys/bus/event_source/devices/intel_pt/caps/mtc
      
      which contains "1" if the feature is supported and "0" otherwise.
      
      MTC packets can be requested using a PMU config term e.g. perf record -e
      intel_pt/mtc/u sleep 1
      
      The frequency of MTC packets can also be specified.  e.g. perf record -e
      intel_pt/mtc,mtc_period=2/u sleep 1
      
      The default value is 3 or the nearest lower value that is supported.  0
      is always supported.
      
      Valid values are given by:
      
      /sys/bus/event_source/devices/intel_pt/caps/mtc_periods
      
      which contains a hexadecimal value, the bits of which represent valid
      values e.g. bit 2 set means value 2 is valid.
      
      The value is converted to the MTC frequency as:
      
      	CTC-frequency / (2 ^ value)
      
      e.g. value 3 means one eighth of CTC-frequency
      
      Where CTC is the hardware crystal clock, the frequency of which can be
      related to TSC via values provided in cpuid leaf 0x15.
      
      If an invalid value is entered, the error message will give a list of
      valid values e.g.
      
      	$ perf record -e intel_pt/mtc_period=15/u uname
      	Invalid mtc_period for intel_pt. Valid values are: 0,3,6,9
      
      tools/perf/Documentation/intel-pt.txt is updated in a later patch as
      there are a number of new features being added.
      
      For more information refer to the June 2015 or later Intel 64 and IA-32
      Architectures SDM Chapter 36 Intel Processor Trace.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-22-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b45fc0bf
    • Adrian Hunter's avatar
      perf tools: Add Intel PT support for decoding MTC packets · 79b58424
      Adrian Hunter authored
      MTC packets provide finer grain timestamp information than TSC packets.
      MTC packets record time using the hardware crystal clock (CTC) which is
      related to TSC packets using a TMA packet.
      
      This patch just adds decoder support.
      
      Support for a default value and validation of values is provided by a
      later patch. Also documentation is updated in a separate patch.
      
      For details refer to the June 2015 or later Intel 64 and IA-32
      Architectures SDM Chapter 36 Intel Processor Trace.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-21-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      79b58424
    • Adrian Hunter's avatar
      perf tools: Pass Intel PT information for decoding MTC and CYC · 11fa7cb8
      Adrian Hunter authored
      Record additional information in the AUXTRACE_INFO event in preparation
      for decoding MTC and CYC packets.  Pass the information to the decoder.
      
      The AUXTRACE_INFO record can be extended by using the size to indicate
      the presence of new members.
      
      The additional information includes PMU config bit positions and the TSC
      to CTC (hardware crystal clock) ratio needed to decode MTC packets.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-20-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      11fa7cb8
    • Adrian Hunter's avatar
      perf tools: Add new Intel PT packet definitions · 3d498078
      Adrian Hunter authored
      New features have been added to Intel PT which include a number of new
      packet definitions.
      
      This patch adds packet definitions for new packets: TMA, MTC, CYC, VMCS,
      TRACESTOP and MNT.  Also another bit in PIP is defined.
      
      This patch only adds support for the definitions. Later patches add
      support for decoding TMA, MTC, CYC and TRACESTOP which is where those
      packets are explained.
      
      VMCS and the newly defined bit in PIP are used with virtualization which
      is not supported yet.  MNT is a maintenance packet which the decoder
      should ignore.
      
      For details, refer to the June 2015 or later Intel 64 and IA-32
      Architectures SDM Chapter 36 Intel Processor Trace.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-19-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3d498078
    • Adrian Hunter's avatar
      perf tools: Add Intel PT support for PSB periods · bc9b6bf0
      Adrian Hunter authored
      The PSB packet is a synchronization packet that provides a starting
      point for decoding or recovery from errors.
      
      This patch adds support for a new Intel PT feature that allows the
      frequency of PSB packets to be specified.
      
      Support for this feature is indicated by
      /sys/bus/event_source/devices/intel_pt/caps/psb_cyc which contains "1"
      if the feature is supported and "0" otherwise.
      
      The PSB period can be specified as a PMU config term e.g. perf record -e
      intel_pt/psb_period=2/u sleep 1
      
      The default value is 3 or the nearest lower value that is supported.  0
      is always supported.
      
      Valid values are given by:
      
      /sys/bus/event_source/devices/intel_pt/caps/psb_periods
      
      which contains a hexadecimal value, the bits of which represent valid
      values e.g. bit 2 set means value 2 is valid.
      
      The value is converted to the approximate number of trace bytes between
      PSB packets as:
      
      	2 ^ (value + 11)
      
      e.g. value 3 means 16KiB bytes between PSBs
      
      If an invalid value is entered, the error message will give a list of
      valid values e.g.
      
      	$ perf record -e intel_pt/psb_period=15/u uname
      	Invalid psb_period for intel_pt. Valid values are: 0-5
      
      tools/perf/Documentation/intel-pt.txt is updated in a later patch as
      there are a number of new features being added.
      
      For more information about PSB periods refer to the Intel 64 and IA-32
      Architectures SDM Chapter 36 Intel Processor Trace from June 2015 or
      later.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-18-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bc9b6bf0
    • Adrian Hunter's avatar
      perf tools: Fix Intel PT 'instructions' sample period · 2a21d036
      Adrian Hunter authored
      The period on synthesized 'instructions' samples was being set to a
      fixed value, whereas the correct value is the number of instructions
      since the last sample, which is a value that the decoder can provide.
      So do it that way.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-14-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2a21d036
    • Arnaldo Carvalho de Melo's avatar
      perf ordered_events: Clear the progress bar at the end of a flush · 5c9ce1e6
      Arnaldo Carvalho de Melo authored
      We were depending on the next screen operation after a flush() being
      one that would redraw the whole screen so that the progress bar would
      be overwritten, when that didn't happen a screen artifact of, say, a
      error dialog window would be overlaid on top of the progress bar, fix
      it by calling ui_browser__finish(), that now has a TUI implementation.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-el0fyw6duemnx62lydjzhs8c@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5c9ce1e6
    • Arnaldo Carvalho de Melo's avatar
      perf ui tui progress: Implement the ui_progress_ops->finish() method · 1e259ad4
      Arnaldo Carvalho de Melo authored
      So that we can erase the progress bar after we're done with it, avoiding
      things like:
      
      -------------------------------------------------------------------
      
                ┌─Error:──────────────────────────────────────────────────────┐
                │Can't annotate unmapped_area_topdown:                        │
                │                                                             │
                │No vmlinux file with build id a826726b5ddacfab1f0bade868f1a79│
                │was found in the path.                                       │
                │                                                             │
                │Note that annotation using /proc/kcore requires CAP_SYS_RAWIO│
      ┌Processin│                                                             │──┐
      │         │Please use:                                                  │  │
      └─────────│                                                             │──┘
                │  perf buildid-cache -vu vmlinux                             │
                │                                                             │
                │or:                                                          │
                │                                                             │
                │  --vmlinux vmlinux                                          │
                │                                                             │
                │                                                             │
                │Press any key...                                             │
                └─────────────────────────────────────────────────────────────┘
      
      Can't annotate unmapped_area_topdown:
      -------------------------------------------------------------------
      
      I.e. that finished progress bar behind the error window. It is not a
      problem when we end up redrawing the whole screen, but its ugly when
      we present such error windows, provide a TUI method so that code like
      the above may avoid this situation, as will be done with the annotation
      code in the next cset.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-qvktnojzwwe37pweging058t@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1e259ad4
    • Arnaldo Carvalho de Melo's avatar
      perf annotate: Reset the dso find_symbol cache when removing symbols · c0b4dffb
      Arnaldo Carvalho de Melo authored
      The 'annotate' tool does some filtering in the entries in a DSO but
      forgot to reset the cache done in dso__find_symbol(), cauxing a SEGV:
      
        [root@zoo ~]# perf annotate netlink_poll
        perf: Segmentation fault
        -------- backtrace --------
        perf[0x526ceb]
        /lib64/libc.so.6(+0x34960)[0x7faedfbe0960]
        perf(rb_erase+0x223)[0x499d63]
        perf[0x4213e9]
        perf[0x4bc123]
        perf[0x4bc621]
        perf[0x4bf26b]
        perf[0x4bc855]
        perf(perf_session__process_events+0x340)[0x4bddc0]
        perf(cmd_annotate+0x6bb)[0x421b5b]
        perf[0x479063]
        perf(main+0x60a)[0x42098a]
        /lib64/libc.so.6(__libc_start_main+0xf0)[0x7faedfbcbfe0]
        perf[0x420aa9]
        [0x0]
        [root@zoo ~]#
      
      Fix it by reseting the find cache when removing symbols.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Fixes: b685ac22 ("perf symbols: Add front end cache for DSO symbol lookup")
      Link: http://lkml.kernel.org/n/tip-b2y9x46y0t8yem1ive41zqyp@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c0b4dffb
  4. 22 Aug, 2015 2 commits
  5. 21 Aug, 2015 10 commits
    • Wang Nan's avatar
      perf probe: Try to use symbol table if searching debug info failed · 1c0bd0e8
      Wang Nan authored
      A problem can occur in a statically linked perf when vmlinux can be found:
      
       # perf probe --add sys_epoll_pwait
       probe-definition(0): sys_epoll_pwait
       symbol:sys_epoll_pwait file:(null) line:0 offset:0 return:0 lazy:(null)
       0 arguments
       Looking at the vmlinux_path (7 entries long)
       Using /lib/modules/4.2.0-rc1+/build/vmlinux for symbols
       Open Debuginfo file: /lib/modules/4.2.0-rc1+/build/vmlinux
       Try to find probe point from debuginfo.
       Symbol sys_epoll_pwait address found : ffffffff8122bd40
       Matched function: SyS_epoll_pwait
       Failed to get call frame on 0xffffffff8122bd40
       An error occurred in debuginfo analysis (-2).
         Error: Failed to add events. Reason: No such file or directory (Code: -2)
      
      The reason is caused by libdw that, if libdw is statically linked, it
      can't load libebl_{arch}.so reliable.
      
      In this case it is still possible to get the address from
      /proc/kalksyms.  However, perf tries that only when libdw returns
      -EBADF.
      
      This patch gives it another chance to utilize symbol table, even if
      libdw returns an error code other than -EBADF.
      
      After applying this patch:
      
       # perf probe -nv --add sys_epoll_pwait
       probe-definition(0): sys_epoll_pwait
       symbol:sys_epoll_pwait file:(null) line:0 offset:0 return:0 lazy:(null)
       0 arguments
       Looking at the vmlinux_path (7 entries long)
       Using /lib/modules/4.2.0-rc1+/build/vmlinux for symbols
       Open Debuginfo file: /lib/modules/4.2.0-rc1+/build/vmlinux
       Try to find probe point from debuginfo.
       Symbol sys_epoll_pwait address found : ffffffff8122bd40
       Matched function: SyS_epoll_pwait
       Failed to get call frame on 0xffffffff8122bd40
       An error occurred in debuginfo analysis (-2).
       Trying to use symbols.
       Opening /sys/kernel/debug/tracing/kprobe_events write=1
       Added new event:
       Writing event: p:probe/sys_epoll_pwait _text+2276672
         probe:sys_epoll_pwait (on sys_epoll_pwait)
      
       You can now use it in all perf tools, such as:
      
       	perf record -e probe:sys_epoll_pwait -aR sleep 1
      
      Although libdw returns an error (Failed to get call frame), perf tries
      symbol table and finally gets correct address.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1440151770-129878-2-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1c0bd0e8
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Initialize reference counts in map__clone() · 66671d00
      Arnaldo Carvalho de Melo authored
      Map clone was written before we introduced reference counts for
      maps and dsos, so all that was needed was just a copy and then we
      would insert it into the new map_groups instance.
      
      Fix it by, after copying, initializing the map->refcnt, grabbing
      a struct dso refcount and resetting pointers that may be used
      to determine if a map, when deleted, is in a rb_tree.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-pd4mr80o5b9gvk50iineacec@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      66671d00
    • Adrian Hunter's avatar
      perf tools: Add example call-graph script · 4b715d24
      Adrian Hunter authored
      Add a script to produce a call-graph from data exported to a postgresql
      database and derived from a processor trace event like intel_pt or intel_bts.
      
      Refer to comments in the scripts call-graph-from-postgresql.py and
      export-to-postgresql.py for more details on how to set up the environment,
      install the required packages, etc.
      
      Committer note:
      
      From the scripts, for convenience while reading 'git log':
      
        An example of using this script with Intel PT:
      
        $ perf record -e intel_pt//u ls
        $ perf script -s ~/libexec/perf-core/scripts/python/export-to-postgresql.py pt_example branches calls
        2015-05-29 12:49:23.464364 Creating database...
        2015-05-29 12:49:26.281717 Writing to intermediate files...
        2015-05-29 12:49:27.190383 Copying to database...
        2015-05-29 12:49:28.140451 Removing intermediate files...
        2015-05-29 12:49:28.147451 Adding primary keys
        2015-05-29 12:49:28.655683 Adding foreign keys
        2015-05-29 12:49:29.365350 Done
        $ python tools/perf/scripts/python/call-graph-from-postgresql.py pt_example
        # The result is a GUI window with a tree representing a context-sensitive
        # call-graph.  Expanding a couple of levels of the tree and adjusting column
        # widths to suit will display something like:
      
                                               Call Graph: pt_example
        Call Path                        |Object     |Count|Time(ns)|Time(%)|Branch Count|Branch Count(%)
        v- ls
           v- 2638:2638
               v- _start                  ld-2.19.so    1   10074071  100.0        211135          100.0
                 |- unknown               unknown       1      13198    0.1             1            0.0
                 >- _dl_start             ld-2.19.so    1    1400980   13.9         19637            9.3
                 >- _d_linit_internal     ld-2.19.so    1     448152    4.4         11094            5.3
                 v-__libc_start_main@plt  ls            1    8211741   81.5        180397           85.4
                    >- _dl_fixup          ld-2.19.so    1       7607    0.1           108            0.1
                    >- __cxa_atexit       libc-2.19.so  1      11737    0.1            10            0.0
                    >- __libc_csu_init    ls            1      10354    0.1            10            0.0
                    |- _setjmp            libc-2.19.so  1          0    0.0             4            0.0
                    v- main               ls            1    8182043   99.6        180254           99.9
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-11-git-send-email-adrian.hunter@intel.com
      [ Added 'python-pyside qt-postgresql' to the yum cmdline installing required packages ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4b715d24
    • Adrian Hunter's avatar
      perf tools: Put itrace options into an asciidoc include · 60b88d87
      Adrian Hunter authored
      perf script, report and inject all have the same itrace options. Put
      them into an asciidoc include file.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-10-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      60b88d87
    • Adrian Hunter's avatar
      perf tools: Add Intel BTS support · d0170af7
      Adrian Hunter authored
      Intel BTS support fits within the new auxtrace infrastructure.  Recording is
      supporting by identifying the Intel BTS PMU, parsing options and setting up
      events.
      
      Decoding is supported by queuing up trace data by thread and then decoding
      synchronously delivering synthesized event samples into the session processing
      for tools to consume.
      
      Committer note:
      
      E.g:
      
        [root@felicio ~]# perf record --per-thread -e intel_bts// ls
        anaconda-ks.cfg  apctest.output  bin  kernel-rt-3.10.0-298.rt56.171.el7.x86_64.rpm  libexec  lock_page.bpf.c  perf.data  perf.data.old
        [ perf record: Woken up 3 times to write data ]
        [ perf record: Captured and wrote 4.367 MB perf.data ]
        [root@felicio ~]# perf evlist -v
        intel_bts//: type: 6, size: 112, { sample_period, sample_freq }: 1, sample_type: IP|TID|IDENTIFIER, read_format: ID, disabled: 1, enable_on_exec: 1, sample_id_all: 1, exclude_guest: 1
        dummy:u: type: 1, size: 112, config: 0x9, { sample_period, sample_freq }: 1, sample_type: IP|TID|IDENTIFIER, read_format: ID, disabled: 1, exclude_kernel: 1, exclude_hv: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, mmap2: 1, comm_exec: 1
        [root@felicio ~]# perf script # the navigate in the pager to some interesting place:
          ls 1843 1 branches: ffffffff810a60cb flush_signal_handlers ([kernel.kallsyms]) => ffffffff8121a522 setup_new_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8121a529 setup_new_exec ([kernel.kallsyms]) => ffffffff8122fa30 do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122fa5d do_close_on_exec ([kernel.kallsyms]) => ffffffff81767ae0 _raw_spin_lock ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff81767af4 _raw_spin_lock ([kernel.kallsyms]) => ffffffff8122fa62 do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122fa8e do_close_on_exec ([kernel.kallsyms]) => ffffffff8122faf0 do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122faf7 do_close_on_exec ([kernel.kallsyms]) => ffffffff8122fa8b do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122fa8e do_close_on_exec ([kernel.kallsyms]) => ffffffff8122faf0 do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122faf7 do_close_on_exec ([kernel.kallsyms]) => ffffffff8122fa8b do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122fa8e do_close_on_exec ([kernel.kallsyms]) => ffffffff8122faf0 do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122faf7 do_close_on_exec ([kernel.kallsyms]) => ffffffff8122fa8b do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122fa8e do_close_on_exec ([kernel.kallsyms]) => ffffffff8122faf0 do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122faf7 do_close_on_exec ([kernel.kallsyms]) => ffffffff8122fa8b do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122fa8e do_close_on_exec ([kernel.kallsyms]) => ffffffff8122faf0 do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122faf7 do_close_on_exec ([kernel.kallsyms]) => ffffffff8122fa8b do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122fa8e do_close_on_exec ([kernel.kallsyms]) => ffffffff8122faf0 do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122faf7 do_close_on_exec ([kernel.kallsyms]) => ffffffff8122fa8b do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122fac9 do_close_on_exec ([kernel.kallsyms]) => ffffffff8122fad2 do_close_on_exec ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8122fadd do_close_on_exec ([kernel.kallsyms]) => ffffffff8120fc80 filp_close ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8120fcaf filp_close ([kernel.kallsyms]) => ffffffff8120fcb6 filp_close ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8120fcc2 filp_close ([kernel.kallsyms]) => ffffffff812547f0 dnotify_flush ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff81254823 dnotify_flush ([kernel.kallsyms]) => ffffffff8120fcc7 filp_close ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8120fccd filp_close ([kernel.kallsyms]) => ffffffff81261790 locks_remove_posix ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff812617a3 locks_remove_posix ([kernel.kallsyms]) => ffffffff812617b9 locks_remove_posix ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff812617b9 locks_remove_posix ([kernel.kallsyms]) => ffffffff8120fcd2 filp_close ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8120fcd5 filp_close ([kernel.kallsyms]) => ffffffff812142c0 fput ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff812142d6 fput ([kernel.kallsyms]) => ffffffff812142df fput ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff8121430c fput ([kernel.kallsyms]) => ffffffff810b6580 task_work_add ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff810b65ad task_work_add ([kernel.kallsyms]) => ffffffff810b65b1 task_work_add ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff810b65c1 task_work_add ([kernel.kallsyms]) => ffffffff810bc710 kick_process ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff810bc725 kick_process ([kernel.kallsyms]) => ffffffff810bc742 kick_process ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff810bc742 kick_process ([kernel.kallsyms]) => ffffffff810b65c6 task_work_add ([kernel.kallsyms])
          ls 1843 1 branches: ffffffff810b65c9 task_work_add ([kernel.kallsyms]) => ffffffff81214311 fput ([kernel.kallsyms])
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-9-git-send-email-adrian.hunter@intel.com
      [ Merged sample->time fix for bug found after first round of testing on slightly older kernel ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d0170af7
    • Dean Nelson's avatar
      tools lib traceevent: Add checks for returned EVENT_ERROR type · 6f56e9cf
      Dean Nelson authored
      Running the following perf-stat command on an arm64 system produces the
      following result...
      
        [root@aarch64 ~]# perf stat -e kmem:mm_page_alloc -a sleep 1
          Warning: [kmem:mm_page_alloc] function sizeof not defined
          Warning: Error: expected type 4 but read 0
        Segmentation fault
        [root@aarch64 ~]#
      
      The second warning was a result of the first warning not stopping
      processing after it detected the issue.
      
      That is, code that found the issue reported the first problem, but
      because it did not exit out of the functions smoothly, it caused the
      other warning to appear and not only that, it later caused the SIGSEGV.
      Signed-off-by: default avatarDean Nelson <dnelson@redhat.com>
      Reviewed-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20150820151632.13927.13791.email-sent-by-dnelson@tealSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6f56e9cf
    • Adrian Hunter's avatar
      perf tools: Fix Intel PT timestamp handling · 81cd60cc
      Adrian Hunter authored
      Events that don't sample the timestamp have a timestamp value of -1.
      
      Intel PT processing wasn't taking that into account.
      
      This is particularly noticeable with Intel BTS because timestamps are
      not requested by default.
      
      Then, if the conversion of -1 to TSC results in a small number, the
      processing is unaffected.
      
      However if the conversion results in a big number, then the data is
      processed prematurely before relevant sideband data like mmap events,
      which in turn results in samples with unknown dsos.
      
      Commiter note:
      
      Since BTS wasn't upstream, I split the patch to fold the BTS part with
      the patch introducing it, to avoid having this bug in the commit
      history. PT was already upstream, so this patch contains that part.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1440060692-5585-1-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      81cd60cc
    • Adrian Hunter's avatar
      perf tools: /proc/kcore requires CAP_SYS_RAWIO message too noisy · 133de940
      Adrian Hunter authored
      The "/proc/kcore requires CAP_SYS_RAWIO" message comes up all the time
      for 'perf script' if vmlinux is not found and the user isn't root, even
      when the kernel is not being traced and even though the message is only
      really relevant for annotation.
      
      Change it to pr_debug and instead put a note in the message displayed if
      annotation is not possible.
      
      Also, the file being accessed might not be /proc/kcore.  Tools can be
      directed to a different location using the --kallsyms option in which
      case kcore is expected to be in the same directory.  Adjust the message
      so it is not misleading in that case.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Li Zhang <zhlcindy@linux.vnet.ibm.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1440065260-8802-1-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      133de940
    • Adrian Hunter's avatar
      perf script: Fix segfault using --show-mmap-events · 05169df5
      Adrian Hunter authored
      Patch "perf script: Don't assume evsel position of tracking events"
      changed 'perf script' to use 'perf_evlist__id2evsel()'. That results
      in a segfault if there is more than 1 event and there are
      synthesized mmap events e.g.
      
      	$ perf record -e cycles,instructions -p$$ sleep 1
      	$ perf script --show-mmap-events
      	Segmentation fault (core dumped)
      
      That happens because these synthesized events have an 'id' of zero
      which does not match any 'evsel'.
      
      Currently, these synthesized events use the sample type of the first
      evsel.
      
      Change 'perf_evlist__id2evsel()' to reflect that which also makes
      it consistent with 'perf_evlist__event2evsel()'.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Fixes: 06b234ec ("perf script: Don't assume evsel position of tracking events")
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1440059205-1765-1-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      05169df5
    • Ingo Molnar's avatar
      perf/x86/msr: Fix the MSR driver build · 82819ffb
      Ingo Molnar authored
      The new MSR PMU driver made use of rdtsc() which does not exist (yet) in
      this tree:
      
        arch/x86/kernel/cpu/perf_event_msr.c:91:3: error: implicit declaration of function 'rdtsc'
      
      Use the old rdtscll() primitive for now.
      Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      82819ffb
  6. 20 Aug, 2015 3 commits
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · dd2281be
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
        - Support Intel PT in several tools, enabling the use of the processor trace
          feature introduced in Intel Broadwell processors: (Adrian Hunter)
      
      	 # dmesg | grep Performance
      	 # [0.188477] Performance Events: PEBS fmt2+, 16-deep LBR, Broadwell events, full-width counters, Intel PMU driver.
      	 # perf record -e intel_pt//u -a sleep 1
      	 [ perf record: Woken up 1 times to write data ]
      	 [ perf record: Captured and wrote 0.216 MB perf.data ]
      	 # perf script # then navigate in the tool output to some area, like this one:
      	 184 1030 dl_main (/usr/lib64/ld-2.17.so) => 7f21ba661440 dl_main (/usr/lib64/ld-2.17.so)
      	 185 1457 dl_main (/usr/lib64/ld-2.17.so) => 7f21ba669f10 _dl_new_object (/usr/lib64/ld-2.17.so)
      	 186 9f37 _dl_new_object (/usr/lib64/ld-2.17.so) => 7f21ba677b90 strlen (/usr/lib64/ld-2.17.so)
      	 187 7ba3 strlen (/usr/lib64/ld-2.17.so) => 7f21ba677c75 strlen (/usr/lib64/ld-2.17.so)
      	 188 7c78 strlen (/usr/lib64/ld-2.17.so) => 7f21ba669f3c _dl_new_object (/usr/lib64/ld-2.17.so)
      	 189 9f8a _dl_new_object (/usr/lib64/ld-2.17.so) => 7f21ba65fab0 calloc@plt (/usr/lib64/ld-2.17.so)
      	 190 fab0 calloc@plt (/usr/lib64/ld-2.17.so) => 7f21ba675e70 calloc (/usr/lib64/ld-2.17.so)
      	 191 5e87 calloc (/usr/lib64/ld-2.17.so) => 7f21ba65fa90 malloc@plt (/usr/lib64/ld-2.17.so)
      	 192 fa90 malloc@plt (/usr/lib64/ld-2.17.so) => 7f21ba675e60 malloc (/usr/lib64/ld-2.17.so)
      	 193 5e68 malloc (/usr/lib64/ld-2.17.so) => 7f21ba65fa80 __libc_memalign@plt (/usr/lib64/ld-2.17.so)
      	 194 fa80 __libc_memalign@plt (/usr/lib64/ld-2.17.so) => 7f21ba675d50 __libc_memalign (/usr/lib64/ld-2.17.so)
      	 195 5d63 __libc_memalign (/usr/lib64/ld-2.17.so) => 7f21ba675e20 __libc_memalign (/usr/lib64/ld-2.17.so)
      	 196 5e40 __libc_memalign (/usr/lib64/ld-2.17.so) => 7f21ba675d73 __libc_memalign (/usr/lib64/ld-2.17.so)
      	 197 5d97 __libc_memalign (/usr/lib64/ld-2.17.so) => 7f21ba675e18 __libc_memalign (/usr/lib64/ld-2.17.so)
      	 198 5e1e __libc_memalign (/usr/lib64/ld-2.17.so) => 7f21ba675df9 __libc_memalign (/usr/lib64/ld-2.17.so)
      	 199 5e10 __libc_memalign (/usr/lib64/ld-2.17.so) => 7f21ba669f8f _dl_new_object (/usr/lib64/ld-2.17.so)
      	 200 9fc2 _dl_new_object (/usr/lib64/ld-2.17.so) =>  7f21ba678e70 memcpy (/usr/lib64/ld-2.17.so)
      	 201 8e8c memcpy (/usr/lib64/ld-2.17.so) => 7f21ba678ea0 memcpy (/usr/lib64/ld-2.17.so)
      
        - Fix annotation of vdso (Adrian Hunter)
      
        - Fix DWARF callchains in 'perf script' (Jiri Olsa)
      
        - Fix adding probes in kernel syscalls and listing which variables can be
          collected at kernel syscall function lines (Masami Hiramatsu)
      
      Build Fixes:
      
        - Fix 32-bit compilation error in util/annotate.c (Adrian Hunter)
      
        - Support static linking with libdw on Fedora 22 (Andi Kleen)
      
      Infrastructure changes:
      
        - Add a helper function to probe whether cpu-wide tracing is possible (Adrian Hunter)
      
        - Move vfs_getname storage to per thread area in 'perf trace' (Arnaldo Carvalho de Melo)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      dd2281be
    • Ingo Molnar's avatar
    • Ingo Molnar's avatar
      Merge tag 'perf-urgent-for-mingo' of... · 19667649
      Ingo Molnar authored
      Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
      
        - Fix buildid processing done at the end of a 'perf record' session, a
          problem that happened in workloads involving lots of small short-lived
          processes.  That code was not asking the perf_session layer to order
          the events.
      
          Make the code more robust to handle some of the problems with such
          out-of-order events and fix 'perf record' to ask for ordered events
          on systems where we have perf_event_attr.sample_id_all.  (Adrian Hunter)
      
        - Show backtrace when handling a SIGSEGV in 'perf top --stdio' (Arnaldo Carvalho de Melo)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      19667649
  7. 19 Aug, 2015 3 commits