1. 07 Jun, 2015 4 commits
  2. 04 Jun, 2015 1 commit
  3. 03 Jun, 2015 1 commit
    • Wang Nan's avatar
      perf tools: Deal with kernel module names in '[]' correctly · 1f121b03
      Wang Nan authored
      Before patch ba92732e ('perf kmaps: Check kmaps to make code more
      robust'), 'perf report' and 'perf annotate' will segfault if trace data
      contains kernel module information like this:
      
       # perf report -D -i ./perf.data
       ...
       0 0 0x188 [0x50]: PERF_RECORD_MMAP -1/0: [0xffffffbff1018000(0xf068000) @ 0]: x [test_module]
       ...
      
       # perf report -i ./perf.data --objdump=/path/to/objdump --kallsyms=/path/to/kallsyms
      
       perf: Segmentation fault
       -------- backtrace --------
       /path/to/perf[0x503478]
       /lib64/libc.so.6(+0x3545f)[0x7fb201f3745f]
       /path/to/perf[0x499b56]
       /path/to/perf(dso__load_kallsyms+0x13c)[0x49b56c]
       /path/to/perf(dso__load+0x72e)[0x49c21e]
       /path/to/perf(map__load+0x6e)[0x4ae9ee]
       /path/to/perf(thread__find_addr_map+0x24c)[0x47deec]
       /path/to/perf(perf_event__preprocess_sample+0x88)[0x47e238]
       /path/to/perf[0x43ad02]
       /path/to/perf[0x4b55bc]
       /path/to/perf(ordered_events__flush+0xca)[0x4b57ea]
       /path/to/perf[0x4b1a01]
       /path/to/perf(perf_session__process_events+0x3be)[0x4b428e]
       /path/to/perf(cmd_report+0xf11)[0x43bfc1]
       /path/to/perf[0x474702]
       /path/to/perf(main+0x5f5)[0x42de95]
       /lib64/libc.so.6(__libc_start_main+0xf4)[0x7fb201f23bd4]
       /path/to/perf[0x42dfc4]
      
      This is because __kmod_path__parse treats '[' leading names as kernel
      name instead of names of kernel module.
      
      If perf.data contains build information and the buildid of such modules
      can be found, the dso->kernel of it will be set to DSO_TYPE_KERNEL by
      __event_process_build_id(), not kernel module.
      
      It will then be passed to dso__load() -> dso__load_kernel_sym() ->
      dso__load_kcore() if --kallsyms is provided.
      
      The refered patch adds NULL pointer checker to avoid segfault. However,
      such kernel modules are still processed incorrectly.
      
      This patch fixes __kmod_path__parse, makes it treat names like
      '[test_module]' as kernel modules.
      
      kmod-path.c is also update to reflect the above changes.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Link: http://lkml.kernel.org/r/1433321541-170245-1-git-send-email-wangnan0@huawei.com
      [ Fixed the merged with 0443f36b ("perf machine: Fix the search
        for the kernel DSO on the unified list" ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1f121b03
  4. 02 Jun, 2015 3 commits
  5. 01 Jun, 2015 1 commit
  6. 30 May, 2015 1 commit
    • Wang Nan's avatar
      perf probe: Fix segfault when glob matching function without debuginfo · 6bb536cc
      Wang Nan authored
      Commit 4c859351 ("perf probe: Support
      glob wildcards for function name") introduces segfault problems when
      debuginfo is not available:
      
       # perf probe 'sys_w*'
        Added new events:
        Segmentation fault
      
      The first problem resides in find_probe_trace_events_from_map(). In
      that function, find_probe_functions() is called to match each symbol
      against glob to find the number of matching functions, but still use
      map__for_each_symbol_by_name() to find 'struct symbol' for matching
      functions. Unfortunately, map__for_each_symbol_by_name() does
      exact matching by searching in an rbtree.
      
      It doesn't know glob matching, and not easy for it to support it because
      it use rbtree based binary search, but we are unable to ensure all names
      matched by the glob (any glob passed by user) reside in one subtree.
      
      This patch drops map__for_each_symbol_by_name(). Since there is no
      rbtree again, re-matching all symbols costs a lot. This patch avoid it
      by saving all matching results into an array (syms).
      
      The second problem is the lost of tp->realname. In
      __add_probe_trace_events(), if pev->point.function is glob, the event
      name should be set to tev->point.realname. This patch ensures its
      existence by strdup sym->name instead of leaving a NULL pointer there.
      
      After this patch:
      
       # perf probe 'sys_w*'
       Added new events:
         probe:sys_waitid     (on sys_w*)
         probe:sys_wait4      (on sys_w*)
         probe:sys_waitpid    (on sys_w*)
         probe:sys_write      (on sys_w*)
         probe:sys_writev     (on sys_w*)
      
       You can now use it in all perf tools, such as:
      
               perf record -e probe:sys_writev -aR sleep 1
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Link: http://lkml.kernel.org/r/1432892747-232506-1-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6bb536cc
  7. 29 May, 2015 15 commits
  8. 28 May, 2015 3 commits
  9. 27 May, 2015 11 commits
    • Andi Kleen's avatar
      perf annotation: Add symbol__get_annotation · 83be34a7
      Andi Kleen authored
      Add a new utility function to get an function annotation out of existing
      code.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1432749114-904-4-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      83be34a7
    • Jiri Olsa's avatar
      perf tools: Add hint for 'Too many events are opened.' error message · 18ffdfe8
      Jiri Olsa authored
      Enhancing the 'Too many events are opened.' error message with hint to
      use use 'ulimit -n <limit>' command.
      
      Before:
      
        $ perf record -e 'sched:*,syscalls:*' ls
        Error:
        Too many events are opened.
        Try again after reducing the number of events.
      
      Now:
      
        $ perf record -e 'sched:*,syscalls:*' ls
        Error:
        Too many events are opened.
        Probably the maximum number of open file descriptors has been reached.
        Hint: Try again after reducing the number of events.
        Hint: Try increasing the limit with 'ulimit -n <limit>'
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1432587114-14924-1-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      18ffdfe8
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Reference count struct map · 84c2cafa
      Arnaldo Carvalho de Melo authored
      We have pointers to struct map instances in several places, like in the
      hist_entry instances, so we need a way to know when we can destroy them,
      otherwise we may either keep leaking them or end up referencing deleted
      instances.
      
      Start fixing it by reference counting them.
      
      This patch puts the reference count for struct map in place, replacing
      direct map__delete() calls with map__put() ones and then grabbing a
      reference count when adding it to the maps struct where maps for a
      struct thread are kept.
      
      Next we'll grab reference counts when setting pointers to struct map
      instances, in places like in the hist_entry code.
      
      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: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-wi19xczk0t2a41r1i2chuio5@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      84c2cafa
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Check if a map is still in use when deleting it · facf3f06
      Arnaldo Carvalho de Melo authored
      I.e. match RB_CLEAR_NODE() with RB_EMPTY_NODE(), to check that it isn't
      in a rb tree at the time of its deletion.
      
      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: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-vumvhird765id11zbx00d2r8@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      facf3f06
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Protect accesses the map rbtrees with a rw lock · 6a2ffcdd
      Arnaldo Carvalho de Melo authored
      To allow concurrent access, next step: refcount struct map instances, so
      that we can ditch maps->removed_maps and stop leaking threads, maps,
      then struct DSO needs the same treatment.
      
      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: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-o45w2w5dzrza38nzqxnqzhyf@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6a2ffcdd
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Introduce struct maps · 1eee78ae
      Arnaldo Carvalho de Melo authored
      That for now has the maps rbtree and the list for the dead maps, that
      may be still referenced from some hist_entry, etc.
      
      This paves the way for protecting the rbtree with a lock, then refcount
      the maps and finally remove the removed_maps list, as it'll not ne
      anymore needed.
      
      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: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-fl0fa6142pj8khj97fow3uw0@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1eee78ae
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · 6632c4b4
      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:
      
      New features:
      
        - Add option in 'perf sched' to merge like comms to lat output (Josef Bacik)
      
        - Improve 'perf probe' error messages when not finding a
          suitable vmlinux (Masami Hiramatsu)
      
      Infrastructure changes:
      
        - Use atomic.h for various pre-existing reference counts (Arnaldo Carvalho de Melo)
      
        - Leg work for refcounting 'struct map' (Arnaldo Carvalho de Melo)
      
        - Assign default value for some pointers (Martin Liška)
      
        - Improve setting of gcc debug option (Martin Liška)
      
        - Separate the tests and tools in installation (Nam T. Nguyen)
      
        - Reduce number of arguments of hist_entry_iter__add() (Namhyung Kim)
      
        - DSO data cache fixes (Namhyung Kim)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      6632c4b4
    • Masami Hiramatsu's avatar
      perf probe: Fix an error when deleting probes successfully · dddc7ee3
      Masami Hiramatsu authored
      Fix a bug in del_perf_probe_events() which returns an error (-ENOENT)
      even if the probes are successfully deleted.
      
      This happens only if the probes are on user-apps and not on kernel,
      simply because it doesn't clear the previous error.
      
      So, without this fix, we get an error even though events are being
      successfully removed.
      
        ------
        # ./perf probe -x ./perf del_perf_probe_events
        Added new event:
          probe_perf:del_perf_probe_events (on del_perf_probe_events in ...
      
        You can now use it in all perf tools, such as:
      
                perf record -e probe_perf:del_perf_probe_events -aR sleep 1
      
        # ./perf probe -d \*:\*
        Removed event: probe_perf:del_perf_probe_events
          Error: Failed to delete events.
        ------
      
      This fixes the above error.
        ------
        # ./perf probe -d \*:\*
        Removed event: probe_perf:del_perf_probe_events
        ------
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@kernel.org>
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Richard Weinberger <richard@nod.at>
      Link: http://lkml.kernel.org/r/20150527083725.23880.45209.stgit@localhost.localdomainSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      dddc7ee3
    • Masami Hiramatsu's avatar
      perf probe: Show the error reason comes from invalid DSO · 419e8738
      Masami Hiramatsu authored
      Show the reason of error when dso__load* fails. This shows when user
      gives wrong kernel image or wrong path.
      
      Without this, perf probe shows an obscure message:
      
        ----
        $ perf probe -k ~/kbin/linux-3.x86_64/vmlinux -L vfs_read
        Failed to find path of kernel module.
          Error: Failed to show lines.
        ----
      
      With this, perf shows appropriate error message:
      
        ----
        $ perf probe -k ~/kbin/linux-3.x86_64/vmlinux -L vfs_read
        Failed to find the path for kernel: Mismatching build id
          Error: Failed to show lines.
        ----
      
      And:
      
        ----
        $ perf probe -k /non-exist/kernel/vmlinux -L vfs_read
        Failed to find the path for kernel: No such file or directory
          Error: Failed to show lines.
        ----
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Richard Weinberger <richard@nod.at>
      Link: http://lkml.kernel.org/r/20150527083718.23880.84100.stgit@localhost.localdomainSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      419e8738
    • Adrian Hunter's avatar
      perf tools: Disallow PMU events intel_pt and intel_bts until there is support · 9b5d1c29
      Adrian Hunter authored
      Disallow PMU events intel_pt and intel_bts until the tools support them.
      
      By default any PMU is selectable as an event but until the tools have
      intel_pt and intel_bts support using them would result in no data being
      recorded without any indication as to why.
      
      Before the change:
      
          $ perf record -e intel_bts// sleep 1
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 0.008 MB perf.data ]
          $ perf report --stdio
          Error:
          The perf.data file has no samples!
      
      After the change:
      
          $ perf record -e intel_bts// sleep 1
          invalid or unsupported event: 'intel_bts//'
          Run 'perf list' for a list of valid events
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1432295653-13989-2-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9b5d1c29
    • Josef Bacik's avatar
      perf sched: Add option to merge like comms to lat output · 2f80dd44
      Josef Bacik authored
      Sometimes when debugging large multi-threaded applications it is helpful
      to collate all of the latency numbers into one bulk record to get an
      idea of what is going on.
      
      This patch does this by merging any entries that belong to the same comm
      into one entry and then spits out those totals.
      
      I've also slightly changed the output so you can see how many threads
      were merged in the processing.  Here is the new default output format
      
       -----------------------------------------------------------------------------------------------------------
        Task                 | Runtime ms  | Switches | Average delay ms | Maximum delay ms | Maximum delay at    |
       -----------------------------------------------------------------------------------------------------------
        chrome:(23)          |  740.878 ms |     2612 | avg:    0.022 ms | max:    0.845 ms | max at: 7935.254223 s
        pulseaudio:1523      |   94.440 ms |      597 | avg:    0.027 ms | max:    0.110 ms | max at: 7934.668372 s
        threaded-ml:6042     |   72.554 ms |      386 | avg:    0.035 ms | max:    1.186 ms | max at: 7935.330911 s
        Chrome_IOThread:3832 |   52.388 ms |      456 | avg:    0.021 ms | max:    1.365 ms | max at: 7935.330602 s
        Chrome_ChildIOT:(7)  |   50.694 ms |      743 | avg:    0.021 ms | max:    1.448 ms | max at: 7935.256659 s
        Compositor:5510      |   30.012 ms |      192 | avg:    0.019 ms | max:    0.131 ms | max at: 7936.636815 s
        plugin_audio_th:6043 |   24.828 ms |      314 | avg:    0.018 ms | max:    0.143 ms | max at: 7936.205994 s
        CompositorTileW:(2)  |   14.099 ms |       45 | avg:    0.022 ms | max:    0.153 ms | max at: 7937.521800 s
      
      the (#) after the task is the number of tasks merged, and then if there were
      no tasks merged it just shows the pid.  Here is the same trace file with the -p
      option to print the per-pid latency numbers
      
       -----------------------------------------------------------------------------------------------------------
        Task                 | Runtime ms  | Switches | Average delay ms | Maximum delay ms | Maximum delay at    |
       -----------------------------------------------------------------------------------------------------------
        chrome:5500          |  386.872 ms |      387 | avg:    0.023 ms | max:    0.241 ms | max at: 7936.001694 s
        pulseaudio:1523      |   94.440 ms |      597 | avg:    0.027 ms | max:    0.110 ms | max at: 7934.668372 s
        threaded-ml:6042     |   72.554 ms |      386 | avg:    0.035 ms | max:    1.186 ms | max at: 7935.330911 s
        chrome:10226         |   69.710 ms |      251 | avg:    0.023 ms | max:    0.764 ms | max at: 7935.992305 s
        chrome:4267          |   64.551 ms |      418 | avg:    0.021 ms | max:    0.294 ms | max at: 7937.862427 s
        chrome:4827          |   62.268 ms |       54 | avg:    0.029 ms | max:    0.666 ms | max at: 7935.992813 s
        Chrome_IOThread:3832 |   52.388 ms |      456 | avg:    0.021 ms | max:    1.365 ms | max at: 7935.330602 s
        chrome:3776          |   46.150 ms |      349 | avg:    0.023 ms | max:    0.845 ms | max at: 7935.254223 s
      Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: kernel-team@fb.com
      Link: http://lkml.kernel.org/r/1432300720-30478-1-git-send-email-jbacik@fb.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2f80dd44