1. 15 Jul, 2016 12 commits
  2. 14 Jul, 2016 21 commits
    • Arnaldo Carvalho de Melo's avatar
      tools: Make "__always_inline" just "inline" on Android · 8c98abff
      Arnaldo Carvalho de Melo authored
      As the gcc there is producing tons of:
      
        "warning: always_inline function might not be inlinable"
      
      At least on android-ndk-r12/platforms/android-24/arch-arm, so, for the
      time being, use this big hammer.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Chris Phlipot <cphlipot0@gmail.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-97l3eg3fnk5shmo4rsyyvj2t@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8c98abff
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Do not provide dup sched_getcpu() prototype on Android · 09dd39d2
      Arnaldo Carvalho de Melo authored
      The Bionic libc has this definition, so don't duplicate it.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Chris Phlipot <cphlipot0@gmail.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-rmd19832zkt07e4crdzyen9z@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      09dd39d2
    • Arnaldo Carvalho de Melo's avatar
      tools lib traceevent: Add correct header for ipv6 definitions · ca575ad2
      Arnaldo Carvalho de Melo authored
      We need to include netinet/in.h to get the in6_addr struct definition, needed to
      build it on the Android NDK:
      
        In file included from event-parse.c:36:0:
        /home/acme/android/android-ndk-r12/platforms/android-24/arch-arm/usr/include/netinet/ip6.h:82:18: error: field 'ip6_src' has incomplete type
          struct in6_addr ip6_src; /* source address */
      
      And it is the canonical way of getting IPv6 definitions, as described,
      for instance, in Linux's 'man ipv6'
      
      Doing that uncovers another problem: this source file uses PRIu64 but
      doesn't include it, depending on it being included by chance via the now
      replaced header (netinet/ip6.h), fix it.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Chris Phlipot <cphlipot0@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-tilr31n3yaba1whsd47qlwa3@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ca575ad2
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-20160713' of... · b29c6574
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-20160713' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      User visible changes:
      
      - Finish merging initial SDT (Statically Defined Traces) support, see
        cset comments for details about how it all works (Masami Hiramatsu)
      
      - Support attaching eBPF programs to tracepoints (Wang Nan)
      
      Infrastructure changes:
      
      - Fix up BITS_PER_LONG setting (Arnaldo Carvalho de Melo)
      
      - Add fallback from ELF_C_READ_MMAP to ELF_C_READ in objtool, fixing
        the build in libelf implementations lacking that elf_begin() cmd,
        such as Alpine Linux's (Arnaldo Carvalho de Melo)
      
      - Avoid checking code drift on busybox's diff in objtool (Arnaldo Carvalho de Melo)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      b29c6574
    • Masami Hiramatsu's avatar
      perf test: Add a test case for SDT event · 8e5dc848
      Masami Hiramatsu authored
      Add a basic test case for SDT event support.  This test scans an SDT
      event in perftools and check whether the SDT event is correctly stored
      into the buildid cache.
      
      Here is an example:
      
        ----
        $ perf test sdt -v
        47: Test SDT event probing                                   :
        --- start ---
        test child forked, pid 20732
        Found 72 SDTs in /home/mhiramat/ksrc/linux/tools/perf/perf
        Writing cache: %sdt_perf:test_target=test_target
        Cache committed: 0
        symbol:test_target file:(null) line:0 offset:0 return:0 lazy:(null)
        test child finished with 0
        ---- end ----
        Test SDT event probing: Ok
        ----
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo 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/146831796546.17065.1502584370844087537.stgit@devboxSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8e5dc848
    • Masami Hiramatsu's avatar
      perf build: Add sdt feature detection · e26e63be
      Masami Hiramatsu authored
      This checks whether sys/sdt.h is available or not, which is required for
      DTRACE_PROBE().
      
      We can disable this feature by passing NO_SDT=1 when building.
      
      This flag will be used for SDT test case and further SDT events in
      perftools.
      Signed-off-by: default avatarMasami 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/146831795615.17065.17513820540591053933.stgit@devboxSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e26e63be
    • Masami Hiramatsu's avatar
      perf probe: Support a special SDT probe format · 7e9fca51
      Masami Hiramatsu authored
      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: default avatarBrendan Gregg <brendan.d.gregg@gmail.com>
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7e9fca51
    • Masami Hiramatsu's avatar
      perf probe: Support @BUILDID or @FILE suffix for SDT events · a598180a
      Masami Hiramatsu authored
      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: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a598180a
    • Masami Hiramatsu's avatar
      perf list: Show SDT and pre-cached events · 40218dae
      Masami Hiramatsu authored
      Show SDT and pre-cached events by perf-list with "sdt". This also shows
      the binary and build-id where the events are placed only when there are
      same name events on different binaries.
      
      e.g.:
      
        # perf list sdt
      
        List of pre-defined events (to be used in -e):
      
          sdt_libc:lll_futex_wake                            [SDT event]
          sdt_libc:lll_lock_wait_private                     [SDT event]
          sdt_libc:longjmp                                   [SDT event]
          sdt_libc:longjmp_target                            [SDT event]
        ...
          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)
      
      The binary path and build-id are shown in below format;
      
        <GROUP>:<EVENT>@<PATH>(<BUILD-ID>)
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Tested-by: default avatarArnaldo 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/20160624090646.25421.44225.stgit@devboxSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      40218dae
    • Masami Hiramatsu's avatar
      perf probe: Search SDT/cached event from all probe caches · 1de7b8bf
      Masami Hiramatsu authored
      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: default avatarMasami 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1de7b8bf
    • Masami Hiramatsu's avatar
      perf probe: Allow wildcard for cached events · 42bba263
      Masami Hiramatsu authored
      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: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      42bba263
    • Masami Hiramatsu's avatar
      perf probe-cache: Add for_each_probe_cache_entry() wrapper · 05bf2c8a
      Masami Hiramatsu authored
      Add for_each_probe_cache_entry() wrapper macro for hiding list in
      probe_cache.
      Signed-off-by: default avatarMasami 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/146831790386.17065.15082256697569419710.stgit@devboxSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      05bf2c8a
    • Masami Hiramatsu's avatar
      perf probe: Make --list show only available cached events · c3492a3a
      Masami Hiramatsu authored
      Make "perf probe --cache --list" show only available cached events by
      checking build-id validity.
      
      E.g. without this patch:
        ----
        $ ./perf probe --cache --add oldevent=cmd_probe
        $ make #(to update ./perf)
        $ ./perf probe --cache --add newevent=cmd_probe
        $ ./perf probe --cache --list
        /home/mhiramat/ksrc/linux/tools/perf/perf (061e90539bac69
        probe_perf:newevent=cmd_probe
        /home/mhiramat/ksrc/linux/tools/perf/perf (c2e44d614e33e1
        probe_perf:oldevent=cmd_probe
        ----
      It shows both of old and new events but user can not use old one.
      With this;
        ----
        $ ./perf probe --cache -l
        /home/mhiramat/ksrc/linux/tools/perf/perf (061e90539bac69
        probe_perf:newevent=cmd_probe
        ----
      
      This shows only new events which are on the existing binary.
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.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/146831789417.17065.17896487479879669610.stgit@devboxSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c3492a3a
    • Masami Hiramatsu's avatar
      perf probe: Accept %sdt and %cached event name · 36a009fe
      Masami Hiramatsu authored
      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: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      36a009fe
    • Masami Hiramatsu's avatar
      perf probe: Fix to show correct error message for $vars and $params · f6eb0518
      Masami Hiramatsu authored
      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: default avatarArnaldo Carvalho de Melo <acme@kernel.org>
      Signed-off-by: default avatarMasami 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f6eb0518
    • Wang Nan's avatar
      perf bpf: Support BPF program attach to tracepoints · b4ee6d41
      Wang Nan authored
      To support 98b5c2c6 ("perf, bpf: allow bpf programs attach to
      tracepoints"), this patch allows BPF scripts to select tracepoints in
      their section name.
      
      Example:
      
        # cat test_tracepoint.c
        /*********************************************/
        #include <uapi/linux/bpf.h>
        #define SEC(NAME) __attribute__((section(NAME), used))
        SEC("raw_syscalls:sys_enter")
        int func(void *ctx)
        {
       	/*
       	 * /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/format:
       	 * ...
       	 * field:long id;	offset:8;	size:8;	signed:1;
       	 * ...
       	 * ctx + 8 select 'id'
       	 */
       	u64 id = *((u64 *)(ctx + 8));
       	if (id == 1)
       		return 1;
       	return 0;
        }
        SEC("_write=sys_write")
        int _write(void *ctx)
        {
       	return 1;
        }
        char _license[] SEC("license") = "GPL";
        int _version SEC("version") = LINUX_VERSION_CODE;
        /*********************************************/
        # perf record -e ./test_tracepoint.c  dd if=/dev/zero of=/dev/null count=5
        5+0 records in
        5+0 records out
        2560 bytes (2.6 kB) copied, 6.2281e-05 s, 41.1 MB/s
        [ perf record: Woken up 1 times to write data ]
        # perf script
               dd 13436 [005] 1596.490869: raw_syscalls:sys_enter: NR 1 (1, 178d000, 200, 7ffe82470d60, ffffffffffffe020, fffff
               dd 13436 [005] 1596.490871:  perf_bpf_probe:_write: (ffffffff812351e0)
               dd 13436 [005] 1596.490873: raw_syscalls:sys_enter: NR 1 (1, 178d000, 200, ffffffffffffe000, ffffffffffffe020, f
               dd 13436 [005] 1596.490874:  perf_bpf_probe:_write: (ffffffff812351e0)
               dd 13436 [005] 1596.490876: raw_syscalls:sys_enter: NR 1 (1, 178d000, 200, ffffffffffffe000, ffffffffffffe020, f
               dd 13436 [005] 1596.490876:  perf_bpf_probe:_write: (ffffffff812351e0)
               dd 13436 [005] 1596.490878: raw_syscalls:sys_enter: NR 1 (1, 178d000, 200, ffffffffffffe000, ffffffffffffe020, f
               dd 13436 [005] 1596.490879:  perf_bpf_probe:_write: (ffffffff812351e0)
               dd 13436 [005] 1596.490881: raw_syscalls:sys_enter: NR 1 (1, 178d000, 200, ffffffffffffe000, ffffffffffffe020, f
               dd 13436 [005] 1596.490882:  perf_bpf_probe:_write: (ffffffff812351e0)
               dd 13436 [005] 1596.490900: raw_syscalls:sys_enter: NR 1 (2, 7ffe8246e640, 1f, 40acb8, 7f44bac74700, 7f44baa4fba
               dd 13436 [005] 1596.490901:  perf_bpf_probe:_write: (ffffffff812351e0)
               dd 13436 [005] 1596.490917: raw_syscalls:sys_enter: NR 1 (2, 7ffe8246e640, 1a, fffffffa, 7f44bac74700, 7f44baa4f
               dd 13436 [005] 1596.490918:  perf_bpf_probe:_write: (ffffffff812351e0)
               dd 13436 [005] 1596.490932: raw_syscalls:sys_enter: NR 1 (2, 7ffe8246e640, 1a, fffffff9, 7f44bac74700, 7f44baa4f
               dd 13436 [005] 1596.490933:  perf_bpf_probe:_write: (ffffffff812351e0)
      
      Committer note:
      
      Further testing:
      
        # trace --no-sys --event /home/acme/bpf/tracepoint.c cat /etc/passwd > /dev/null
           0.000 raw_syscalls:sys_enter:NR 1 (1, 7f0490504000, c48, 7f0490503010, ffffffffffffffff, 0))
           0.006 perf_bpf_probe:_write:(ffffffff81241bc0))
        #
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468406646-21642-6-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b4ee6d41
    • Wang Nan's avatar
      perf bpf: Rename bpf__foreach_tev() to bpf__foreach_event() · cd102d70
      Wang Nan authored
      Following commit will allow BPF script attach to tracepoints.
      bpf__foreach_tev() will iterate over all events, not only kprobes.
      Rename it to bpf__foreach_event().
      
      Since only group and event are used by caller, there's no need to pass
      full 'struct probe_trace_event' to bpf_prog_iter_callback_t. Pass only
      these two strings. After this patch bpf_prog_iter_callback_t natually
      support tracepoints.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468406646-21642-5-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cd102d70
    • Wang Nan's avatar
      perf event parser: Add const qualifier to evt_name and sys_name · 8c619d6a
      Wang Nan authored
      Add missing 'const' qualifiers so following commits are able to create
      tracepoints using const strings.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468406646-21642-4-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8c619d6a
    • Wang Nan's avatar
      tools lib bpf: Report error when kernel doesn't support program type · 705fa219
      Wang Nan authored
      Now libbpf support tracepoint program type. Report meaningful error when kernel
      version is less than 4.7.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468406646-21642-3-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      705fa219
    • Wang Nan's avatar
      tools lib bpf: New API to adjust type of a BPF program · 5f44e4c8
      Wang Nan authored
      Add 4 new APIs to adjust and query the type of a BPF program.
      Load program according to type set by caller. Default is set to
      BPF_PROG_TYPE_KPROBE.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468406646-21642-2-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5f44e4c8
    • Arnaldo Carvalho de Melo's avatar
      objtool: Avoid checking code drift on busybox's diff · 1a4bf285
      Arnaldo Carvalho de Melo authored
      That doesn't have -I to match lines.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-1zqv1h6okt70e2huokkdtf1u@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1a4bf285
  3. 13 Jul, 2016 4 commits
    • Arnaldo Carvalho de Melo's avatar
      objtool: Add fallback from ELF_C_READ_MMAP to ELF_C_READ · 774bec3f
      Arnaldo Carvalho de Melo authored
      Not all libelf implementations have this "Please, ELF_C_READ, but use
      mmap if possible" elf_begin() cmd, so provide a fallback to plain old
      ELF_C_READ.
      
      Case in point: Alpine Linux 3.4.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-1fctuknrawgoi5xqon4mu9dv@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      774bec3f
    • Arnaldo Carvalho de Melo's avatar
      tools: Fix up BITS_PER_LONG setting · 2a00f026
      Arnaldo Carvalho de Melo authored
      It was set based on CONFIG_64BIT, that is available only when using
      Kconfig, which we're working towards but not to the point of having this
      CONFIG variable set, so synthesize it from available compiler defined
      defines, __SIZEOF_LONG__ or, lacking that, __WORDSIZE.
      
      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-og5fmkr17856lhupacihwxvb@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2a00f026
    • Ingo Molnar's avatar
      tools: Work around BITS_PER_LONG related build failure in objtool · 7b39cafb
      Ingo Molnar authored
      The objtool build fails with the recent changes to the bits-per-long
      headers:
      
        tools/include/linux/bitops.h:12:0: error: "BITS_PER_LONG" redefined [-Werror]
      
      Which got introduced by:
      
        bb970707 tools: Copy the bitsperlong.h files from the kernel
      
      Work it around for the time being.
      
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      7b39cafb
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-20160712' of... · 68cf16c6
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-20160712' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      User visible changes:
      
      - Add demangling of symbols in programs written in the Rust language (David Tolnay)
      
      - Add support for tracepoints in the python binding, including an example, that
        sets up and parses sched:sched_switch events, tools/perf/python/tracepoint.py
        (Jiri Olsa)
      
      - Introduce --stdio-color to set up the color output mode selection in
        'annotate' and 'report', allowing emit color escape sequences when
        redirecting the output of these tools (Arnaldo Carvalho de Melo)
      
      Infrastructure changes:
      
      - Various tweaks to allow the 'perf trace' beautifiers to build without using
        kernel headers and in a wider range of Linux distributions/releases
        (Arnaldo Carvalho de Melo)
      
      - Stop using kernel source files, instead copy what is needed and
        check when the original kernel source file gets modified, warning
        the developers about it. This helps in building the tool in older
        systems and even in recent ones, for just added kernel features
        for which ABI details (struct changes, defines, etc) still are not
        available on system headers (Arnaldo Carvalho de Melo)
      
      - Be consistent in how to use strerror_r, adding a wrapper that makes sure that
        it returns a pointer to passed buffer, and using the XSI variant, that is
        available in more libc implementations (Arnaldo Carvalho de Melo)
      
      - Avoid checking code drift on busibox's diff perf intel-pt-decoder, as it
        doesn't have the '-I' command line switch to check for regexps
        (Arnaldo Carvalho de Melo)
      
      - Add missing headers in various places (Arnaldo Carvalho de Melo)
      
      - Remove unneeded headers from various other places (Arnaldo Carvalho de Melo)
      
      - Add feature detection for gelf_getnote(), disabling SDT support if not
        present (Arnaldo Carvalho de Melo)
      
      - Fix oddities with GCC 5.3.0 by initializing some variables
        (Arnaldo Carvalho de Melo)
      
      - With those changes in place perf now builds on Alpine Linux 3.4, in addition to
        on centos (5, 6, 7), debian (7, 8, experimental), fedora (21, 22, 23, 24, rawhide),
        mageia 5, opensuse (13.2, 42.1) and ubuntu (12.04.5, 14.04.4, 15.10, 16.04) and
        will be test build on those systems prior to future pull requests.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      68cf16c6
  4. 12 Jul, 2016 3 commits
    • Steven Rostedt's avatar
      tools lib traceevent: Add filter on task CPU id · 6d248fbd
      Steven Rostedt authored
      Add a 'CPU' special field to allow the filter in trace-cmd report to
      filter on the task's CPU.
      
      By adding a special field 'CPU' (all caps) the user can now filter out
      tasks based on which CPU they are on. This is useful when filtering out
      (or in) a bunch of threads.
      
        -F 'CPU == 0'
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/20160712093306.5b058103@gandalf.local.homeSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6d248fbd
    • Jiri Olsa's avatar
      perf python: Add tracepoint example · 9881d7df
      Jiri Olsa authored
      To show how to enable a tracepoint and access its fields.
      
      Committer note:
      
      Testing it:
      
        # ls -l /tmp/build/perf/python/perf.so
        -rwxrwxr-x. 1 acme acme 1563256 Jul 12 16:19 /tmp/build/perf/python/perf.so
        # export PYTHONPATH=/tmp/build/perf/python/
        # tools/perf/python/tracepoint.py 2> /dev/null | head -200 | tail -10
        time 76345337296548 prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=tracepoint.py- next_pid=18479 next_prio=120
        time 76345338520479 prev_comm=gnome-shelln-b prev_pid=2186 prev_prio=120 prev_state=0x1 ==> next_comm=swapper/1 next_pid=0 next_prio=120
        time 76345337309942 prev_comm=tracepoint.py- prev_pid=18479 prev_prio=120 prev_state=0x1 ==> next_comm=swapper/0 next_pid=0 next_prio=120
        time 76345337312302 prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=tracepoint.py- next_pid=18479 next_prio=120
        time 76345337324927 prev_comm=tracepoint.py- prev_pid=18479 prev_prio=120 prev_state=0x1 ==> next_comm=swapper/0 next_pid=0 next_prio=120
        time 76345337327115 prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=tracepoint.py- next_pid=18479 next_prio=120
        time 76345338621750 prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=rcuos/2 next_pid=29 next_prio=120
        time 76345338607922 prev_comm=swapper/3 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=rcu_sched next_pid=7 next_prio=120
        time 76345337338817 prev_comm=tracepoint.py- prev_pid=18479 prev_prio=120 prev_state=0x1 ==> next_comm=swapper/0 next_pid=0 next_prio=120
        time 76345338627156 prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=head-terminal- next_pid=18480 next_prio=120
        #
        # strip /tmp/build/perf/python/perf.so
        # ls -l /tmp/build/perf/python/perf.so
        -rwxrwxr-x. 1 acme acme 319616 Jul 12 16:25 /tmp/build/perf/python/perf.so
      Reported-and-Tested-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1468148882-10362-10-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9881d7df
    • Jiri Olsa's avatar
      perf python: Add support to resolve tracepoint fields · bae57e38
      Jiri Olsa authored
      Adding tp_getattro callback for sample event. It resolves tracepoint
      fields in runtime.
      
      It's now possible to access tracepoint fields in normal fashion like
      hardcoded ones (see the example in the next patch).
      Reported-and-Tested-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1468148882-10362-9-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bae57e38