Skip to content
  1. Nov 12, 2014
  2. Nov 07, 2014
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · 322cd21f
      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:
      
      Infrastructure changes:
      
       - Add gzip decompression support for kernel modules (Namhyung Kim)
      
       - More prep patches for Intel PT, including a a thread stack and
         more stuff made available via the database export mechanism (Adrian Hunter)
      
       - Optimize checking that tracepoint events are defined in perf script perl/python (Jiri Olsa)
      
       - Do not free pevent when deleting tracepoint evsel (Jiri Olsa)
      
       - Fix build-id matching for vmlinux (Namhyung Kim)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      322cd21f
    • Jiri Olsa's avatar
      perf evsel: Do not call pevent_free_format when deleting tracepoint · daa01794
      Jiri Olsa authored
      
      
      The libtraceevent library's main handle 'struct pevent' holds pointers
      of every event that was added to it via functions:
      
        pevent_parse_format
        pevent_parse_event
      
      We can't release struct event_format (call pevent_free_format)
      separately, because that breaks that pointers array mentioned above and
      another add_event call could end up with segfault.
      
      All added events are released within the handle cleanup in pevent_free.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/1415098538-1512-1-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      daa01794
    • Jiri Olsa's avatar
      perf script python: Removing event cache as it's no longer needed · adf5bcf3
      Jiri Olsa authored
      
      
      We don't need to maintain cache of 'struct event_format' objects.
      Currently the 'struct perf_evsel' holds this reference already.
      
      Adding events_defined bitmap to keep track of defined events, which is
      much cheaper than array of pointers.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung Kim <namhyung@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1414363445-22370-3-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      adf5bcf3
    • Jiri Olsa's avatar
      perf script perl: Removing event cache as it's no longer needed · cdae2d1e
      Jiri Olsa authored
      
      
      We don't need to maintain cache of 'struct event_format' objects.
      Currently the 'struct perf_evsel' holds this reference already.
      
      Adding events_defined bitmap to keep track of defined events, which is
      much cheaper than array of pointers.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung Kim <namhyung@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1414363445-22370-2-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cdae2d1e
    • Jiri Olsa's avatar
      perf tools: Add test_and_set_bit function · 416c419c
      Jiri Olsa authored
      
      
      Set a bit and return its old value. Stolen from kernel sources, will be
      used in next patches.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung Kim <namhyung@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1414363445-22370-1-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      416c419c
  3. Nov 05, 2014
    • Namhyung Kim's avatar
      perf tools: Make vmlinux short name more like kallsyms short name · 96d78059
      Namhyung Kim authored
      
      
      The previous patch changed kernel dso name from '[kernel.kallsyms]' to
      vmlinux.  However it might add confusion to old users accustomed to the
      old name.  So change the short name to '[kernel.vmlinux]' to reduce such
      confusion.
      
      Before:
        # Overhead  Command         Shared Object            Symbol
        # ........  ..............  .......................  ...............................
        #
             9.83%  swapper         vmlinux                  [k] intel_idle
             4.10%  awk             libc-2.20.so             [.] __strcmp_sse2
             1.86%  sed             libc-2.20.so             [.] __strcmp_sse2
             1.78%  netctl-auto     libc-2.20.so             [.] __strcmp_sse2
             1.23%  netctl-auto     libc-2.20.so             [.] __mbrtowc
             1.21%  firefox         libxul.so                [.] 0x00000000024b62bd
             1.20%  swapper         vmlinux                  [k] cpuidle_enter_state
             1.03%  sleep           vmlinux                  [k] copy_user_generic_unrolled
      
      After:
        # Overhead  Command         Shared Object            Symbol
        # ........  ..............  .......................  ...............................
        #
             9.83%  swapper         [kernel.vmlinux]         [k] intel_idle
             4.10%  awk             libc-2.20.so             [.] __strcmp_sse2
             1.86%  sed             libc-2.20.so             [.] __strcmp_sse2
             1.78%  netctl-auto     libc-2.20.so             [.] __strcmp_sse2
             1.23%  netctl-auto     libc-2.20.so             [.] __mbrtowc
             1.21%  firefox         libxul.so                [.] 0x00000000024b62bd
             1.20%  swapper         [kernel.vmlinux]         [k] cpuidle_enter_state
             1.03%  sleep           [kernel.vmlinux]         [k] copy_user_generic_unrolled
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415063674-17206-9-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      96d78059
    • Namhyung Kim's avatar
      perf tools: Fix build-id matching on vmlinux · b837a8bd
      Namhyung Kim authored
      There's a problem on finding correct kernel symbols when perf report
      runs on a different kernel.  Although a part of the problem was solved
      by the prior commit 0a7e6d1b
      
       ("perf tools: Check recorded kernel
      version when finding vmlinux"), there's a remaining problem still.
      
      When perf records samples, it synthesizes the kernel map using
      machine__mmap_name() and ref_reloc_sym like "[kernel.kallsyms]_text".
      You can easily see it using 'perf report -D' command.
      
      After finishing record, it goes through the recorded events to find
      maps/dsos actually used.  And then record build-id info of them.
      
      During this process, it needs to load symbols in a dso and it'd call
      dso__load_vmlinux_path() since the default value of the symbol_conf.
      try_vmlinux_path is true.  However it changes dso->long_name to a real
      path of the vmlinux file (e.g. /lib/modules/3.16.4/build/vmlinux) if one
      is running on a custom kernel.
      
      It resulted in that perf report reads the build-id of the vmlinux, but
      cannot use it since it only knows about the [kernel.kallsyms] map.  It
      then falls back to possible vmlinux paths by using the recorded kernel
      version (in case of a recent version) or a running kernel silently.
      
      Even with the recent tools, this still has a possibility of breaking
      the result.  As the build directory is a symbolic link, if one built a
      new kernel in the same directory with different source/config, the old
      link to vmlinux will point the new file.  So it's absolutely needed to
      use build-id when finding a kernel image.
      
      In this patch, it's now changed to try to search a kernel dso in the
      existing dso list which was constructed during build-id table parsing
      so it'll always have a build-id.  If not found, search "[kernel.kallsyms]".
      
      Before:
      
        $ perf report
        # Children      Self  Command  Shared Object      Symbol
        # ........  ........  .......  .................  ...............................
        #
            72.15%     0.00%  swapper  [kernel.kallsyms]  [k] set_curr_task_rt
            72.15%     0.00%  swapper  [kernel.kallsyms]  [k] native_calibrate_tsc
            72.15%     0.00%  swapper  [kernel.kallsyms]  [k] tsc_refine_calibration_work
            71.87%    71.87%  swapper  [kernel.kallsyms]  [k] module_finalize
         ...
      
      After (for the same perf.data):
      
            72.15%     0.00%  swapper  vmlinux  [k] cpu_startup_entry
            72.15%     0.00%  swapper  vmlinux  [k] arch_cpu_idle
            72.15%     0.00%  swapper  vmlinux  [k] default_idle
            71.87%    71.87%  swapper  vmlinux  [k] native_safe_halt
         ...
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: http://lkml.kernel.org/r/20140924073356.GB1962@gmail.com
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415063674-17206-8-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b837a8bd
    • Namhyung Kim's avatar
      perf record: Do not save pathname in ./debug/.build-id directory for vmlinux · 00dc8657
      Namhyung Kim authored
      
      
      When perf record finishes a session, it pre-processes samples in order
      to write build-id info from DSOs that had samples.
      
      During this process it'll call map__load() for the kernel map, and it
      ends up calling dso__load_vmlinux_path() which replaces dso->long_name.
      
      But this function checks kernel's build-id before searching vmlinux path
      so it'll end up with a cryptic name, the pathname for the entry in the
      ~/.debug cache, which can be confusing to users.
      
      This patch adds a flag to skip the build-id check during record, so
      that it'll have the original vmlinux path for the kernel dso->long_name,
      not the entry in the ~/.debug cache.
      
      Before:
        # perf record -va sleep 3
        mmap size 528384B
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.196 MB perf.data (~8545 samples) ]
        Looking at the vmlinux_path (7 entries long)
        Using /home/namhyung/.debug/.build-id/f0/6e17aa50adf4d00b88925e03775de107611551 for symbols
      
      After:
        # perf record -va sleep 3
        mmap size 528384B
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.193 MB perf.data (~8432 samples) ]
        Looking at the vmlinux_path (7 entries long)
        Using /lib/modules/3.16.4-1-ARCH/build/vmlinux for symbols
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415063674-17206-7-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      00dc8657
    • Namhyung Kim's avatar
      perf build-id: Move build-id related functions to util/build-id.c · e195fac8
      Namhyung Kim authored
      
      
      It'd be better managing those functions in a separate place as
      util/header.c file is already big.
      
      It now exports following 3 functions to others:
      
        bool perf_session__read_build_ids(struct perf_session *session, bool with_hits);
        int perf_session__write_buildid_table(struct perf_session *session, int fd);
        int perf_session__cache_build_ids(struct perf_session *session);
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Link: http://lkml.kernel.org/r/545733E7.6010105@intel.com
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415063674-17206-5-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e195fac8
    • Namhyung Kim's avatar
      perf build-id: Rename dsos__write_buildid_table() · 714c9c4a
      Namhyung Kim authored
      
      
      The dsos__write_buildid_table() is not use struct dso and it mostly
      uses perf_session struct.
      
      So rename it to perf_session__write_buildid_ table() so that it
      corresponds to other related functions such as
      perf_session__read_build_ids() and perf_session__cache_build_ids().
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415063674-17206-4-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      714c9c4a
    • Namhyung Kim's avatar
      perf tools: Add gzip decompression support for kernel module · e92ce12e
      Namhyung Kim authored
      
      
      Now my Archlinux box shows module symbols correctly.
      
      Before:
        $ perf report --stdio
        Failed to open /tmp/perf-3477.map, continuing without symbols
        no symbols found in /usr/bin/date, maybe install a debug package?
        No kallsyms or vmlinux with build-id 7b4ea0a49ae2111925857099aaf05c3246ff33e0 was found
        [drm] with build id 7b4ea0a49ae2111925857099aaf05c3246ff33e0 not found, continuing without symbols
        No kallsyms or vmlinux with build-id edd931629094b660ca9dec09a1b635c8d87aa2ee was found
        [jbd2] with build id edd931629094b660ca9dec09a1b635c8d87aa2ee not found, continuing without symbols
        No kallsyms or vmlinux with build-id a7b1eada671c34933e5610bb920b2ca4945a82c3 was found
        [ext4] with build id a7b1eada671c34933e5610bb920b2ca4945a82c3 not found, continuing without symbols
        No kallsyms or vmlinux with build-id d69511fa3e5840e770336ef45b06c83fef8d74e3 was found
        [scsi_mod] with build id d69511fa3e5840e770336ef45b06c83fef8d74e3 not found, continuing without symbols
        No kallsyms or vmlinux with build-id af0430af13461af058770ee9b87afc07922c2e77 was found
        [libata] with build id af0430af13461af058770ee9b87afc07922c2e77 not found, continuing without symbols
        No kallsyms or vmlinux with build-id aaeedff8160ce631a5f0333591c6ff291201d29f was found
        [libahci] with build id aaeedff8160ce631a5f0333591c6ff291201d29f not found, continuing without symbols
        No kallsyms or vmlinux with build-id c57907712becaf662dc4981824bb372c0441d605 was found
        [mac80211] with build id c57907712becaf662dc4981824bb372c0441d605 not found, continuing without symbols
        No kallsyms or vmlinux with build-id e0589077cc0ec8c3e4c40eb9f2d9e69d236bee8f was found
        [iwldvm] with build id e0589077cc0ec8c3e4c40eb9f2d9e69d236bee8f not found, continuing without symbols
        No kallsyms or vmlinux with build-id 2d86086bf136bf374a2f029cf85a48194f9b950b was found
        [cfg80211] with build id 2d86086bf136bf374a2f029cf85a48194f9b950b not found, continuing without symbols
        No kallsyms or vmlinux with build-id 4493c48599bdb3d91d0f8db5150e0be33fdd9221 was found
        [iwlwifi] with build id 4493c48599bdb3d91d0f8db5150e0be33fdd9221 not found, continuing without symbols
        ...
        #
        # Overhead  Command          Shared Object            Symbol
        # ........  ...............  .......................  ........................................................
        #
             0.03%  swapper          [ext4]                   [k] 0x000000000000fe2e
             0.03%  swapper          [kernel.kallsyms]        [k] account_entity_enqueue
             0.03%  swapper          [ext4]                   [k] 0x000000000000fc2b
             0.03%  irq/50-iwlwifi   [iwlwifi]                [k] 0x000000000000200b
             0.03%  swapper          [kernel.kallsyms]        [k] ktime_add_safe
             0.03%  swapper          [kernel.kallsyms]        [k] elv_completed_request
             0.03%  swapper          [libata]                 [k] 0x0000000000003997
             0.03%  swapper          [libahci]                [k] 0x0000000000001f25
             0.03%  swapper          [kernel.kallsyms]        [k] rb_next
             0.03%  swapper          [kernel.kallsyms]        [k] blk_finish_request
             0.03%  swapper          [ext4]                   [k] 0x0000000000010248
             0.00%  perf             [kernel.kallsyms]        [k] native_write_msr_safe
      
      After:
        $ perf report --stdio
        Failed to open /tmp/perf-3477.map, continuing without symbols
        no symbols found in /usr/bin/tr, maybe install a debug package?
        ...
        #
        # Overhead  Command          Shared Object                Symbol
        # ........  ...............  ...........................  ......................................................
        #
      
             0.04%  kworker/u16:3    [ext4]                       [k] ext4_read_block_bitmap
             0.03%  kworker/u16:0    [mac80211]                   [k] ieee80211_sta_reset_beacon_monitor
             0.02%  irq/50-iwlwifi   [mac80211]                   [k] ieee80211_get_bssid
             0.02%  firefox          [e1000e]                     [k] __ew32_prepare
             0.02%  swapper          [libahci]                    [k] ahci_handle_port_interrupt
             0.02%  emacs            libglib-2.0.so.0.4000.0      [.] g_mutex_unlock
             0.02%  swapper          [e1000e]                     [k] e1000_clean_tx_irq
             0.02%  dwm              [kernel.kallsyms]            [k] __schedule
             0.02%  gnome-terminal-  [vdso]                       [.] __vdso_clock_gettime
             0.02%  swapper          [e1000e]                     [k] e1000_alloc_rx_buffers
             0.02%  irq/50-iwlwifi   [mac80211]                   [k] ieee80211_rx
             0.01%  firefox          [vdso]                       [.] __vdso_gettimeofday
             0.01%  irq/50-iwlwifi   [iwlwifi]                    [k] iwl_pcie_rxq_restock.part.13
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/87h9yexshi.fsf@sejong.aot.lge.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e92ce12e
  4. Nov 04, 2014
    • Namhyung Kim's avatar
      perf symbols: Preparation for compressed kernel module support · c00c48fc
      Namhyung Kim authored
      
      
      This patch adds basic support to handle compressed kernel module as some
      distro (such as Archlinux) carries on it now.  The actual work using
      compression library will be added later.
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415063674-17206-2-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c00c48fc
    • Adrian Hunter's avatar
      perf tools: Defer export of comms that were not 'set' · 758008b2
      Adrian Hunter authored
      
      
      Tracing for a workload begins before the comm event is seen, which
      results in the initial comm having a string of the form ":<pid>" (e.g.
      ":12345").
      
      In order to export the correct string, defer the export until the new
      script 'flush' callback.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414678188-14946-8-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      758008b2
    • Adrian Hunter's avatar
      perf tools: Add call information to Python export · 6a70307d
      Adrian Hunter authored
      
      
      Add the ability to export detailed information about paired calls and
      returns to Python db export and the export-to-postgresql.py script.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414678188-14946-7-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6a70307d
    • Adrian Hunter's avatar
      perf tools: Add call information to the database export API · 88f50d60
      Adrian Hunter authored
      
      
      Make it possible for the database export API to use the enhanced thread
      stack and export detailed information about paired calls and returns.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414678188-14946-6-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      88f50d60
    • Adrian Hunter's avatar
      perf tools: Add branch_type and in_tx to Python export · c29414f5
      Adrian Hunter authored
      
      
      Add branch_type and in_tx to Python db export and the
      export-to-postgresql.py script.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414678188-14946-4-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c29414f5
    • Adrian Hunter's avatar
      perf tools: Add branch type to db export · f2bff007
      Adrian Hunter authored
      
      
      Add the ability to export branch types through the database export
      facility.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414678188-14946-3-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f2bff007
    • Adrian Hunter's avatar
      perf tools: Enhance the thread stack to output call/return data · 92a9e4f7
      Adrian Hunter authored
      
      
      Enhance the thread stack to output detailed information about paired
      calls and returns.
      
      The enhanced processing consumes sample information via
      thread_stack__process() and outputs information about paired calls /
      returns via a call-back.
      
      While the call-back makes it possible for the facility to be used by
      arbitrary tools, a subsequent patch will provide the information to
      Python scripting via the db-export interface.
      
      An important part of the call/return information is the
      call path which provides a structure that defines a context
      sensitive call graph.
      
      Note that there are now two ways to use the thread stack.
      
      For simply providing a call stack (like you would get from the perf
      record -g option) the interface consists of thread_stack__event() and
      thread_stack__sample().
      
      Whereas the enhanced interface consists of call_return_processor__new()
      and thread_stack__process().
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414678188-14946-5-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      92a9e4f7
    • Adrian Hunter's avatar
      perf tools: Add a thread stack for synthesizing call chains · 00447ccd
      Adrian Hunter authored
      
      
      Add a thread stack for synthesizing call chains from call and return
      events.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414678188-14946-2-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      00447ccd
  5. Oct 30, 2014
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · 05b2537e
      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 from Arnaldo Carvalho de Melo:
      
      User visible changes:
      
       - Don't open the DWARF info multiple times, keeping instead a dwfl handle
         in struct dso, greatly speeding up 'perf report' on powerpc. (Sukadev Bhattiprolu)
      
       - Introduce PARSE_OPT_DISABLED option flag and use it to avoid showing
         undersired options in tools that provides frontends to 'perf record', like
         sched, kvm, etc (Namhyung Kim)
      
      Infrastructure changes:
      
       - More Intel PT work, including a facility to export sample data (comms,
         threads, symbol names, etc) in a database friendly way, with an script to use
         this to create a postgresql database. (Adrian Hunter)
      
       - Use make sure that thread->mg->machine points to the machine where
         the thread exists (it was being set only for the kmaps kernel modules
         case, do it as well for the mmaps) and use it to shorten function
         signatures (Arnaldo Carvalho de Melo)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      05b2537e
    • Ingo Molnar's avatar
      Merge tag 'perf-urgent-for-mingo' of... · d785452c
      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 report -F (abort, in_tx, mispredict, etc) segfaults for sample.data files
         without branch info (Jiri Olsa)
      
       - Add patch that should have went in a previous patchkit to use global cache
         provided by libunwind (Namhyung Kim)
      
       - Make CPUINFO_PROC an array to support different kernels, problem
         detected when the information reported via /proc/cpuinfo changed on ARM (Wang Nan)
      
       - 'perf probe' --demangle typo fix and a new --quiet option (Masami Hiramatsu)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d785452c
  6. Oct 29, 2014
    • Adrian Hunter's avatar
      perf session: Add perf_session__deliver_synth_event() · a293829d
      Adrian Hunter authored
      
      
      Add a function to deliver synthesized events from within a session.
      
      Intel PT decoding works by synthesizing events (primarily branch events)
      that can then be consumed by existing tools.  This function will be used
      to deliver those events.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414417770-18602-3-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a293829d
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Use evlist__for_each in a few remaining places · cba9b847
      Arnaldo Carvalho de Melo authored
      
      
      Where direct use of the longer form using list_for_entry() was being
      used.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-v4fw80flg25nkl8jgeod3ot9@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cba9b847
    • Adrian Hunter's avatar
      perf tools: Add id index · 3c659eed
      Adrian Hunter authored
      
      
      Add an index of the event identifiers, in preparation for Intel PT.
      
      The event id (also called the sample id) is a unique number
      allocated by the kernel to the event created by perf_event_open().  Events
      can include the event id by having a sample type including PERF_SAMPLE_ID or
      PERF_SAMPLE_IDENTIFIER.
      
      Currently the main use of the event id is to match an event back to the
      evsel to which it belongs i.e. perf_evlist__id2evsel()
      
      The purpose of this patch is to make it possible to match an event back to
      the mmap from which it was read.  The reason that is useful is because the
      mmap represents a time-ordered context (either for a cpu or for a thread).
      Intel PT decodes trace information on that basis.  In full-trace mode, that
      information can be recorded when the Intel PT trace is read, but in
      sample-mode the Intel PT trace data is embedded in a sample and it is in
      that case that the "id index" is needed.
      
      So the mmaps are numbered (idx) and the cpu and tid recorded against the id
      by perf_evlist__set_sid_idx() which is called by perf_evlist__mmap_per_evsel().
      
      That information is recorded on the perf.data file in the new "id index".
      idx, cpu and tid are added to struct perf_sample_id (which is the node of
      evlist's hash table to match ids to evsels).  The information can be
      retrieved using perf_evlist__id2sid().  Note however this all depends on
      having a sample type including PERF_SAMPLE_ID or PERF_SAMPLE_IDENTIFIER,
      otherwise ids are not recorded.
      
      The "id index" is a synthesized event record which will be created when
      Intel PT sampling is used by calling perf_event__synthesize_id_index().
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414417770-18602-2-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3c659eed
    • Masami Hiramatsu's avatar
      perf probe: Add --quiet option to suppress output result message · 5e17b28f
      Masami Hiramatsu authored
      
      
      Add --quiet(-q) option to suppress output result message for --add, and
      --del options (Note that --lines/funcs/vars are not affected). This
      option is useful if you run the perf probe inside your scripts.
      
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/20141027203131.21219.35170.stgit@localhost.localdomain
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5e17b28f
    • Adrian Hunter's avatar
      perf script: Add Python script to export to postgresql · 2987e32f
      Adrian Hunter authored
      
      
      Add a Python script to export to a postgresql database.
      
      The script requires the Python pyside module and the Qt PostgreSQL
      driver.  The packages needed are probably named "python-pyside" and
      "libqt4-sql-psql"
      
      The caller of the script must be able to create postgresql databases.
      
      The script takes the database name as a parameter.  The database and
      database tables are created.  Data is written to flat files which are
      then imported using SQL COPY FROM.
      
      Example:
      
        $ perf record ls
        ...
        $ perf script report export-to-postgresql lsdb
        2014-02-14 10:55:38.631431 Creating database...
        2014-02-14 10:55:39.291958 Writing to intermediate files...
        2014-02-14 10:55:39.350280 Copying to database...
        2014-02-14 10:55:39.358536 Removing intermediate files...
        2014-02-14 10:55:39.358665 Adding primary keys
        2014-02-14 10:55:39.658697 Adding foreign keys
        2014-02-14 10:55:39.667412 Done
        $ psql lsdb
        lsdb-# \d
                    List of relations
         Schema |      Name       | Type  | Owner
        --------+-----------------+-------+-------
         public | comm_threads    | table | acme
         public | comms           | table | acme
         public | dsos            | table | acme
         public | machines        | table | acme
         public | samples         | table | acme
         public | samples_view    | view  | acme
         public | selected_events | table | acme
         public | symbols         | table | acme
         public | threads         | table | acme
        (9 rows)
        lsdb-# \d samples
               Table "public.samples"
            Column     |  Type   | Modifiers
        ---------------+---------+-----------
         id            | bigint  | not null
         evsel_id      | bigint  |
         machine_id    | bigint  |
         thread_id     | bigint  |
         comm_id       | bigint  |
         dso_id        | bigint  |
         symbol_id     | bigint  |
         sym_offset    | bigint  |
         ip            | bigint  |
         time          | bigint  |
         cpu           | integer |
         to_dso_id     | bigint  |
         to_symbol_id  | bigint  |
         to_sym_offset | bigint  |
         to_ip         | bigint  |
         period        | bigint  |
         weight        | bigint  |
         transaction   | bigint  |
         data_src      | bigint  |
        Indexes:
            "samples_pkey" PRIMARY KEY, btree (id)
        Foreign-key constraints:
            "commfk" FOREIGN KEY (comm_id) REFERENCES comms(id)
            "dsofk" FOREIGN KEY (dso_id) REFERENCES dsos(id)
            "evselfk" FOREIGN KEY (evsel_id) REFERENCES selected_events(id)
            "machinefk" FOREIGN KEY (machine_id) REFERENCES machines(id)
            "symbolfk" FOREIGN KEY (symbol_id) REFERENCES symbols(id)
            "threadfk" FOREIGN KEY (thread_id) REFERENCES threads(id)
            "todsofk" FOREIGN KEY (to_dso_id) REFERENCES dsos(id)
            "tosymbolfk" FOREIGN KEY (to_symbol_id) REFERENCES symbols(id)
      
        lsdb-# \d samples_view
                       View "public.samples_view"
              Column       |          Type           | Modifiers
        -------------------+-------------------------+-----------
         id                | bigint                  |
         time              | bigint                  |
         cpu               | integer                 |
         pid               | integer                 |
         tid               | integer                 |
         command           | character varying(16)   |
         event             | character varying(80)   |
         ip_hex            | text                    |
         symbol            | character varying(2048) |
         sym_offset        | bigint                  |
         dso_short_name    | character varying(256)  |
         to_ip_hex         | text                    |
         to_symbol         | character varying(2048) |
         to_sym_offset     | bigint                  |
         to_dso_short_name | character varying(256)  |
      
          lsdb=# select * from samples_view;
      
         id| time       |cpu | pid  | tid  |command| event  |   ip_hex      |           symbol    |sym_off| dso_name|to_ip_hex|to_symbol|to_sym_off|to_dso_name
         --+------------+----+------+------+-------+--------+---------------+---------------------+-------+---------+---------+---------+----------+----------
         1 |12202825015 | -1 | 7339 | 7339 |:17339 | cycles | fffff8104d24a |native_write_msr_safe|    10 | [kernel]| 0       | unknown |         0| unknown
         2 |12203258804 | -1 | 7339 | 7339 |:17339 | cycles | fffff8104d24a |native_write_msr_safe|    10 | [kernel]| 0       | unknown |         0| unknown
         3 |12203988119 | -1 | 7339 | 7339 |:17339 | cycles | fffff8104d24a |native_write_msr_safe|    10 | [kernel]| 0       | unknown |         0| unknown
      
      My notes (which may be out-of-date) on setting up postgresql so you can
      create databases:
      
      fedora:
      
              $ sudo yum install postgresql postgresql-server python-pyside qt-postgresql
              $ sudo su - postgres -c initdb
              $ sudo service postgresql start
              $ sudo su - postgres
              $ createuser -s <your username>
      
      I used the the unix user name in createuser.
      
      If it fails, try createuser without -s and answer the following question
      to allow your user to create tables:
      
              Shall the new role be a superuser? (y/n) y
      
      ubuntu:
      
              $ sudo apt-get install postgresql
              $ sudo su - postgres
              $ createuser <your username>
              Shall the new role be a superuser? (y/n) y
      
      You may want to disable automatic startup.  One way is to edit
      /etc/postgresql/9.3/main/start.conf.  Another is to disable the init
      script e.g. sudo update-rc.d postgresql disable
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414061124-26830-8-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2987e32f
    • Adrian Hunter's avatar
      perf scripting python: Extend interface to export data in a database-friendly way · df919b40
      Adrian Hunter authored
      
      
      Use the new db_export facility to export data in a database-friendly
      way.
      
      A Python script selects the db_export mode by setting a global variable
      'perf_db_export_mode' to True.  The script then optionally implements
      functions to receive table rows.  The functions are:
      
      	evsel_table
      	machine_table
      	thread_table
      	comm_table
      	dso_table
      	symbol_table
      	sample_table
      
      An example script is provided in a subsequent patch.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414061124-26830-7-git-send-email-adrian.hunter@intel.com
      [ Reserve space for per symbol db_id space when perf_db_export_mode is on ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      df919b40
    • Adrian Hunter's avatar
      perf tools: Add facility to export data in database-friendly way · 0db15b1e
      Adrian Hunter authored
      
      
      This patch introduces an abstraction for exporting sample data in a
      database-friendly way.  The abstraction does not implement the actual
      output.  A subsequent patch takes this facility into use for extending
      the script interface.
      
      The abstraction is needed because static data like symbols, dsos, comms
      etc need to be exported only once.  That means allocating them a unique
      identifier and recording it on each structure.  The member 'db_id' is
      used for that.  'db_id' is just a 64-bit sequence number.
      
      Exporting centres around the db_export__sample() function which exports
      the associated data structures if they have not yet been allocated a
      db_id.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414061124-26830-6-git-send-email-adrian.hunter@intel.com
      [ committer note: Stash db_id using symbol_conf.priv_size + symbol__priv() and foo->priv areas ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0db15b1e
    • Arnaldo Carvalho de Melo's avatar
      perf pmu: Add proper error handling to print_pmu_events() · 7e4772dc
      Arnaldo Carvalho de Melo authored
      
      
      It was silently returning or printing "(null)" when no memory was
      available at various points. Fix it by checking and warning the user
      when that happens.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-835udmf66x9nza504cu6irz9@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7e4772dc
    • Adrian Hunter's avatar
      perf tools: Do not attempt to run perf-read-vdso32 if it wasn't built · 46b1fa85
      Adrian Hunter authored
      
      
      popen() causes an error message to print if perf-read-vdso32 does not
      run.  Avoid that by not trying to run it if it was not built.  Ditto
      perf-read-vdsox32.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414061124-26830-17-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      46b1fa85
    • Adrian Hunter's avatar
      perf tools: Add support for 32-bit compatibility VDSOs · f6832e17
      Adrian Hunter authored
      
      
      'perf record' post-processes the event stream  to create a list of
      build-ids for object files for which sample events have been recorded.
      That results in those object files being recorded in the build-id cache.
      
      In the case of VDSO, perf tools reads it from memory and copies it into
      a temporary file, which as decribed above, gets added to the build-id
      cache.
      
      Then when the perf.data file is processed by other tools, the build-id
      of VDSO is listed in the perf.data file and the VDSO can be read from
      the build-id cache.  In that case the name of the map, the short name of
      the DSO, and the entry in the build-id cache are all "[vdso]".
      
      However, in the 64-bit case, there also can be 32-bit compatibility
      VDSOs.
      
      A previous patch added programs "perf-read-vdso32" and "perf
      read-vdsox32".
      
      This patch uses those programs to read the correct VDSO for a thread and
      create a temporary file just as for the 64-bit VDSO.
      
      The map name and the entry in the build-id cache are still "[vdso]" but
      the DSO short name becomes "[vdso32]" and "[vdsox32]" respectively.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414061124-26830-16-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f6832e17
    • Adrian Hunter's avatar
      perf tools: Build programs to copy 32-bit compatibility · e477f3f0
      Adrian Hunter authored
      
      
      perf tools copy VDSO out of memory.  However, on 64-bit machines there
      may be 32-bit compatibility VDOs also.  To copy those requires separate
      32-bit executables.
      
      This patch adds to the build additional programs perf-read-vdso32 and
      perf-read-vdsox32 for 32-bit and x32 respectively.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>,
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414061124-26830-15-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e477f3f0
    • Adrian Hunter's avatar
      perf pmu: Let pmu's with no events show up on perf list · 42634bc7
      Adrian Hunter authored
      
      
      perf list only lists PMUs with events.  Add a flag to cause a PMU to be
      also listed separately.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414061124-26830-3-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      42634bc7
    • Wang Nan's avatar
      perf tools: Ensure return negative value when write header error · ed307758
      Wang Nan authored
      
      
      When 'perf record' write headers, it calls write_xxx in
      tools/perf/util/header.c, and check return value. It rolls back all
      working only when return value is negative.
      
      This patch ensures write_cpudesc() and write_total_mem() return negative number
      when error. Without this patch, headers reported by 'perf report' header is
      error in some platform. Following output is caputured on ARM, which doesn't
      contain "Processor" field in /proc/cpuinfo. See "cpudesc", "total memory" and
      "cmdline" field.
      
         bash-4.2# perf record ls
         ...
         [ perf record: Woken up 1 times to write data ]
         [ perf record: Captured and wrote 0.001 MB perf.data (~36 samples) ]
         bash-4.2# perf report --stdio --header
         Error:
         The perf.data file has no samples!
         # ========
         # captured on: Fri Sep 12 10:09:10 2014
         # hostname : arma15el
         # os release : 3.17.0+
         # perf version : 3.10.53
         # arch : armv7l
         # nrcpus online : 4
         # nrcpus avail : 1
         # cpudesc : (null)
         # total memory : 0 kB
         # cmdline :
         # event : name = cycles, type = 0, config = 0x0, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, excl_host = 0, excl_guest = 1, precise_ip = 0
         # pmu mappings: not available
         # ========
         #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Waiman Long <Waiman.Long@hp.com>
      Link: http://lkml.kernel.org/r/1413428909-80017-1-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ed307758
    • Namhyung Kim's avatar
      perf probe: Use PARSE_OPT_EXCLUSIVE flag · 13dcbbc0
      Namhyung Kim authored
      
      
      The perf probe command has some exclusive options.  Use new PARSE_OPT_EXCLUSIVE
      flag to simplify the code and show more compact usage.
      
        $ perf probe -l -a foo
          Error: switch `a' cannot be used with switch `l'
      
         usage: perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]
            or: perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]
            or: perf probe [<options>] --del '[GROUP:]EVENT' ...
            or: perf probe --list
            or: perf probe [<options>] --line 'LINEDESC'
            or: perf probe [<options>] --vars 'PROBEPOINT'
      
            -a, --add <[EVENT=]FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT [[NAME=]ARG ...]>
                                  probe point definition, where
      		GROUP:	Group name (optional)
      		EVENT:	Event name
      		FUNC:	Function name
      		OFF:	Offset from function entry (in byte)
      		%return:	Put the probe at function return
      		SRC:	Source code path
      		RL:	Relative line number from function entry.
      		AL:	Absolute line number in file.
      		PT:	Lazy expression of line code.
      		ARG:	Probe argument (local variable name or
      			kprobe-tracer argument format.)
      
            -l, --list            list up current probe events
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarHemant Kumar <hemant@linux.vnet.ibm.com>
      Acked-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1413990949-13953-6-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      13dcbbc0
    • Namhyung Kim's avatar
      perf tools: Add support for exclusive option · 42bd71d0
      Namhyung Kim authored
      
      
      Some options cannot be used at the same time.  To handle such options
      add a new PARSE_OPT_EXCLUSIVE flag and show error message if more than
      one of them is used.
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Reviewed-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Acked-by: default avatarHemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1413990949-13953-5-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      42bd71d0
    • Namhyung Kim's avatar
      perf kvm: Print kvm specific --help output · f45d20ff
      Namhyung Kim authored
      
      
      The 'perf kvm stat record' tool is an alias of 'perf record' with
      predefined kvm related options. All options that passed to 'perf kvm
      stat record' are processed by the 'perf record' tool. So, 'perf kvm
      stat record --help' prints help of usage for the 'perf record'
      command. There are a few options useful for 'perf kvm stat record',
      the rest either break kvm related output or don't change it.
      
      Let's print safe for 'perf kvm stat record' options in addition to
      general 'perf record' --help output.
      
      With this patch, new output looks like below:
      
        $ perf kvm stat record -h
      
         usage: perf kvm stat record [<options>]
      
            -p, --pid <pid>       record events on existing process id
            -t, --tid <tid>       record events on existing thread id
            -r, --realtime <n>    collect data with this RT SCHED_FIFO priority
                --no-buffering    collect data without buffering
            -a, --all-cpus        system-wide collection from all CPUs
            -C, --cpu <cpu>       list of cpus to monitor
            -c, --count <n>       event period to sample
            -o, --output <file>   output file name
            -i, --no-inherit      child tasks do not inherit counters
            -m, --mmap-pages <pages>
                                  number of mmap data pages
            -v, --verbose         be more verbose (show counter open errors, etc)
            -q, --quiet           don't print any message
            -s, --stat            per thread counts
            -D, --delay <n>       ms to wait before starting measurement after program start
            -u, --uid <user>      user to profile
                --per-thread      use per-thread mmaps
      
        $ perf kvm stat record -n sleep 1
          Error: switch `n' is not usable
      
         usage: perf kvm stat record [<options>]
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarHemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1413990949-13953-4-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f45d20ff
    • Namhyung Kim's avatar
      perf tools: Export usage string and option table of perf record · e5b2c207
      Namhyung Kim authored
      
      
      Those are shared with other builtin commands like kvm, script.  So
      make it accessable from them.  This is a preparation of later change
      that limiting possible options.
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarHemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1413990949-13953-3-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e5b2c207
    • Namhyung Kim's avatar
      perf tools: Add PARSE_OPT_DISABLED flag · d152d1be
      Namhyung Kim authored
      
      
      In some cases, we need to reuse exising options with some of them
      disabled.  To do that, add PARSE_OPT_DISABLED flag and
      set_option_flag() function.
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarHemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1413990949-13953-2-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d152d1be