1. 04 1月, 2017 2 次提交
  2. 03 1月, 2017 1 次提交
    • M
      perf probe: Fix to get correct modname from elf header · 1f2ed153
      Masami Hiramatsu 提交于
      Since 'perf probe' supports cross-arch probes, it is possible to analyze
      different arch kernel image which has different bits-per-long.
      
      In that case, it fails to get the module name because it uses the
      MOD_NAME_OFFSET macro based on the host machine bits-per-long, instead
      of the target arch bits-per-long.
      
      This fixes above issue by changing modname-offset based on the target
      archs bit width. This is ok because linux kernel uses LP64 model on
      64bit arch.
      
      E.g. without this (on x86_64, and target module is arm32):
      
        $ perf probe -m build-arm/fs/configfs/configfs.ko -D configfs_lookup
        p:probe/configfs_lookup :configfs_lookup+0
                                ^-Here is an empty module name.
      
      With this fix, you can see correct module name:
      
        $ perf probe -m build-arm/fs/configfs/configfs.ko -D configfs_lookup
        p:probe/configfs_lookup configfs:configfs_lookup+0
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/148337043836.6752.383495516397005695.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1f2ed153
  3. 03 10月, 2016 1 次提交
  4. 29 9月, 2016 1 次提交
    • M
      perf probe: Fix to cut off incompatible chars from group name · 35726d3a
      Masami Hiramatsu 提交于
      Cut off the characters which can not use for group name of uprobes
      when making it based on executable filename.
      
      For example, if the exec name is libstdc++.so, without this fix
      perf probe generates "probe_libstdc++" as the group name, but
      it is failed to set because '+' can not be used for group name.
      
      With this fix perf accepts only alphabet, number or '_' for group
      name, thus perf generates "probe_libstdc" as the group name.
      
      E.g. with this fix, you can see the event name has no "+".
        ----
        $ ./perf probe -x /usr/lib64/libstdc++.so.6 -D is_open
        p:probe_libstdc/is_open /usr/lib64/libstdc++.so.6.0.22:0x8ca80
        p:probe_libstdc/is_open_1 /usr/lib64/libstdc++.so.6.0.22:0x8ca70
        p:probe_libstdc/is_open_2 /usr/lib64/libstdc++.so.6.0.22:0x8ca60
        p:probe_libstdc/is_open_3 /usr/lib64/libstdc++.so.6.0.22:0xb0ad0
        p:probe_libstdc/is_open_4 /usr/lib64/libstdc++.so.6.0.22:0xecca9
        ----
      
      Committer note:
      
      Before this fix:
      
        # perf probe -x /usr/lib64/libstdc++.so.6 is_open
        Failed to write event: Invalid argument
          Error: Failed to add events.
        #
      
      After the fix:
      
        # perf probe -x /usr/lib64/libstdc++.so.6 is_open
        Added new events:
          probe_libstdc:is_open (on is_open in /usr/lib64/libstdc++.so.6.0.22)
          probe_libstdc:is_open_1 (on is_open in /usr/lib64/libstdc++.so.6.0.22)
          probe_libstdc:is_open_2 (on is_open in /usr/lib64/libstdc++.so.6.0.22)
          probe_libstdc:is_open_3 (on is_open in /usr/lib64/libstdc++.so.6.0.22)
          probe_libstdc:is_open_4 (on is_open in /usr/lib64/libstdc++.so.6.0.22)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe_libstdc:is_open_4 -aR sleep 1
      
        # perf probe -l probe_libstdc:*
          probe_libstdc:is_open (on is_open@libstdc++-v3/include/fstream in /usr/lib64/libstdc++.so.6.0.22)
          probe_libstdc:is_open_1 (on is_open@libstdc++-v3/include/fstream in /usr/lib64/libstdc++.so.6.0.22)
          probe_libstdc:is_open_2 (on is_open@libstdc++-v3/include/fstream in /usr/lib64/libstdc++.so.6.0.22)
          probe_libstdc:is_open_3 (on is_open@src/c++98/basic_file.cc in /usr/lib64/libstdc++.so.6.0.22)
          probe_libstdc:is_open_4 (on stdio_filebuf:5@include/ext/stdio_filebuf.h in /usr/lib64/libstdc++.so.6.0.22)
        #
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/147464491667.29804.9553638175441827970.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      35726d3a
  5. 05 9月, 2016 1 次提交
  6. 01 9月, 2016 4 次提交
  7. 09 8月, 2016 4 次提交
  8. 19 7月, 2016 1 次提交
  9. 14 7月, 2016 6 次提交
    • M
      perf probe: Support a special SDT probe format · 7e9fca51
      Masami Hiramatsu 提交于
      Support a special SDT probe format which can omit the '%' prefix only if
      the SDT group name starts with "sdt_". So, for example both of
      "%sdt_libc:setjump" and "sdt_libc:setjump" are acceptable for perf probe
      --add.
      
      E.g. without this:
      
        # perf probe -a sdt_libc:setjmp
        Semantic error :There is non-digit char in line number.
        ...
      
      With this:
      
        # perf probe -a sdt_libc:setjmp
        Added new event:
          sdt_libc:setjmp      (on %setjmp in /usr/lib64/libc-2.20.so)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e sdt_libc:setjmp -aR sleep 1
      Suggested-by: NBrendan Gregg <brendan.d.gregg@gmail.com>
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/146831794674.17065.13359473252168740430.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7e9fca51
    • M
      perf probe: Support @BUILDID or @file suffix for SDT events · a598180a
      Masami Hiramatsu 提交于
      Support @BUILDID or @file suffix for SDT events. This allows perf to add
      probes on SDTs/pre-cached events on given FILE or the file which has
      given BUILDID (also, this complements BUILDID.)
      
      For example, both gcc and libstdc++ has same SDTs as below.  If you
      would like to add a probe on sdt_libstdcxx:catch on gcc, you can do as
      below.
      
        ----
        # perf list sdt | tail -n 6
          sdt_libstdcxx:catch@/usr/bin/gcc(0cc207fc4b27)     [SDT event]
          sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
          sdt_libstdcxx:rethrow@/usr/bin/gcc(0cc207fc4b27)   [SDT event]
          sdt_libstdcxx:rethrow@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
          sdt_libstdcxx:throw@/usr/bin/gcc(0cc207fc4b27)     [SDT event]
          sdt_libstdcxx:throw@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
        # perf probe -a %sdt_libstdcxx:catch@0cc
        Added new event:
          sdt_libstdcxx:catch  (on %catch in /usr/bin/gcc)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e sdt_libstdcxx:catch -aR sleep 1
        ----
      
      Committer note:
      
      Doing the full sequence of steps to get the results above:
      
      With a clean build-id cache:
      
        [root@jouet ~]# rm -rf ~/.debug/
        [root@jouet ~]# perf list sdt
      
        List of pre-defined events (to be used in -e):
      
        [root@jouet ~]#
      
      No events whatsoever, then, we can add all events in gcc to the build-id
      cache, doing a --add + --dry-run:
      
        [root@jouet ~]# perf probe --dry-run --cache -x /usr/bin/gcc --add %sdt_libstdcxx:\*
        Added new events:
          sdt_libstdcxx:throw  (on %* in /usr/bin/gcc)
          sdt_libstdcxx:rethrow (on %* in /usr/bin/gcc)
          sdt_libstdcxx:catch  (on %* in /usr/bin/gcc)
      
        You can now use it in all perf tools, such as:
      
      	perf record -e sdt_libstdcxx:catch -aR sleep 1
      
        [root@jouet ~]#
      
      It really didn't add any events, it just cached them:
      
        [root@jouet ~]# perf probe -l
        [root@jouet ~]#
      
      We can see that it was cached as:
      
        [root@jouet ~]# ls -la ~/.debug/usr/bin/gcc/9a0730e2bcc6d2a2003d21ac46807e8ee6bcb7c2/
        total 976
        drwxr-xr-x. 2 root root   4096 Jul 13 21:47 .
        drwxr-xr-x. 3 root root   4096 Jul 13 21:47 ..
        -rwxr-xr-x. 4 root root 985912 Jun 22 18:52 elf
        -rw-r--r--. 1 root root    303 Jul 13 21:47 probes
        [root@jouet ~]# file ~/.debug/usr/bin/gcc/9a0730e2bcc6d2a2003d21ac46807e8ee6bcb7c2/elf
        /root/.debug/usr/bin/gcc/9a0730e2bcc6d2a2003d21ac46807e8ee6bcb7c2/elf: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=9a0730e2bcc6d2a2003d21ac46807e8ee6bcb7c2, stripped
        [root@jouet ~]# cat ~/.debug/usr/bin/gcc/9a0730e2bcc6d2a2003d21ac46807e8ee6bcb7c2/probes
        %sdt_libstdcxx:throw=throw
        p:sdt_libstdcxx/throw /usr/bin/gcc:0x71ffd
        %sdt_libstdcxx:rethrow=rethrow
        p:sdt_libstdcxx/rethrow /usr/bin/gcc:0x720b8
        %sdt_libstdcxx:catch=catch
        p:sdt_libstdcxx/catch /usr/bin/gcc:0x7307f
        %sdt_libgcc:unwind=unwind
        p:sdt_libgcc/unwind /usr/bin/gcc:0x7eec0
        #sdt_libstdcxx:*=%*
        [root@jouet ~]#
      
      Ok, now we can use 'perf probe' to refer to those cached entries as:
      
        Humm, nope, doing as above we end up with:
      
        [root@jouet ~]# perf probe -a %sdt_libstdcxx:catch
        Semantic error :* is bad for event name -it must follow C symbol-naming rule.
          Error: Failed to add events.
        [root@jouet ~]#
      
      But it worked at some point, lets try not using --dry-run:
      
      Resetting everything:
      
        # rm -rf ~/.debug/
        # perf probe -d *:*
        # perf probe -l
        # perf list sdt
      
          List of pre-defined events (to be used in -e):
      
        #
      
      Ok, now it cached everything, even things we haven't asked it to
      (sdt_libgcc:unwind):
      
        [root@jouet ~]# perf probe -x /usr/bin/gcc --add %sdt_libstdcxx:\*
        Added new events:
          sdt_libstdcxx:throw  (on %* in /usr/bin/gcc)
          sdt_libstdcxx:rethrow (on %* in /usr/bin/gcc)
          sdt_libstdcxx:catch  (on %* in /usr/bin/gcc)
      
        You can now use it in all perf tools, such as:
      
      	perf record -e sdt_libstdcxx:catch -aR sleep 1
      
        [root@jouet ~]# perf list sdt
      
        List of pre-defined events (to be used in -e):
      
          sdt_libgcc:unwind                                  [SDT event]
          sdt_libstdcxx:catch                                [SDT event]
          sdt_libstdcxx:rethrow                              [SDT event]
          sdt_libstdcxx:throw                                [SDT event]
        [root@jouet ~]#
      
      And we have the events in place:
      
        [root@jouet ~]# perf probe -l
          sdt_libstdcxx:catch  (on execute_cfa_program+1551@../../../libgcc/unwind-dw2.c in /usr/bin/gcc)
          sdt_libstdcxx:rethrow (on d_print_subexpr+280@libsupc++/cp-demangle.c in /usr/bin/gcc)
          sdt_libstdcxx:throw  (on d_print_subexpr+93@libsupc++/cp-demangle.c in /usr/bin/gcc)
        [root@jouet ~]#
      
      And trying to use them at least has 'perf trace --event sdt*:*' working.
      
      Then, if we try to add the ones in libstdc++:
      
        [root@jouet ~]# perf probe -x /usr/lib64/libstdc++.so.6 -a %sdt_libstdcxx:\*
        Error: event "catch" already exists.
         Hint: Remove existing event by 'perf probe -d'
               or force duplicates by 'perf probe -f'
               or set 'force=yes' in BPF source.
          Error: Failed to add events.
        [root@jouet ~]#
      
      Doesn't work, dups, but at least this served to, unbeknownst to the user, add
      the SDT probes in /usr/lib64/libstdc++.so.6!
      
        [root@jouet ~]# perf list sdt
      
        List of pre-defined events (to be used in -e):
      
          sdt_libgcc:unwind                                  [SDT event]
          sdt_libstdcxx:catch@/usr/bin/gcc(9a0730e2bcc6)     [SDT event]
          sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event]
          sdt_libstdcxx:rethrow@/usr/bin/gcc(9a0730e2bcc6)   [SDT event]
          sdt_libstdcxx:rethrow@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event]
          sdt_libstdcxx:throw@/usr/bin/gcc(9a0730e2bcc6)     [SDT event]
          sdt_libstdcxx:throw@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event]
        [root@jouet ~]#
      
      Now we should be able to get to the original cset comment, if we remove all
      SDTs events in place, not from the cache, from the kernel, where it was set up as:
      
        [root@jouet ~]# ls -la /sys/kernel/debug/tracing/events/sdt_libstdcxx/
        total 0
        drwxr-xr-x.  5 root root 0 Jul 13 22:00 .
        drwxr-xr-x. 80 root root 0 Jul 13 21:56 ..
        drwxr-xr-x.  2 root root 0 Jul 13 22:00 catch
        -rw-r--r--.  1 root root 0 Jul 13 22:00 enable
        -rw-r--r--.  1 root root 0 Jul 13 22:00 filter
        drwxr-xr-x.  2 root root 0 Jul 13 22:00 rethrow
        drwxr-xr-x.  2 root root 0 Jul 13 22:00 throw
        [root@jouet ~]#
      
        [root@jouet ~]# head -2 /sys/kernel/debug/tracing/events/sdt_libstdcxx/throw/format
        name: throw
        ID: 2059
        [root@jouet ~]#
      
      Now to remove it:
      
        [root@jouet ~]# perf probe -d sdt_libstdc*:*
        Removed event: sdt_libstdcxx:catch
        Removed event: sdt_libstdcxx:rethrow
        Removed event: sdt_libstdcxx:throw
        [root@jouet ~]#
      
      Which caused:
      
        [root@jouet ~]# ls -la /sys/kernel/debug/tracing/events/sdt_libstdcxx/
        ls: cannot access '/sys/kernel/debug/tracing/events/sdt_libstdcxx/': No such file or directory
        [root@jouet ~]#
      
      Ok, now we can do:
      
        [root@jouet ~]# perf list sdt_libstdcxx:catch
      
        List of pre-defined events (to be used in -e):
      
          sdt_libstdcxx:catch@/usr/bin/gcc(9a0730e2bcc6)     [SDT event]
          sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event]
        [root@jouet ~]#
      
      So, these are not really 'pre-defined events', i.e. we can't use them with
      'perf record --event':
      
        [root@jouet ~]# perf record --event sdt_libstdcxx:catch*
        event syntax error: 'sdt_libstdcxx:catch*'
                             \___ unknown tracepoint
      
        Error:	File /sys/kernel/debug/tracing/events/sdt_libstdcxx/catch* not found.
        Hint:	Perhaps this kernel misses some CONFIG_ setting to enable this feature?.
      <SNIP>
        [root@jouet ~]#
      
      To have it really pre-defined we must use perf probe to get its definition from
      the cache and set it up in the kernel, creating the tracepoint to _then_ use it
      with 'perf record --event':
      
        [root@jouet ~]# perf probe -a sdt_libstdcxx:catch
        Semantic error :There is non-digit char in line number.
        <SNIP>
      
      Oops, there is another gotcha here, we need that pesky '%' character:
      
        [root@jouet ~]# perf probe -a %sdt_libstdcxx:catch
        Added new events:
          sdt_libstdcxx:catch  (on %catch in /usr/bin/gcc)
          sdt_libstdcxx:catch_1 (on %catch in /usr/lib64/libstdc++.so.6.0.22)
      
        You can now use it in all perf tools, such as:
      
      	perf record -e sdt_libstdcxx:catch_1 -aR sleep 1
      
        [root@jouet ~]#
      
      But then we added _two_ events, one with the name we expected, the other one
      with a _ added, when doing the analysis we need to pay attention to who maps to
      who.
      
      And here is where we get to the point of this patch, which is to be able to
      disambiguate those definitions for 'catch' in the build-id cache, but first we need
      remove those events we just added:
      
      [root@jouet ~]# perf probe -d %sdt_libstdcxx:catch
      
      Oops, that didn't remove anything, we need to _remove_ that % char in this case:
      
        [root@jouet ~]# perf probe -d sdt_libstdcxx:catch
        Removed event: sdt_libstdcxx:catch
      
      And we need to remove the other event added, i.e. I forgot to add a * at the end:
      
        [root@jouet ~]# perf probe -d sdt_libstdcxx:catch*
        Removed event: sdt_libstdcxx:catch_1
        [root@jouet ~]#
      
      Ok, disambiguating it using what is in this patch:
      
        [root@jouet ~]# perf list sdt_libstdcxx:catch
      
        List of pre-defined events (to be used in -e):
      
          sdt_libstdcxx:catch@/usr/bin/gcc(9a0730e2bcc6)     [SDT event]
          sdt_libstdcxx:catch@/usr/lib64/libstdc++.so.6.0.22(ef2b7066559a) [SDT event]
        [root@jouet ~]#
        [root@jouet ~]# perf probe -a %sdt_libstdcxx:catch@9a07
        Added new event:
          sdt_libstdcxx:catch  (on %catch in /usr/bin/gcc)
      
        You can now use it in all perf tools, such as:
      
      	perf record -e sdt_libstdcxx:catch -aR sleep 1
      
        [root@jouet ~]# perf probe -l
          sdt_libstdcxx:catch  (on execute_cfa_program+1551@../../../libgcc/unwind-dw2.c in /usr/bin/gcc)
        [root@jouet ~]#
      
      Yeah, it works! But we need to try and simplify this :-)
      
      Update: Some aspects of this simplification take place in the following
              patches.
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/146831793746.17065.13065062753978236612.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a598180a
    • M
      perf probe: Search SDT/cached event from all probe caches · 1de7b8bf
      Masami Hiramatsu 提交于
      Search SDT/cached event from all probe caches if user doesn't pass any
      binary. With this, we don't have to specify target binary for SDT and
      named cached events (which start with %).
      
      E.g. without this, a target binary must be passed with -x.
      
        # perf probe -x /usr/lib64/libc-2.20.so -a %sdt_libc:\*
      
      With this change, we don't need it anymore.
      
        # perf probe -a %sdt_libc:\*
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/146831792812.17065.2353705982669445313.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1de7b8bf
    • M
      perf probe: Allow wildcard for cached events · 42bba263
      Masami Hiramatsu 提交于
      Allo glob wildcard for reusing cached/SDT events. E.g.
      
        # perf probe -x /usr/lib64/libc-2.20.so -a %sdt_libc:\*
      
      This example adds probes for all SDT in libc.
      Note that the SDTs must have been scanned by perf buildid-cache.
      
      Committer note:
      
      Using it to check what of those SDT probes would take place when doing
      a cargo run (rust):
      
        # trace --no-sys --event sdt_libc:* cargo run
           0.000 sdt_libc:setjmp:(7f326b69c4d1))
          28.423 sdt_libc:setjmp:(7f4b0a5364d1))
          29.000 sdt_libc:setjmp:(7f4b0a5364d1))
          88.597 sdt_libc:setjmp:(7fc01fd414d1))
          89.220 sdt_libc:setjmp:(7fc01fd414d1))
          95.501 sdt_libc:setjmp:(7f326b69c4d1))
           Running `target/debug/hello_world`
          97.110 sdt_libc:setjmp:(7f95e09234d1))
        Hello, world!
        #
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/146831791813.17065.17846564230840594888.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      42bba263
    • M
      perf probe: Accept %sdt and %cached event name · 36a009fe
      Masami Hiramatsu 提交于
      To improve usability, support %[PROVIDER:]SDTEVENT format to add new
      probes on SDT and cached events.
      
      e.g.
        ----
        # perf probe -x /lib/libc-2.17.so  %lll_lock_wait_private
        Added new event:
          sdt_libc:lll_lock_wait_private (on %lll_lock_wait_private in /usr/lib/libc-2.17.so)
      
        You can now use it in all perf tools, such as:
      
                perf record -e sdt_libc:lll_lock_wait_private -aR sleep 1
      
        # perf probe -l | more
          sdt_libc:lll_lock_wait_private (on __lll_lock_wait_private+21 in /usr/lib/libc-2.17.so)
        ----
      
      Note that this is not only for SDT events, but also normal
      events with event-name.
      
      e.g. define "myevent" on cache (-n doesn't add the real probe)
        ----
        # perf probe -x ./perf --cache -n --add 'myevent=dso__load $params'
        ----
        Reuse the "myevent" from cache as below.
        ----
        # perf probe -x ./perf %myevent
        ----
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/146831788372.17065.3645054540325909346.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      36a009fe
    • M
      perf probe: Fix to show correct error message for $vars and $params · f6eb0518
      Masami Hiramatsu 提交于
      Fix to show correct error messages for $vars and $params because
      those special variables requires debug information to find the
      real variables or function parameters.
      
      E.g. without this fix;
        ----
        # perf probe -x /lib64/libc-2.23.so getaddrinfo \$params
        Failed to write event: Invalid argument
        Please upgrade your kernel to at least 3.14 to have access to feature $params
          Error: Failed to add events.
        ----
      
      Perf ends up with an error, but the message is not correct.  With this
      fix, perf shows correct error message as below.
      
        ----
        # perf probe -x /lib64/libc-2.23.so getaddrinfo \$params
        The /usr/lib64/libc-2.23.so file has no debug information.
        Rebuild with -g, or install an appropriate debuginfo package.
          Error: Failed to add events.
        ----
      Reported-and-Tested-by: NArnaldo Carvalho de Melo <acme@kernel.org>
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/146831787438.17065.6152436996780110699.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f6eb0518
  10. 13 7月, 2016 1 次提交
    • A
      tools: Introduce str_error_r() · c8b5f2c9
      Arnaldo Carvalho de Melo 提交于
      The tools so far have been using the strerror_r() GNU variant, that
      returns a string, be it the buffer passed or something else.
      
      But that, besides being tricky in cases where we expect that the
      function using strerror_r() returns the error formatted in a provided
      buffer (we have to check if it returned something else and copy that
      instead), breaks the build on systems not using glibc, like Alpine
      Linux, where musl libc is used.
      
      So, introduce yet another wrapper, str_error_r(), that has the GNU
      interface, but uses the portable XSI variant of strerror_r(), so that
      users rest asured that the provided buffer is used and it is what is
      returned.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-d4t42fnf48ytlk8rjxs822tf@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c8b5f2c9
  11. 05 7月, 2016 1 次提交
  12. 01 7月, 2016 2 次提交
  13. 23 6月, 2016 2 次提交
  14. 22 6月, 2016 1 次提交
  15. 16 6月, 2016 1 次提交
  16. 14 6月, 2016 3 次提交
  17. 10 5月, 2016 1 次提交
  18. 06 5月, 2016 1 次提交
  19. 28 4月, 2016 1 次提交
  20. 27 4月, 2016 3 次提交
    • R
      perf probe: Fix module probe issue if no dwarf support · c61fb959
      Ravi Bangoria 提交于
      Perf is not able to register probe in kernel module when dwarf supprt
      is not there(and so it goes for symtab). Perf passes full path of
      module where only module name is required which is causing the problem.
      This patch fixes this issue.
      
      Before applying patch:
      
        $ dpkg -s libdw-dev
        dpkg-query: package 'libdw-dev' is not installed and no information is...
      
        $ sudo ./perf probe -m /linux/samples/kprobes/kprobe_example.ko kprobe_init
        Added new event:
          probe:kprobe_init (on kprobe_init in /linux/samples/kprobes/kprobe_example.ko)
      
        You can now use it in all perf tools, such as:
      
        perf record -e probe:kprobe_init -aR sleep 1
      
        $ sudo cat /sys/kernel/debug/tracing/kprobe_events
        p:probe/kprobe_init /linux/samples/kprobes/kprobe_example.ko:kprobe_init
      
        $ sudo ./perf record -a -e probe:kprobe_init
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.105 MB perf.data ]
      
        $ sudo ./perf script 	# No output here
      
      After applying patch:
      
        $ sudo ./perf probe -m /linux/samples/kprobes/kprobe_example.ko kprobe_init
        Added new event:
          probe:kprobe_init    (on kprobe_init in kprobe_example)
      
        You can now use it in all perf tools, such as:
      
        perf record -e probe:kprobe_init -aR sleep 1
      
        $ sudo cat /sys/kernel/debug/tracing/kprobe_events
        p:probe/kprobe_init kprobe_example:kprobe_init
      
        $ sudo ./perf record -a -e probe:kprobe_init
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.105 MB perf.data (2 samples) ]
      
        $ sudo ./perf script
        insmod 13990 [002]  5961.216833: probe:kprobe_init: ...
        insmod 13995 [002]  5962.889384: probe:kprobe_init: ...
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1461680741-12517-1-git-send-email-ravi.bangoria@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c61fb959
    • R
      perf probe: Fix offline module name missmatch issue · 63a29613
      Ravi Bangoria 提交于
      Perf can add a probe on kernel module which has not been loaded yet.
      
      The current implementation finds the module name from path. But if the
      filename is different from the actual module name then perf fails to
      register a probe while loading module because of mismatch in the names.
      
      For example, samples/kobject/kobject-example.ko is loaded as
      kobject_example.
      
      Before applying patch:
      
        $ sudo ./perf probe -m /linux/samples/kobject/kobject-example.ko foo_show
          Added new event:
            probe:foo_show       (on foo_show in kobject-example)
      
          You can now use it in all perf tools, such as:
      
          perf record -e probe:foo_show -aR sleep 1
      
        $ cat /sys/kernel/debug/tracing/kprobe_events
          p:probe/foo_show kobject-example:foo_show
      
        $ insmod kobject-example.ko
      
        $ lsmod
          Module                  Size  Used by
          kobject_example        16384  0
      
        Generate read to /sys/kernel/kobject_example/foo while recording data
        with below command
        $ sudo ./perf record -e probe:foo_show -a
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 0.093 MB perf.data ]
      
        $./perf report --stdio -F overhead,comm,dso,sym
          Error:
          The perf.data.old file has no samples!
      
      After applying patch:
      
        $ sudo ./perf probe -m /linux/samples/kobject/kobject-example.ko foo_show
          Added new event:
            probe:foo_show       (on foo_show in kobject_example)
      
          You can now use it in all perf tools, such as:
      
          perf record -e probe:foo_show -aR sleep 1
      
        $ sudo cat /sys/kernel/debug/tracing/kprobe_events
          p:probe/foo_show kobject_example:foo_show
      
        $ insmod kobject-example.ko
      
        $ lsmod
          Module                  Size  Used by
          kobject_example        16384  0
      
        Generate read to /sys/kernel/kobject_example/foo while recording data
        with below command
        $ sudo ./perf record -e probe:foo_show -a
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 0.097 MB perf.data (8 samples) ]
      
        $ sudo ./perf report  --stdio -F overhead,comm,dso,sym
          ...
          # Samples: 8  of event 'probe:foo_show'
          # Event count (approx.): 8
          #
          # Overhead  Command  Shared Object      Symbol
          # ........  .......  .................  ............
          #
             100.00%  cat      [kobject_example]  [k] foo_show
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1461680741-12517-2-git-send-email-ravi.bangoria@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      63a29613
    • M
      perf probe: Set default kprobe group name if it is not given · 2a12ec13
      Masami Hiramatsu 提交于
      Set kprobe group name as "probe" if it is not given.
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20160426090413.11891.95640.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2a12ec13
  21. 26 4月, 2016 1 次提交
  22. 24 3月, 2016 1 次提交