Commit Graph

603497 Commits

Author SHA1 Message Date
Adrian Hunter 25af37f4e1 x86/insn: Add AVX-512 support to the instruction decoder
Add support for Intel's AVX-512 instructions to the instruction decoder.

AVX-512 instructions are documented in Intel Architecture Instruction
Set Extensions Programming Reference (February 2016).

AVX-512 instructions are identified by a EVEX prefix which, for the
purpose of instruction decoding, can be treated as though it were a
4-byte VEX prefix.

Existing instructions which can now accept an EVEX prefix need not be
further annotated in the op code map (x86-opcode-map.txt). In the case
of new instructions, the op code map is updated accordingly.

Also add associated Mask Instructions that are used to manipulate mask
registers used in AVX-512 instructions.

The 'perf tools' instruction decoder is updated in a subsequent patch.
And a representative set of instructions is added to the perf tools new
instructions test in a subsequent patch.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: X86 ML <x86@kernel.org>
Link: http://lkml.kernel.org/r/1469003437-32706-3-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-21 09:37:11 -03:00
Adrian Hunter 6f6ef07f41 x86/insn: perf tools: Fix vcvtph2ps instruction decoding
vcvtph2ps does not have an immediate operand, so remove the erroneous
'Ib' from its opcode map entry. Add vcvtph2ps to the perf tools new
instructions test to verify it.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: X86 ML <x86@kernel.org>
Link: http://lkml.kernel.org/r/1469003437-32706-2-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-20 09:57:46 -03:00
Ingo Molnar 5048c2af07 perf/core improvements and fixes:
User visible:
 
 - Properly report when a function wildcard produces no matches in 'perf probe'
   (Masami Hiramatsu)
 
 - Balance opening and reading events in 'perf stat', which could cause
   it to get stuck trying to close invalid file descriptors (Mark Rutland)
 
 Infrastructure:
 
 - Copy more headers from the kernel, this time for headers that
   were just including the contents of its kernel counterparts, should
   help resolving the problems with linux-next, where some uapi related
   patches seem to be breaking tools/object/ build.
 
   Some more combing will be done, but at least it is possible to build
   perf out of tree, via a detached tarball (make help | grep perf)
   without including kernel files in its MANIFEST (Arnaldo Carvalho de Melo)
 
 - Fix smatch found errors that were not causing problems, but are
   mistakes nonetheless (Dan Carpenter)
 
 - Fix string vs byte array resolving in the python script code (Jiri Olsa)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJXjWXkAAoJENZQFvNTUqpAHksQAJ8q8gTRzjF8BKh8PL1LF3T5
 JeJ1/duxnaWFF1zt0Z/H7B17m7RFGA8sqG7/O35kxGuzZPGAPDb7B4msInXKlq8t
 dsO49Kw3ffpNiq2douNqj52RlsC2+Togmtz2FhJPAO0LkPZiukOjp/XcQBEuhh2B
 4a5rls+5G7UeMUdUzDKPIBBIvZM/L0Y9nx2UdnQeDNDbKxe/WcyJlY1yG3d1WvXy
 hFjbMwU92al/dGbbXp0ppaiKfLblf0UsisEVaujb/p4cQzV/NgPzUpyUWSrpWMfO
 AbCD8sZWuoIKolPJZ1XF7vHpXTRPfDJtU5bNBiH1HCCE4aMsjwVq+g6Frcg579ld
 IgcLmnb4zvGHUyDR03jUDtYKlYKY/liyynivrD5fv9IVrv/CVyLrpMbhNm8G+83+
 9xwwpzHyFDEhvvP2N7yg1Cb1BFx4yCE2ETFeSgot77JtGCl/CXK+aNjQOlw7TY7l
 Im/MRGUF5WdBi5bHmig66smZlVBoSz8ujd6WbCscqJz3fLQgpi0f+13qpwnRwsJ6
 uxVoMqdKt5/ZWkM19kn2pdYB16HqSm1VX7aXkvUP3hEgtepxMKyjpE/PUGwcrDcC
 mBg9EvUY0pdJDNt2qn2GCC6PR+4S4FKf+jBoma97mMiRzZanrEMqUGlmM66zmfQK
 nFgbYuY/Cz9FtnVAtiPN
 =8KKS
 -----END PGP SIGNATURE-----

Merge tag 'perf-core-for-mingo-20160718' 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:

 - Properly report when a function wildcard produces no matches in 'perf probe'
   (Masami Hiramatsu)

 - Balance opening and reading events in 'perf stat', which could cause
   it to get stuck trying to close invalid file descriptors (Mark Rutland)

Infrastructure changes:

 - Copy more headers from the kernel, this time for headers that
   were just including the contents of its kernel counterparts, should
   help resolving the problems with linux-next, where some uapi related
   patches seem to be breaking tools/object/ build. (Arnaldo Carvalho de Melo)

   Some more combing will be done, but at least it is possible to build
   perf out of tree, via a detached tarball (make help | grep perf),
   without including kernel files in its MANIFEST (Arnaldo Carvalho de Melo)

 - Fix smatch found errors that were not causing problems, but are
   mistakes nonetheless (Dan Carpenter)

 - Fix string vs. byte array resolving in the python script code (Jiri Olsa)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-07-19 08:44:38 +02:00
Jiri Olsa 988dd774dc perf tests: Add is_printable_array test
Add automated test for is_printable_array function.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1468685480-18951-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 19:50:35 -03:00
Jiri Olsa accaed2659 perf tools: Make is_printable_array global
It's used from 2 objects in perf, so it's better to keep just one copy.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1468685480-18951-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 19:49:47 -03:00
Jiri Olsa 249de6e074 perf script python: Fix string vs byte array resolving
Jirka reported that python code returns all arrays as strings.  This
makes impossible to get all items for byte array tracepoint field
containing 0x00 value item.

Fixing this by scanning full length of the array and returning it as
PyByteArray object in case non printable byte is found.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Reported-and-Tested-by: Jiri Pirko <jiri@mellanox.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1468685480-18951-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 19:48:04 -03:00
Masami Hiramatsu e70493429b perf probe: Warn unmatched function filter correctly
Warn unmatched function filter correctly instead of warning
"symbol-loading error", since that can be a filter issue.

From the technical point of view, this adds a filter chech in map__load
and if there is a filter, it returns -2 (filter-out), instead of -1
(error), and perf-probe checks it and change message.

E.g. without this fix:

  # perf probe -F rt_sp*
  no symbols found in [kernel.kallsyms], maybe install a debug package?
  Failed to load symbols in kernel

With this fix:

  # perf probe -F rt_sp*
  no symbols passed the given filter.
  Failed to find symbols matched to "rt_sp*"
    Error: Failed to show functions.

Reported-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146885835596.16106.2293540792775552481.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 19:46:34 -03:00
Mark Rutland 9a6c582d57 perf cpu_map: Add more helpers
In some cases it's necessry to figure out the map-local index of a given
Linux logical CPU ID. Add a new helper, cpu_map__idx, to acquire this.
As the logic is largely the same as the existing cpu_map__has, this is
rewritten in terms of the new helper.

At the same time, add the inverse operation, cpu_map__cpu, which yields
the logical CPU id for a map-local index. While this can be performed
manually, wrapping this in a helper can make code more legible.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1468577293-19667-3-git-send-email-mark.rutland@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 19:42:47 -03:00
Mark Rutland 00e727bb38 perf stat: Balance opening and reading events
In create_perf_stat_counter, when a target CPU has not been provided, we
call __perf_evsel__open with empty_cpu_map, and open a single FD per
thread. However, in read_counter we assume that we opened events for the
product of threads and CPUs described in the evsel's cpu_map.

Thus, if an evsel has a cpu_map with more than one entry, we will
attempt to access FDs that we didn't open. This could result in a number
of problems (e.g. blocking while reading from STDIN if the fd memory
happened to be initialised to zero).

This is problematic for systems were a logical CPU PMU covers some
arbitrary subset of CPUs. The cpu_map of any evsel for that PMU will be
initialised based on the cpumask exposed through sysfs, even if the user
requests per-thread events.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1468577293-19667-2-git-send-email-mark.rutland@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 19:41:14 -03:00
Arnaldo Carvalho de Melo ae3c14a028 tools: Copy linux/{hash,poison}.h and check for drift
We were also using this directly from the kernel sources, the two last
cases, fix it.

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-7o14xvacqcjc5llc7gvjjyl8@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 18:41:50 -03:00
Arnaldo Carvalho de Melo 3aa0042769 perf tools: Remove include/linux/list.h from perf's MANIFEST
It hasn't been used since we made tools/ self sufficiente wrt list.h.

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>
Fixes: d1b39d41eb ("tools: Make list.h self-sufficient")
Link: http://lkml.kernel.org/n/tip-w20ueqlf22kh7ctjqo0zjpig@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 18:35:11 -03:00
Arnaldo Carvalho de Melo de1e17b1d0 tools: Copy the bitops files accessed from the kernel and check for drift
copy some more kernel files accessed from tools/, check for drift.

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-omz8xdyvvxgjiuqzwj6ecm6j@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 18:33:41 -03:00
Arnaldo Carvalho de Melo ad430729ae Remove: kernel unistd*h files from perf's MANIFEST, not used
No need to copy it to a detached tarball as they aren't used anymore

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-lopmaqi439ke10g1j9cxrxwt@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 18:14:44 -03:00
Arnaldo Carvalho de Melo e0643c4e9f perf tools: Remove tools/perf/util/include/linux/const.h
Not used anymore, remove one more file referencing kernel sources, i.e.
outside of tools/

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-ykfjt3t8l0npxfwmekiwwyu6@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 17:53:22 -03:00
Arnaldo Carvalho de Melo 7e3f364113 perf tools: Remove tools/perf/util/include/asm/byteorder.h
Not used anymore. This also stops include linux/swab.h directly
from the kernel sources, remove that reference from the MANIFEST.

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>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 17:52:42 -03:00
Arnaldo Carvalho de Melo 14f0652b4f perf tools: Add missing linux/compiler.h include to perf-sys.h
It uses the likely/unlikely macros, so need to include
<linux/compiler.h>.

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-p0xrhgbkicsii9ohmhhprqpi@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 17:40:49 -03:00
Dan Carpenter 9fcfcdf3c7 perf jit: Remove some no-op error handling
The 'info.e_machine' struct member is an uint16_t so 'm' is never less
than zero.  It looks like this was maybe left over code from earlier
versions so I've just removed it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: kernel-janitors@vger.kernel.org
Link: http://lkml.kernel.org/r/20160715210836.GB19522@mwanda
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 12:20:00 -03:00
Dan Carpenter e03141db36 perf jit: Add missing curly braces
It doesn't change the runtime behavior, but my static checker complains
that curly braces were intended.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: kernel-janitors@vger.kernel.org
Link: http://lkml.kernel.org/r/20160715210712.GA19522@mwanda
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-18 12:20:00 -03:00
Ingo Molnar 09211e2530 perf/core improvements and fixes:
User visible:
 
 - Allow reading from a backward ring buffer (one setup via sys_perf_event_open
   with perf_event_attr.write_backward = 1) (Wang Nan)
 
 Infrastructure:
 
 - Fix the build on Android NDK r12b (initially just for arm), that is now port
   of my perf-build container collection and will get tested prior to sending
   patches upstream (Arnaldo Carvalho de Melo)
 
 - Add correct header for ipv6 defini
 
 - Fix bitsperlong.h fallout (Arnaldo Carvalho de Melo, Peter Zijlstra)
 
 - Use base 0 (auto) in filename__read_ull, so that we can handle hex values too (Jiri Olsa)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJXiUuRAAoJENZQFvNTUqpAwxQP/AuVqQ3FhKj9uNHL+walbjjA
 cfJcFtcy0RMbQEN1PKPmUDyMAzJdTEChnzip9TWiS5a+33y5uGyegaOX9FsLwhiR
 NOJe7K4+UQdJLWAVWH4YnScy7ElalStl9h7VTO8eculdrrGVbGhIbp8UACazwC6q
 GgF3/GVAucMJxx3QHt5MVboQeyDdj/n9Rs4bBainDkS4RoD7oUOhpMGIM4Bb3q+o
 nW0GM9hmRlT38lBzwgEm1zMwkNIICER/YkTklDBVCFPWW3Q8ncrOl8YvCIqLsWVU
 Dxv3hifK23UoYhVO0+AlbjqSDAvpx8kJWpEM07r4kxc8QDzmvo1BRvd7O5AWyV0o
 XMETTDhUpqA+R1Yl1hVYrmuaiMf0cUu1uFlpGKq9+nQ3h0IIJIjbS4nugzrCSJsT
 CNcZVP1/MXFkT6jXn7Sw3wPb4cflLXch9uwaa3UYl+wOVdUDu7r4zt4avloAVJio
 H3vM9VmlEzdNwiFgVPIMu+9jFkfJjBeAyG3m/xslS8hZcS0ByeTzMZfAVQ9m4Ymg
 45R3vpQOHtCMiQ8oApJgkwXh4inUPs9wBZc4QPMSSz3MPWGecON4V+I3+pmW3vMg
 BDSsu2r/kb5YbCxtv0F6BEKc5NnFc9xI3mfjbS9VTHE2nTf1RhB0o/cWo85sqOKc
 a9PeBOmUO+Jiv6MkS0Y7
 =QHDr
 -----END PGP SIGNATURE-----

Merge tag 'perf-core-for-mingo-20160715' 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:

 - Allow reading from a backward ring buffer (one setup via sys_perf_event_open()
   with perf_event_attr.write_backward = 1) (Wang Nan)

Infrastructure changes:

 - Fix the build on Android NDK r12b (initially just for ARM), that is now port
   of my perf-build container collection and will get tested prior to sending
   patches upstream (Arnaldo Carvalho de Melo)

 - Add correct header for IPv6 definitions

 - Fix bitsperlong.h fallout (Arnaldo Carvalho de Melo, Peter Zijlstra)

 - Use base 0 (auto) in filename__read_ull(), so that we can handle hex values too (Jiri Olsa)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-07-16 22:36:42 +02:00
Arnaldo Carvalho de Melo b49364f36c objtool: Initialize variable to silence old compiler
gcc version 4.1.2 20080704 (Red Hat 4.1.2-55) barfs with:

    CC       /tmp/build/objtool/builtin-check.o
  cc1: warnings being treated as errors
  builtin-check.c: In function 'cmd_check':
  builtin-check.c:667: warning: 'prev_rela' may be used uninitialized in this function
  mv: cannot stat `/tmp/build/objtool/.builtin-check.o.tmp': No such file or directory
  make[1]: *** [/tmp/build/objtool/builtin-check.o] Error 1

Init it to NULL to silence it.

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-qolo31rl2ojlwj1lj9dhemyz@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:32:52 -03:00
Arnaldo Carvalho de Melo 4a0982f941 objtool: Add -I$(srctree)/tools/arch/$(ARCH)/include/uapi
So that it can find asm/bitsperlong.h to get the __BITS_PER_LONG
definition.

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: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-pr3pvskh65pey4po7t122z4j@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:29:20 -03:00
Wang Nan 4ea648aec0 perf record: Add --tail-synthesize option
When working with overwritable ring buffer there's a inconvenience
problem: if perf dumps data after a long period after it starts,
non-sample events may lost, which makes following 'perf report' unable
to identify proc name and mmap layout. For example:

 # perf record -m 4 -e raw_syscalls:* -g --overwrite --switch-output \
        dd if=/dev/zero of=/dev/null

send SIGUSR2 after dd runs long enough. The resuling perf.data lost
correct comm and mmap events:

 # perf script -i perf.data.2016061522374354
 perf 24478 [004] 2581325.601789:  raw_syscalls:sys_exit: NR 0 = 512
 ^^^^
 Should be 'dd'
                   27b2e8 syscall_slow_exit_work+0xfe2000e3 (/lib/modules/4.6.0-rc3+/build/vmlinux)
                   203cc7 do_syscall_64+0xfe200117 (/lib/modules/4.6.0-rc3+/build/vmlinux)
                   b18d83 return_from_SYSCALL_64+0xfe200000 (/lib/modules/4.6.0-rc3+/build/vmlinux)
             7f47c417edf0 [unknown] ([unknown])
             ^^^^^^^^^^^^
             Fail to unwind

This patch provides a '--tail-synthesize' option, allows perf to collect
system status when finalizing output file. In resuling output file, the
non-sample events reflect system status when dumping data.

After this patch:
 # perf record -m 4 -e raw_syscalls:* -g --overwrite --switch-output --tail-synthesize \
        dd if=/dev/zero of=/dev/null

 # perf script -i perf.data.2016061600544998
 dd 27364 [004] 2583244.994464: raw_syscalls:sys_enter: NR 1 (1, ...
 ^^
 Correct comm
                   203a18 syscall_trace_enter_phase2+0xfe2001a8 ([kernel.kallsyms])
                   203aa5 syscall_trace_enter+0xfe200055 ([kernel.kallsyms])
                   203caa do_syscall_64+0xfe2000fa ([kernel.kallsyms])
                   b18d83 return_from_SYSCALL_64+0xfe200000 ([kernel.kallsyms])
                    d8e50 __GI___libc_write+0xffff01d9639f4010 (/tmp/oxygen_root-w00229757/lib64/libc-2.18.so)
                    ^^^^^
                    Correct unwind

This option doesn't aim to solve this problem completely. If a process
terminates before SIGUSR2, we still lost its COMM and MMAP events. For
example, we can't unwind correctly from the final perf.data we get from
the previous example, because when perf collects the final output file
(when we press C-c), 'dd' has been terminated so its '/proc/<pid>/mmap'
becomes empty.

However, this is a cheaper choice. To completely solve this problem we
need to continously output non-sample events. To satisify the
requirement of daemonization, we need to merge them periodically. It is
possible but requires much more code and cycles.

Automatically select --tail-synthesize when --overwrite is provided.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-16-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:52 -03:00
Wang Nan f06149c0db perf session: Don't warn about out of order event if write_backward is used
If write_backward attribute is set, records are written into kernel
ring buffer from end to beginning, but read from beginning to end.
To avoid 'XX out of order events recorded' warning message (timestamps
of records is in reverse order when using write_backward), suppress the
warning message if write_backward is selected by at lease one event.

Result:

Before this patch:
  # perf record -m 1 -e raw_syscalls:sys_exit/overwrite/ \
                     -e raw_syscalls:sys_enter \
                     dd if=/dev/zero of=/dev/null count=300
  300+0 records in
  300+0 records out
  153600 bytes (154 kB) copied, 0.000601617 s, 255 MB/s
  [ perf record: Woken up 5 times to write data ]
  Warning:
  40 out of order events recorded.
  [ perf record: Captured and wrote 0.096 MB perf.data (696 samples) ]

After this patch:
  # perf record -m 1 -e raw_syscalls:sys_exit/overwrite/ \
                     -e raw_syscalls:sys_enter \
                     dd if=/dev/zero of=/dev/null count=300
  300+0 records in
  300+0 records out
  153600 bytes (154 kB) copied, 0.000644873 s, 238 MB/s
  [ perf record: Woken up 5 times to write data ]
  [ perf record: Captured and wrote 0.096 MB perf.data (696 samples) ]

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-15-git-send-email-wangnan0@huawei.com
Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:51 -03:00
Wang Nan 626a6b784e perf tools: Enable overwrite settings
This patch allows following config terms and option:

Globally setting events to overwrite;

  # perf record --overwrite ...

Set specific events to be overwrite or no-overwrite.

  # perf record --event cycles/overwrite/ ...
  # perf record --event cycles/no-overwrite/ ...

Add missing config terms and update the config term array size because
the longest string length has changed.

For overwritable events, it automatically selects attr.write_backward
since perf requires it to be backward for reading.

Test result:

  # perf record --overwrite -e syscalls:*enter_nanosleep* usleep 1
  [ perf record: Woken up 2 times to write data ]
  [ perf record: Captured and wrote 0.011 MB perf.data (1 samples) ]
  # perf evlist -v
  syscalls:sys_enter_nanosleep: type: 2, size: 112, config: 0x134, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1, inherit: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, write_backward: 1
  # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-14-git-send-email-wangnan0@huawei.com
Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:51 -03:00
Wang Nan f6cdff8329 perf evlist: Make {pause,resume} internal helpers
There's no user of these two function outside evlist.c. Remove them from
public namespace.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:50 -03:00
Wang Nan 057374645b perf record: Read from overwritable ring buffer
Drive the evlist->bkw_mmap_state state machine during draining and when
SIGUSR2 is received. Read the backward ring buffer in record__mmap_read_all.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-12-git-send-email-wangnan0@huawei.com
Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:50 -03:00
Wang Nan 54cc54decd perf evlist: Setup backward mmap state machine
Introduce a bkw_mmap_state state machine to evlist:

                     .________________(forbid)_____________.
                     |                                     V
 NOTREADY --(0)--> RUNNING --(1)--> DATA_PENDING --(2)--> EMPTY
                     ^  ^              |   ^               |
                     |  |__(forbid)____/   |___(forbid)___/|
                     |                                     |
                      \_________________(3)_______________/

 NOTREADY     : Backward ring buffers are not ready
 RUNNING      : Backward ring buffers are recording
 DATA_PENDING : We are required to collect data from backward ring buffers
 EMPTY        : We have collected data from backward ring buffers.

 (0): Setup backward ring buffer
 (1): Pause ring buffers for reading
 (2): Read from ring buffers
 (3): Resume ring buffers for recording

We can't avoid this complexity. Since we deliberately drop records from
overwritable ring buffer, there's no way for us to check remaining from
ring buffer itself (by checking head and old pointers). Therefore, we
need DATA_PENDING and EMPTY state to help us recording what we have done
to the ring buffer.

In record__mmap_read_evlist(), drive this state machine from DATA_PENDING
to EMPTY.

In perf_evlist__mmap_per_evsel(), drive this state machine from NOTREADY
to RUNNING when creating backward mmap.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-11-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:49 -03:00
Wang Nan a0c6f451f9 perf evlist: Drop evlist->backward
Now there's no real user of evlist->backward. Drop it. We are going to
use evlist->backward_mmap as a container for backward ring buffer.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-10-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:49 -03:00
Wang Nan 078c33862e perf evlist: Map backward events to backward_mmap
In perf_evlist__mmap_per_evsel(), select backward_mmap for backward
events.  Utilize new perf_mmap APIs. Dynamically alloc backward_mmap.

Remove useless functions.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-9-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:48 -03:00
Wang Nan b2cb615d8a perf evlist: Introduce backward_mmap array for evlist
Add backward_mmap to evlist, free it together with normal mmap.

Improve perf_evlist__pick_pc(), search backward_mmap if evlist->mmap is
not available.

This patch doesn't alloc this array. It will be allocated conditionally
in the following commits.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-8-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:48 -03:00
Wang Nan a1f7261834 perf evlist: Extract common code in mmap failure processing
In perf_evlist__mmap_per_cpu() and perf_evlist__mmap_per_thread(), in
case of mmap failure, successfully created maps should be cleared.

Current code uses two loops calling __perf_evlist__munmap() for each
function.

This patch extracts common code to perf_evlist__munmap_nofree() and use
previous introduced decoupled API perf_mmap__munmap(). Now
__perf_evlist__munmap() can be removed because of no user.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-7-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:47 -03:00
Wang Nan 4876075b32 perf evlist: Record mmap cookie into fdarray private field
Insetad of saving a index into fdarray entries private field, save the
corresponding 'struct perf_mmap' pointer, and release them directly
using perf_mmap__put().

Following commits introduce multiple mmap arrays to evlist. Without this
patch, perf_evlist__munmap_filtered() is unable to retrive correct
'struct perf_mmap' pointer.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-6-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:47 -03:00
Wang Nan a4ea0ec4f2 perf record: Decouple record__mmap_read() and evlist.
Perf evlist will have multiple mmap arrays. Update record__mmap_read():
it should read from 'struct perf_mmap' directly.

Also, make record__mmap_read() ready to read from backward ring buffer.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-5-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:46 -03:00
Wang Nan 8db6d6b19e perf evlist: Update mmap related APIs and helpers
Currently, the evlist mmap related helpers and APIs accept evlist and
idx, and dereference 'struct perf_mmap' by evlist->mmap[idx]. This is
unnecessary, and force each evlist contains only one mmap array.

Following commits are going to introduce multiple mmap arrays to a
evlist.  This patch refators these APIs and helpers, introduces
functions accept perf_mmap pointer directly. New helpers and APIs are
decoupled with perf_evlist, and become perf_mmap functions (so they have
perf_mmap prefix).

Old functions are reimplemented with new functions. Some of them will be
removed in following commits.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-4-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:46 -03:00
Wang Nan 2b43834706 tools lib fd array: Allow associating a pointer cookie with each entry
Add a 'ptr' field to fdarray->priv array.

This feature will be used by following commits, which introduce
muiltiple 'struct perf_mmap' arrays for different types of mapping.

Because of this, during fdarray__filter(), a simple 'idx' is not enough.

Add a pointer cookie that allows to directly associate a 'struct
perf_mmap' pointer to an fdarray entry.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-3-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:27:46 -03:00
Peter Zijlstra e81fcd4372 tools: Simplify BITS_PER_LONG define
Do it using (__CHAR_BIT__ * __SIZEOF_LONG__), simpler, works everywhere,
reduces the complexity by ditching CONFIG_64BIT, that was being
synthesized from yet another set of defines, which proved fragile,
breaking the build on linux-next for no obvious reasons.

Committer Note:

Except on:

gcc version 4.1.2 20080704 (Red Hat 4.1.2-55)

Fallback to __WORDSIZE in that case...

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20160715072243.GP30154@twins.programming.kicks-ass.net
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 17:26:41 -03:00
Arnaldo Carvalho de Melo 32a951b4fd perf evlist: Drop redundant evsel->overwrite indicator
evsel->overwrite indicator means an event should be put into
overwritable ring buffer. In current implementation, it equals to
evsel->attr.write_backward. To reduce compliexity, remove
evsel->overwrite, use evsel->attr.write_backward instead.

In addition, in __perf_evsel__open(), if kernel doesn't support
write_backward and user explicitly set it in evsel, don't fallback
like other missing feature, since it is meaningless to fall back to
a forward ring buffer in this case: we are unable to stably read
from an forward overwritable ring buffer.

Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 13:38:06 -03:00
Jiri Olsa db49120a32 tools lib api fs: Use base 0 in filename__read_ull
By using 0 for base, the strtoull() detects the base automatically (see
'man strtoull').

ATM we have just one user of this function, the cpu__get_max_freq
function reading the "cpuinfo_max_freq" sysfs file. It should not get
affected by this change.

Committer note:

This change seems motivated by this discussion:

"[PATCH] [RFC V1]s390/perf: fix 'start' address of module's map"
http://lkml.kernel.org/r/20160711120155.GA29929@krava

I.e. this patches paves the way for filename__read_ull() to be used in a
S/390 related fix.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Songshan Gong <gongss@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1468567797-27564-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 13:38:05 -03:00
Arnaldo Carvalho de Melo 0d203166de perf tools: Bail out at "--sort dcacheline" and cacheline_size not known
There are cases where further work would be needed to overcome the fact
that neither sysconf(_SC_LEVEL1_DCACHE_LINESIZE) nor
/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size are
available in some systems (Android, for instance), so bail out when such
a situation takes place.

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-ho8d8g8mh0o2dri7ckcccafi@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 10:08:43 -03:00
Arnaldo Carvalho de Melo 8811e8ea14 perf tools: Just pr_debug() about not being able to read cacheline_size
So far the cacheline_size is only useful for the "dcacheline" --sort
order, i.e. if that is not used, which is the norm, then the user
shouldn't care that he is running this, say, on an Android system where
sysconf(_SC_LEVEL1_DCACHE_LINESIZE) and the
/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size sysfs file
isn't available.

An upcoming patch will emit an warning only for "--sort ...,dcacheline,...".

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-580cnkvftunyvt9n7unsholi@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-15 10:08:29 -03:00
Arnaldo Carvalho de Melo 8c98abff43 tools: Make "__always_inline" just "inline" on Android
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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-14 12:03:04 -03:00
Arnaldo Carvalho de Melo 09dd39d2d2 perf tools: Do not provide dup sched_getcpu() prototype on Android
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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-14 12:02:04 -03:00
Arnaldo Carvalho de Melo ca575ad209 tools lib traceevent: Add correct header for ipv6 definitions
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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-14 11:33:32 -03:00
Ingo Molnar b29c657469 perf/core improvements and fixes:
User visible:
 
 - 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:
 
 - 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: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJXhvaLAAoJENZQFvNTUqpAoygP/i4bFNrt9j8Aq3FyUw6i1say
 GzLMVhjw1dQXUJwg9H4UPUEqkUYA6sg7Icn34SmLKWKWYoo/uu8zX4wBCJkgk8eT
 EL8oBSVAGX6cnVn09upZZWBnFerviMrLh0jEakuUt2KdhGRfd/b8rnPdX1/ApcMa
 FCDNC1yRGutD8EY31T5UbDF7UI6SBDrD0fzNysGJakt0NHvbwTftxdYBd2IpmAgK
 6FMSovyeILGpZIOdZZKv0gOUhI3MZUD3NLDJpYK+tlUjGOmwpqTxYZbMpPzh5GdU
 ITRLhHI/SQzd4qtNE201lc7ICkGMgWTrig3bZFT1XO25X25b/yJx9xVbTklccfRi
 qWcQISCyDtHEE3ij7071bb6cIR/RMle70No3qpPvQoYBDe24VpURJ5aRa1YXKQg2
 ig+3UdJVTmaykvc0YUPgz2V2vfq/NYAHemwU+mc5K5bjPgI6CmW+eaeHJElHbRca
 eO+aMNzy+zam6DNjrO/6lljhrLiJpTUXnMTr6WBy0uxxDg737Ga3x2DJIxBJnZdC
 Q/WHXyIdxVbV10zFt1y4n9J6sv0lJAT+w8wYpqxGFBuiuTH3l6zDtKENstyIeFxg
 S5rH14+NNWCaAyLYvFASo+ypmIYEzQkF8LA4fpekdX+AhfGaUHFFty0QnlbHTpn7
 ujPjCHsmdmrZTYZ4tIgC
 =pLbD
 -----END PGP SIGNATURE-----

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: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-07-14 08:54:13 +02:00
Masami Hiramatsu 8e5dc84835 perf test: Add a test case for SDT event
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: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Arnaldo 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@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-13 23:09:10 -03:00
Masami Hiramatsu e26e63be64 perf build: Add sdt feature detection
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: Masami 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@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-13 23:09:09 -03:00
Masami Hiramatsu 7e9fca51fb perf probe: Support a special SDT probe format
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: Brendan Gregg <brendan.d.gregg@gmail.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Arnaldo 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@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-13 23:09:09 -03:00
Masami Hiramatsu a598180aa1 perf probe: Support @BUILDID or @FILE suffix for SDT events
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: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Arnaldo 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@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-13 23:09:08 -03:00
Masami Hiramatsu 40218daea1 perf list: Show SDT and pre-cached events
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: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo 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@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-13 23:09:07 -03:00
Masami Hiramatsu 1de7b8bf72 perf probe: Search SDT/cached event from all probe caches
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: Masami 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@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-13 23:09:07 -03:00