Commit graph

602998 commits

Author SHA1 Message Date
Jiri Olsa
6c50258443 perf unwind: Call unwind__prepare_access for forked thread
Currently we call unwind__prepare_access for map event.  In case we
report fork event the thread inherits its parent's maps and
unwind__prepare_access is never called for the thread.

This causes unwind__get_entries seeing uninitialized
unwind_libunwind_ops and thus returning no callchain.

Adding unwind__prepare_access calls for fork even processing.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1467634583-29147-5-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-04 20:27:25 -03:00
Jiri Olsa
a2873325ff perf unwind: Add initialized arg into unwind__prepare_access
Adding initialized arg into unwind__prepare_access to get feedback about
the initialization state.

It's not possible to get it from error code, because we return 0 even in
case we don't recognize dso, which is valid.

The 'initialized' value is used in following patch to speedup
unwind__prepare_access calls logic in fork path.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1467634583-29147-4-git-send-email-jolsa@kernel.org
[ Remove ; after static inline function signatures, fixes build break ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-04 20:27:12 -03:00
Jiri Olsa
347ca87806 perf tests: Fix hist accumulation test
User's values from .perfconfig could overload the default callchain
setup and cause this test to fail.  Making sure the test is using
default callchain_param values.

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>
Link: http://lkml.kernel.org/r/1467634583-29147-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-04 19:39:01 -03:00
Jiri Olsa
c60da22aca perf header: Transform nodes string info to struct
Storing NUMA info within struct numa_node instead of strings. This way
it's usable in future patches.

Also it turned out it's slightly less code involved than using strings.

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>
Link: http://lkml.kernel.org/r/1467634583-29147-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-04 19:39:01 -03:00
Masami Hiramatsu
6430a94ead perf buildid-cache: Scan and import user SDT events to probe cache
perf buildid-cache --add <binary> scans given binary and add
the SDT events to probe cache. "sdt_" prefix is appended for
all SDT providers to avoid event-name clash with other pre-defined
events. It is possible to use the cached SDT events as other cached
events, via perf probe --add "sdt_<provider>:<event>=<event>".

e.g.
  ----
  # perf buildid-cache --add /lib/libc-2.17.so
  # perf probe --cache --list | head -n 5
  /usr/lib/libc-2.17.so (a6fb821bdf53660eb2c29f778757aef294d3d392):
  sdt_libc:setjmp=setjmp
  sdt_libc:longjmp=longjmp
  sdt_libc:longjmp_target=longjmp_target
  sdt_libc:memory_heap_new=memory_heap_new
  # perf probe -x /usr/lib/libc-2.17.so \
    -a sdt_libc:memory_heap_new=memory_heap_new
  Added new event:
    sdt_libc:memory_heap_new (on memory_heap_new
   in /usr/lib/libc-2.17.so)

  You can now use it in all perf tools, such as:

          perf record -e sdt_libc:memory_heap_new -aR sleep 1

  # perf probe -l
    sdt_libc:memory_heap_new (on new_heap+183 in /usr/lib/libc-2.17.so)
  ----

Note that SDT event entries in probe-cache file is somewhat different
from normal cached events. Normal one starts with "#", but SDTs are
starting with "%".

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Masami 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/146736025058.27797.13043265488541434502.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-04 19:39:00 -03:00
Masami Hiramatsu
8d993d9690 perf probe: Add group name support
Allow user to set group name for adding new event.  Note that user must
ensure that the group name doesn't conflict with existing group name
carefully.

E.g. Existing group name can conflict with other events.  Especially,
using the group name reserved for kernel modules can hide kernel
embedded events when loading modules.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Masami 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/146736024091.27797.9471545190066268995.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-04 19:39:00 -03:00
Hemant Kumar
060fa0c7a3 perf sdt: ELF support for SDT
This patch serves the initial support to identify and list SDT events in
binaries.  When programs containing SDT markers are compiled, gcc with
the help of assembler directives identifies them and places them in the
section ".note.stapsdt".

To find these markers from the binaries, one needs to traverse through
this section and parse the relevant details like the name, type and
location of the marker. Also, the original location could be skewed due
to the effect of prelinking. If that is the case, the locations need to
be adjusted.

The functions in this patch open a given ELF, find out the SDT section,
parse the relevant details, adjust the location (if necessary) and
populate them in a list.

A typical note entry in ".note.stapsdt" section is as follows :

                                 |--nhdr.n_namesz--|
                ------------------------------------
                |      nhdr      |     "stapsdt"   |
        -----   |----------------------------------|
         |      |  <location>       <base_address> |
         |      |  <semaphore>                     |
nhdr.n_descsize |  "provider_name"   "note_name"   |
         |      |   <args>                         |
        -----   |----------------------------------|
                |      nhdr      |     "stapsdt"   |
                |...

The above shows an excerpt from the section ".note.stapsdt".  'nhdr' is
a structure which has the note name size (n_namesz), note description
size (n_desc_sz) and note type (n_type).

So, in order to parse the note note info, we need nhdr to tell us where
to start from.  As can be seen from <sys/sdt.h>, the name of the SDT
notes given is "stapsdt".  But this is not the identifier of the note.

After that, we go to description of the note to find out its location, the
address of the ".stapsdt.base" section and the semaphore address.
Then, we find the provider name and the SDT marker name and then follow the
arguments.

Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146736022628.27797.1201368329092908163.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-04 19:38:59 -03:00
Arnaldo Carvalho de Melo
2492c465ad perf build: Add feature detection for libelf's elf_getshdrstrndx()
That appeared after 0.140, and will be used in the SDT code, so, to
avoid bisection break on older systems, add a feature detection and
provide a stub with a pr_debug() to keep it building.

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: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-80y0eldgweorqnwha9rvfxjr@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-04 19:38:59 -03:00
Masami Hiramatsu
4a0f65c102 perf probe: Remove caches when --cache is given
'perf probe --del' removes caches when '--cache' is given.  Note that
the delete pattern is not the same as for normal events.

If you cached probes with event name, --del "eventname" works as
expected. However, if you skipped it, the cached probes doesn't have
actual event name. In that case --del "probe-desc" is required (wildcard
is acceptable).  For example a cache entry has the probe-desc "vfs_read
$params", you can remove it with --del 'vfs_read*'.

  -----
  # perf probe --cache --list
  /[kernel.kallsyms] (1466a0a250b5d0070c6d0f03c5fed30b237970a1):
  vfs_read $params
  /usr/lib64/libc-2.17.so (c31ffe7942bfd77b2fca8f9bd5709d387a86d3bc):
  getaddrinfo $params

  # perf probe --cache --del vfs_read\*
  Removed cached event: probe:vfs_read

  # perf probe --cache --list
  /[kernel.kallsyms] (1466a0a250b5d0070c6d0f03c5fed30b237970a1):
  /usr/lib64/libc-2.17.so (c31ffe7942bfd77b2fca8f9bd5709d387a86d3bc):
  getaddrinfo $params
  -----

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/146736021651.27797.10250879847070772920.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-01 11:34:57 -03:00
Masami Hiramatsu
1f3736c9c8 perf probe: Show all cached probes
perf probe --list shows all cached probes when --cache is given. Each
caches are shown with on which binary that probed. E.g.:

  -----
  # perf probe --cache vfs_read \$params
  # perf probe --cache -x /lib64/libc-2.17.so getaddrinfo \$params
  # perf probe --cache --list
  [kernel.kallsyms] (1466a0a250b5d0070c6d0f03c5fed30b237970a1):
  vfs_read $params
  /usr/lib64/libc-2.17.so (c31ffe7942bfd77b2fca8f9bd5709d387a86d3bc):
  getaddrinfo $params
  -----

Note that $params requires debuginfo.

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/146736020674.27797.13488316780383460180.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-01 11:34:57 -03:00
Masami Hiramatsu
bc0622302f perf probe: Use cache entry if possible
Before analyzing debuginfo, try to find a corresponding entry from probe
cache always. This does not depend on --cache, the --cache enables to
store/update cache, but looking up the cache is always enabled.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Masami 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/146736019226.27797.16366402884098398857.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-01 11:34:57 -03:00
Ingo Molnar
dc29bb47a3 perf/core improvements and fixes:
New features:
 
 - Allow running 'perf test' entries in the same process, not forking to
   test each testcase, useful for debugging (Jiri Olsa)
 
 - Show number of samples in the stdio annotate header (Peter Zijlstra)
 
 Documentation:
 
 - Add documentation for perf.data on disk format (Andi Kleen)
 
 Build fixes:
 
 - Fix 'perf trace' build on old systems wrt missing SCHED_RESET_ON_FORK and
   eventfd.h (Arnaldo Carvalho de Melo)
 
 Infrastructure:
 
 - Utility function to fetch arch from evsel/evlist (Ravi Bangoria)
 
 Trivial:
 
 - Fix spelling mistake: "missmatch" -> "mismatch" in libbpf (Colin Ian King)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJXdZFuAAoJENZQFvNTUqpALH8P/jUEFEVEnkUPjITbQgT6mfaH
 3eoF2aM9XzyeJ4RwcSEWqjegF4nkwv10FBVEKjeIvvs8ajEO+SnyChL0/zpGoMHJ
 DWXeicQYFTbQy23d4p2ecU2gOH6QqtlzJ9d/UodwCWjM05FdROUa8Mz0WwyvIOiy
 xTZ81DdV/f0E7axI06Rel0yeQIirc8uUG+Wt4wYZhnrXP3tANLG/1bHjLgeAEYsB
 2KPMz9lt2Wbzc/tng6fExWJzG7gct/yAuWV1kJxs7I1bIZekxAYGG+7ZDP+o5jh9
 2bU021pajJh8KdwcabJJ37t1A3/LZOSjCz4Qc1PPHqBJFZMTOtKMUWdW2Pvzp7XB
 qF+7cvePG1JuapSin4QeqBG38ECQVbcg5dFIHPtLPWmoNmMYdjak2ypaWloeYDOT
 O68bbTaR+MLDdfSRtr5mHplAZL6m3I7nWerwtAWwy/LdFUkQrwfhdO23m2debwPH
 WuFmPz3HZqBAdSaTNl1F1Rqe/IL7MsPCgSZy/o3piC59sNhXyc55GaxMfF83yu95
 PBz0ngZmW3/otYZW2EQC0BwkT1ef5ewqtmn3HAEBNnzqMHKTHkg+n3Ode0H0t2q4
 rCXYIM0PAvQw8YSICt4HeapmW7unu2DcsFecApafpdjZhRmgIu40bwZ0eHBPK3bu
 HhK58+DFEuYmMOzsRoIQ
 =MDzG
 -----END PGP SIGNATURE-----

Merge tag 'perf-core-for-mingo-20160630' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

New features:

 - Allow running 'perf test' entries in the same process, not forking to
   test each testcase, useful for debugging (Jiri Olsa)

 - Show number of samples in the stdio annotate header (Peter Zijlstra)

Documentation changes:

 - Add documentation for perf.data on disk format (Andi Kleen)

Build fixes:

 - Fix 'perf trace' build on old systems wrt missing SCHED_RESET_ON_FORK and
   eventfd.h (Arnaldo Carvalho de Melo)

Infrastructure changes:

 - Utility function to fetch arch from evsel/evlist (Ravi Bangoria)

Trivial changes:

 - Fix spelling mistake: "missmatch" -> "mismatch" in libbpf (Colin Ian King)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-07-01 08:40:39 +02:00
Jiri Olsa
a24020e6b7 perf tools: Change cpu_map__fprintf output
Display cpu map in standard list form.  (perf report -D output on perf stat data).

before:
  0x590 [0x18]: PERF_RECORD_CPU_MAP nr: 4 cpus: 0, 1, 2, 3

after:
  0x590 [0x18]: PERF_RECORD_CPU_MAP: 0-3

Adding automated testcase.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo 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/1467113345-12669-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-30 18:27:45 -03:00
Jiri Olsa
7fa9b8fba0 perf test: Add -F/--dont-fork option
Adding -F/--dont-fork option to bypass forking for each test. It's
useful for debugging test.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Nilay Vaish <nilayvaish@gmail.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/1467113345-12669-1-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-30 18:27:45 -03:00
Jiri Olsa
8fbc38aaaf perf tests: Fix thread map test for -F option
I hit a bug when running test suite without forking each test (-F
option):

  $ perf test -Fv
  ...
  34: Test thread map                                          :
  --- start ---
  FAILED tests/thread-map.c:24 wrong comm
  ---- end ----
  Test thread map: FAILED!

The reason was the process name wasn't 'perf' as expected by the test,
because other tests set the name as well.

Setting it explicitly now.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Nilay Vaish <nilayvaish@gmail.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/1467113345-12669-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-30 18:27:44 -03:00
Jiri Olsa
f3069249e9 perf tools: Allow to reset open files counter
I hit a bug when running test suite without forking
each test (-F option):

  $ perf test -F dso
   8: Test dso data read                                       : Ok
   9: Test dso data cache                                      : FAILED!
  10: Test dso data reopen                                     : FAILED!

The reason the session file limit is set just once for
perf process so we need to reset it for each test,
otherwise wrong limit is taken into account.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Nilay Vaish <nilayvaish@gmail.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/1467113345-12669-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-30 18:27:44 -03:00
Arnaldo Carvalho de Melo
3be28870c0 perf trace beauty eventfd: No need to include eventfd.h
Old systems such as RHEL5 lack this file, and what we need is
already under ifdefs, so just ditch this #include.

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-dzbjfllw6znuoy37skwnwa4r@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-30 18:27:43 -03:00
Arnaldo Carvalho de Melo
a41af25b3c perf trace beauty sched_policy: Define SCHED_RESET_ON_FORK for older systems
RHEL5 for instance doesn't have this one, help 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-3adewnii78zi110eovfciopy@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-30 18:27:43 -03:00
Peter Zijlstra (Intel)
135cce1bf1 perf annotate: Add number of samples to the header
Staring at annotations of large functions is useless if there's only a
few samples in them. Report the number of samples in the header to make
this easier to determine.

Committer note:

The change amounts to:

  - Percent | Source code & Disassembly of perf-vdso.so for cycles:u
  ------------------------------------------------------------------
  + Percent | Source code & Disassembly of perf-vdso.so for cycles:u (3278 samples)
  +--------------------------------------------------------------------------------

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20160630082955.GA30921@twins.programming.kicks-ass.net
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-30 18:27:42 -03:00
Peter Zijlstra (Intel)
53dd9b5f95 perf annotate: Simplify header dotted line sizing
No need to use strlen, etc to figure that out, just use the return from
printf(), it will tell how wide the following line needs to be.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20160630082955.GA30921@twins.programming.kicks-ass.net
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-30 09:21:03 -03:00
Ravi Bangoria
f4e47f9f7b perf evsel: Utility function to fetch arch
Add Utility function to fetch arch using evsel. (evsel->env->arch)

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Daniel Axtens <dja@axtens.net>
Cc: David Laight <David.Laight@ACULAB.COM>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1467267262-4589-2-git-send-email-ravi.bangoria@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-30 08:37:32 -03:00
Colin Ian King
de8a63bd50 tools lib bpf: Fix spelling mistake: "missmatch" -> "mismatch"
Trivial fix to spelling mistake

Signed-off-by: Colin King <colin.king@canonical.com>
Acked-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1467116617-8318-1-git-send-email-colin.king@canonical.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-29 10:07:34 -03:00
Andi Kleen
d4897e1935 perf tools: Add documentation for perf.data on disk format
Add some documentation for the on disk format of perf.data. This is not
documenting the actual perf events -- which are documented in
perf_event.h -- but just the additional headers that perf record adds
around them when writing the data to disk.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1466800885-12974-1-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-29 10:07:23 -03:00
Ingo Molnar
d905768c9e perf/core improvements and fixes:
New features:
 
 - Generate comm, fork and exit events when converting perf.data files to CTF (Wang Nan)
 
 Infrastructure:
 
 - Add libbabeltrace to build-test (Wang Nan)
 
 - 'perf record' prep work to support multiple evlists (Wang Nan)
 
 - Remove unused hist_entry__annotate function (Ravi Bangoria)
 
 - Add more toolchain triplets (Ravi Bangoria)
 
 - Update message for slang devel packages on Ubuntu (Neeraj Badlani)
 
 - Generalize handling of 'ret' instructions in the annotate TUI (Naveen N. Rao)
 
 - Use proper dso name for is_regular_file, fixing device file handling (Jiri Olsa)
 
 Build Fixes:
 
 - Add missing config.h include, fixing the build with libbabeltrace (Jiri Olsa)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJXcoITAAoJENZQFvNTUqpAWxwP/j/h0hGej0/OtzmYIvkeMNXL
 Ei/G1SPjaVS1HxE2UeqcSVFN9dYXHXNwC/9D9Zhg3nTVeVqdTTtk4l2AQcBt7/0b
 5dHFD3mue5iSPFR2nh6nkidb2AyplrCd192Ovww0S/hy26HkNF/8X02aknpOm4SL
 u+S6oYo1gaKCMh7FXYqxFa4uMfzrnCQH5YmEUyuuj3S7fDyidVYVsHfa7DAvzZF9
 gyFnqHRX9H+FpWXkJtaTAaDEQtMvKqvvjLglWDm4W5z0dvyIvVpTiJwm3AtPJ17a
 7rfg+D8V/pA5rcC5HsUwzTrrwzNH0/fDwZgrn50/FImaVyR8MbowgUG+xRGctqsk
 ITmW0FQisJngBekZ7aMl8/WgZ5XfvfwtPo9sfvyTnryqbG1ZizWmnOCFg9PpfSWK
 08kNQac/t4Uo6qZmL1x3lw8T60EGsOJaVwllNKPcF5CO0ff5cXKnXTkEyCoCcS20
 RJ8mFJeqol76gmjAy5rYdK9hLMDTUlrHIB2gTE9s1woaiuAvhpnXl0QVx6q38e3L
 H0f1JFF0Ny5Nb5W+xOUFXiNmVAOKoFL9hS4GOpzDyTozVBTRazjMQf5srfskrhlb
 4dpvwJqIFHo/NaKXZcHYcT7wYFaE6gbApjw5bUaFPMvhYOJ/DefW8FSk8btcma1N
 LZ65UEGakqS5gbFX9NdU
 =rSZA
 -----END PGP SIGNATURE-----

Merge tag 'perf-core-for-mingo-20160628' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

New features:

 - Generate comm, fork and exit events when converting perf.data files to CTF (Wang Nan)

Infrastructure changes:

 - Add libbabeltrace to build-test (Wang Nan)

 - 'perf record' prep work to support multiple evlists (Wang Nan)

 - Remove unused hist_entry__annotate function (Ravi Bangoria)

 - Add more toolchain triplets (Ravi Bangoria)

 - Update message for slang devel packages on Ubuntu (Neeraj Badlani)

 - Generalize handling of 'ret' instructions in the annotate TUI (Naveen N. Rao)

 - Use proper dso name for is_regular_file, fixing device file handling (Jiri Olsa)

Build Fixes:

 - Add missing config.h include, fixing the build with libbabeltrace (Jiri Olsa)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-06-29 11:34:41 +02:00
Wang Nan
ebccba3fe0 perf data ctf: Generate fork and exit events to CTF output
If 'all' is selected, convert fork and exit events to output CTF stream.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-8-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:58 -03:00
Wang Nan
9e1a7ea19f perf data ctf: Add '--all' option for 'perf data convert'
After this patch, 'perf data convert' convert comm events to output CTF
stream.

Result:

  # perf record -a sleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.378 MB perf.data (73 samples)  ]

  # perf data convert --to-ctf ./out.ctf
  [ perf data convert: Converted 'perf.data' into CTF data './out.ctf' ]
  [ perf data convert: Converted and wrote 0.003 MB (73 samples) ]

  # babeltrace --clock-seconds ./out.ctf/
  [10627.402515791] (+?.?????????) cycles:ppp: { cpu_id = 0 }, { perf_ip = 0xFFFFFFFF81065AF4, perf_tid = 0, perf_pid = 0, perf_period = 1 }
  [10627.402518972] (+0.000003181) cycles:ppp: { cpu_id = 0 }, { perf_ip = 0xFFFFFFFF81065AF4, perf_tid = 0, perf_pid = 0, perf_period = 1 }
  ...    // only sample event is converted

  # perf data convert --all --to-ctf ./out.ctf
  [ perf data convert: Converted 'perf.data' into CTF data './out.ctf' ]
  [ perf data convert: Converted and wrote 0.023 MB (73 samples, 384 non-samples) ]

  # babeltrace --clock-seconds ./out.ctf/
  [  0.000000000] (+?.?????????) perf_comm: { cpu_id = 0 }, { pid = 1, tid = 1, comm = "init" }
  [  0.000000000] (+0.000000000) perf_comm: { cpu_id = 0 }, { pid = 2, tid = 2, comm = "kthreadd" }
  [  0.000000000] (+0.000000000) perf_comm: { cpu_id = 0 }, { pid = 3, tid = 3, comm = "ksoftirqd/0" }
  ...    // comm events are converted
  [10627.402515791] (+10627.402515791) cycles:ppp: { cpu_id = 0 }, { perf_ip = 0xFFFFFFFF81065AF4, perf_tid = 0, perf_pid = 0, perf_period = 1 }
  [10627.402518972] (+0.000003181) cycles:ppp: { cpu_id = 0 }, { perf_ip = 0xFFFFFFFF81065AF4, perf_tid = 0, perf_pid = 0, perf_period = 1 }
  ...    // samples are also converted

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-7-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:57 -03:00
Wang Nan
f5a08ceda5 perf data ctf: Generate comm event to CTF output
If 'all' is selected, convert comm event to output CTF stream.

setup_non_sample_events() is called if non_sample is selected. It
creates a comm_class for comm event.

Use macros to generate and process_comm_event and add_comm_event. These
macros can be reused for other non-sample events.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-6-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:57 -03:00
Wang Nan
8ee4c46c5e perf data ctf: Prepare collect non-sample events
Following commits are going to allow 'perf data convert' to collect not
only samples, but also non-sample events like comm and fork. In this
patch we count non-sample events using c.non_sample_count, and prepare
to print number of both type of events like:

  # ~/perf data convert --all --to-ctf ./out.ctf
  [ perf data convert: Converted 'perf.data' into CTF data './out.ctf' ]
  [ perf data convert: Converted and wrote 0.846 MB (6508 samples, 686 non-samples) ]

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-5-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:56 -03:00
Wang Nan
f02a6489d1 perf data ctf: Add 'all' option
If 'all' option is selected, 'perf data convert' should convert not only
samples, but non-sample events such as comm and fork. Add this option in
perf_data_convert_opts. Following commits will add cmdline option to
select it.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-4-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:56 -03:00
Wang Nan
3275f68e50 perf data ctf: Pass convert options through opts structure
Following commits will add new option to 'perf data convert'. All options
should be grouped into a structure and passed to low level converter
(currently there's only one converter).

Introduce data-convert.h and define 'struct perf_data_convert_opts' in
it. Pass 'force' through opts.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-3-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:55 -03:00
Wang Nan
069ee5c488 perf data ctf: Add value_set_string() helper
There are many value_set_##x helper for integer, but only for integer.
This patch adds value_set_string() helper to help following commits
create string fields.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:55 -03:00
Jiri Olsa
ed7b630b31 perf symbols: Use proper dso name for is_regular_file
Marc reported use of uninitialized memory:

> In commit "403567217d3f perf symbols: Do not read symbols/data from
> device files" a check to uninitialzied memory was added. This leads to
> the following valgrind output:
>
>  ==24515== Syscall param stat(file_name) points to uninitialised byte(s)
>  ==24515==    at 0x75B26D5: _xstat (in /lib/x86_64-linux-gnu/libc-2.22.so)
>  ==24515==    by 0x4E548D: stat (stat.h:454)
>  ==24515==    by 0x4E548D: is_regular_file (util.c:687)
>  ==24515==    by 0x4A5BEE: dso__load (symbol.c:1435)
>  ==24515==    by 0x4BB1AE: map__load (map.c:289)
>  ==24515==    by 0x4BB1AE: map__find_symbol (map.c:333)
>  ==24515==    by 0x4835B3: thread__find_addr_location (event.c:1300)
>  ==24515==    by 0x4B5342: add_callchain_ip (machine.c:1652)
>  ==24515==    by 0x4B5342: thread__resolve_callchain_sample (machine.c:1906)
>  ==24515==    by 0x4B9E7D: thread__resolve_callchain (machine.c:1958)
>  ==24515==    by 0x441B3E: process_event (builtin-script.c:795)
>  ==24515==    by 0x441B3E: process_sample_event (builtin-script.c:920)
>  ==24515==    by 0x4BEE29: perf_evlist__deliver_sample (session.c:1192)
>  ==24515==    by 0x4BEE29: machines__deliver_event (session.c:1229)
>  ==24515==    by 0x4BF770: perf_session__deliver_event (session.c:1286)
>  ==24515==    by 0x4BF770: ordered_events__deliver_event (session.c:114)
>  ==24515==    by 0x4C1D17: __ordered_events__flush (ordered-events.c:207)
>  ==24515==    by 0x4C1D17: ordered_events__flush.part.3 (ordered-events.c:274)
>  ==24515==    by 0x4BF44C: perf_session__process_user_event (session.c:1325)
>  ==24515==    by 0x4BF44C: perf_session__process_event (session.c:1451)
>  ==24515==  Address 0x807c6a0 is 0 bytes inside a block of size 4,096 alloc'd
>  ==24515==    at 0x4C29C0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>  ==24515==    by 0x4A5BCB: dso__load (symbol.c:1421)
>  ==24515==    by 0x4BB1AE: map__load (map.c:289)
>  ==24515==    by 0x4BB1AE: map__find_symbol (map.c:333)
>  ==24515==    by 0x4835B3: thread__find_addr_location (event.c:1300)
>  ==24515==    by 0x4B5342: add_callchain_ip (machine.c:1652)
>  ==24515==    by 0x4B5342: thread__resolve_callchain_sample (machine.c:1906)
>  ==24515==    by 0x4B9E7D: thread__resolve_callchain (machine.c:1958)
>  ==24515==    by 0x441B3E: process_event (builtin-script.c:795)
>  ==24515==    by 0x441B3E: process_sample_event (builtin-script.c:920)
>  ==24515==    by 0x4BEE29: perf_evlist__deliver_sample (session.c:1192)
>  ==24515==    by 0x4BEE29: machines__deliver_event (session.c:1229)
>  ==24515==    by 0x4BF770: perf_session__deliver_event (session.c:1286)
>  ==24515==    by 0x4BF770: ordered_events__deliver_event (session.c:114)
>  ==24515==    by 0x4C1D17: __ordered_events__flush (ordered-events.c:207)
>  ==24515==    by 0x4C1D17: ordered_events__flush.part.3 (ordered-events.c:274)
>  ==24515==    by 0x4BF44C: perf_session__process_user_event (session.c:1325)
>  ==24515==    by 0x4BF44C: perf_session__process_event (session.c:1451)
>  ==24515==    by 0x4C0EAC: __perf_session__process_events (session.c:1804)
>  ==24515==    by 0x4C0EAC: perf_session__process_events (session.c:1858)

The reason was a typo that passed global 'name' variable as the
is_regular_file argument instead dso->long_name.

Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: 403567217d ("perf symbols: Do not read symbols/data from device files")
Link: http://lkml.kernel.org/r/1466772025-17471-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:54 -03:00
Wang Nan
ee667f947c perf record: Prepare picking perf_event_mmap_page from multiple evlists
Following commits introduce new evlists to record. This patch adjusts
record__pick_pc() and introduces perf_evlist__pick_pc() to read control
page from one specific evlist. record__pick_pc() will be improved to
search control page from multiple evlists.

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/1467023052-146749-4-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:54 -03:00
Wang Nan
cb21686b7d perf record: Prepare reading from multiple evlists in record__mmap_read_all()
Following commits introduce new evlists to record. This patch adjusts
record__mmap_read_all() and record__mmap_read(): converting original
record__mmap_read_all() to record__mmap_read_evlist(), read from one
evlist; makes record__mmap_read() reading from specific evlist.
record__mmap_read_all() will be improved to read from multiple evlists.

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/1467023052-146749-3-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:53 -03:00
Wang Nan
cda57a8c74 perf record: Move mmap setup block to separate function
Following commits introduce multiple evlists to record. This patch
extracts perf_evlist__mmap_ex() processing to a new function, creates
record__mmap() and record__mmap_evlist() to wrap perf_evlist__mmap_ex()
and its error processing. They will be improvemented to create mmap for
all evlists.

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/1467023052-146749-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:53 -03:00
Jiri Olsa
f6c12a004c perf data convert: Include config.h header
Otherwise some compiler might scream:

  $ make LIBBABELTRACE_DIR=/opt/libbabeltrace/ LIBBABELTRACE=1
    BUILD:   Doing 'make -j4' parallel build
    CC       util/data-convert-bt.o
  util/data-convert-bt.c: In function ‘convert__config’:
  util/data-convert-bt.c:1299:19: error: implicit declaration of function ‘perf_config_u64’ [-Werror=implicit-function-declaration]
     c->queue_size = perf_config_u64(var, value);
  ...

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Taeung Song <treeze.taeung@gmail.com>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: 41840d211c ("perf config: Move config declarations from util/cache.h to util/config.h")
Link: http://lkml.kernel.org/r/1466772025-17471-1-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:52 -03:00
Wang Nan
f5ce45736b perf build: Add libbabeltrace to build-test
'make build-test' doesn't test LIBBABELTRACE=1. It misses a building
failure caused by commit 41840d211c ("perf config: Move config
declarations from util/cache.h to util/config.h"), breaks bisect.

Add LIBBABELTRACE=1 to build-test.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466818918-131281-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 10:54:52 -03:00
Ravi Bangoria
78f69b5865 perf tools: Add more toolchain triplets
Add few more triplets based on Fedora and Ubuntu binutils (cross tools).

Before applying patch on x86:

  ( Install binutils-powerpc64-linux-gnu.x86_64 )
  $ perf report -i perf.data.powerpc --vmlinux vmlinux.powerpc \
      --objdump powerpc64-linux-gnu-objdump

After applying patch on x86:

  $ perf report -i perf.data.powerpc --vmlinux vmlinux.powerpc

I.e. it will find the right objdump from the environment data recorded
in the perf.data file + these triplets.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Daniel Axtens <dja@axtens.net>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Link: http://lkml.kernel.org/r/1466769240-12376-7-git-send-email-ravi.bangoria@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-27 14:31:41 -03:00
Naveen N. Rao
6ef9492915 perf annotate: Generalize handling of 'ret' instructions
Introduce helper to detect 'ret' instructions and use the same in the TUI.
A helper is needed since some architectures such as powerpc have more
than one return instruction.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Daniel Axtens <dja@axtens.net>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Link: http://lkml.kernel.org/r/1466769240-12376-5-git-send-email-ravi.bangoria@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-27 14:25:05 -03:00
Neeraj Badlani
9f776ba11c perf tools: Update makefile message for installing slang devel package
In case of missing library (libslang), give hint to install library
(libslang2-dev), since libslang-dev is not provided by Ubuntu.

Signed-off-by: Neeraj Badlani <neerajbadlani@gmail.com>
Link: http://lkml.kernel.org/r/1467035997-9100-1-git-send-email-neerajbadlani@gmail.com
[ removed excessive 'or' usage ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-27 12:44:22 -03:00
Ravi Bangoria
f2f4fe4410 perf annotate: Remove unused hist_entry__annotate function
hist_entry__annotate looks part of API but I don't find any caller
of this function. Removing it.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Daniel Axtens <dja@axtens.net>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Link: http://lkml.kernel.org/r/1466769240-12376-2-git-send-email-ravi.bangoria@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-27 10:58:50 -03:00
Peter Zijlstra
d4cf1949f9 perf/x86/intel: Add {rd,wr}lbr_{to,from} wrappers
The whole rdmsr()/wrmsr() for lbr_from got a little unweildy with the
sign extension quirk, provide a few simple wrappers to clean things up.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Carrillo-Cisneros <davidcc@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-06-27 11:34:21 +02:00
David Carrillo-Cisneros
71adae99ed perf/x86/intel: Add MSR_LAST_BRANCH_FROM_x quirk for ctx switch
Add quirk for context switch to save/restore the value of
MSR_LAST_BRANCH_FROM_x when LBR is enabled and there is potential for
kernel addresses to be in the lbr_from register.

To test this patch, use a perf tool and kernel with the patch
next in this series. That patch removes the work around that masked
the hw bug:

  $ ./lbr_perf record --call-graph lbr -e cycles:k sleep 1

where lbr_perf is the patched perf tool, that allows to specify :k
on lbr mode. The above command will trigger a #GPF :

 WARNING: CPU: 28 PID: 14096 at arch/x86/mm/extable.c:65 ex_handler_wrmsr_unsafe+0x70/0x80
 unchecked MSR access error: WRMSR to 0x681 (tried to write 0x1fffffff81010794)
 ...
 Call Trace:
  [<ffffffff8167af49>] dump_stack+0x4d/0x63
  [<ffffffff810b9b15>] __warn+0xe5/0x100
  [<ffffffff810b9be9>] warn_slowpath_fmt+0x49/0x50
  [<ffffffff810abb40>] ex_handler_wrmsr_unsafe+0x70/0x80
  [<ffffffff810abc42>] fixup_exception+0x42/0x50
  [<ffffffff81079d1a>] do_general_protection+0x8a/0x160
  [<ffffffff81684ec2>] general_protection+0x22/0x30
  [<ffffffff810101b9>] ? intel_pmu_lbr_sched_task+0xc9/0x380
  [<ffffffff81009d7c>] intel_pmu_sched_task+0x3c/0x60
  [<ffffffff81003a2b>] x86_pmu_sched_task+0x1b/0x20
  [<ffffffff81192a5b>] perf_pmu_sched_task+0x6b/0xb0
  [<ffffffff8119746d>] __perf_event_task_sched_in+0x7d/0x150
  [<ffffffff810dd9dc>] finish_task_switch+0x15c/0x200
  [<ffffffff8167f894>] __schedule+0x274/0x6cc
  [<ffffffff8167fdd9>] schedule+0x39/0x90
  [<ffffffff81675398>] exit_to_usermode_loop+0x39/0x89
  [<ffffffff810028ce>] prepare_exit_to_usermode+0x2e/0x30
  [<ffffffff81683c1b>] retint_user+0x8/0x10

Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Stephane Eranian <eranian@google.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: http://lkml.kernel.org/r/1466533874-52003-5-git-send-email-davidcc@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-06-27 11:34:20 +02:00
David Carrillo-Cisneros
3812bba84f perf/x86/intel: Fix trivial formatting and style bug
Replace spaces by tabs in LBR_FROM_* constants to align with newly
defined constant. Use BIT_ULL.

Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Stephane Eranian <eranian@google.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: http://lkml.kernel.org/r/1466533874-52003-4-git-send-email-davidcc@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-06-27 11:34:19 +02:00
David Carrillo-Cisneros
19fc9ddd61 perf/x86/intel: Fix MSR_LAST_BRANCH_FROM_x bug when no TSX
Intel's SDM states that bits 61:62 in MSR_LAST_BRANCH_FROM_x are the
TSX flags for formats with LBR_TSX flags (i.e. LBR_FORMAT_EIP_EFLAGS2).

However, when the CPU has TSX support deactivated, bits 61:62 actually
behave as follows:

  - For wrmsr(), bits 61:62 are considered part of the sign extension.
  - When capturing branches, the LBR hw will always clear bits 61:62.
    regardless of the sign extension.

Therefore, if:

  1) LBR has TSX format.
  2) CPU has no TSX support enabled.

... then any value passed to wrmsr() must be sign extended to 63 bits
and any value from rdmsr() must be converted to have a sign extension
of 61 bits, ignoring the values at TSX flags.

This bug was masked by the work-around to the Intel's CPU bug:
BJ94. "LBR May Contain Incorrect Information When Using FREEZE_LBRS_ON_PMI"
in Document Number: 324643-037US.

The aforementioned work-around uses hw flags to filter out all kernel
branches, limiting LBR callstack to user level execution only.

Since user addresses are not sign extended, they do not trigger the wrmsr()
bug in MSR_LAST_BRANCH_FROM_x when saved/restored at context switch.

To verify the hw bug:

  $ perf record -b -e cycles sleep 1
  $ rdmsr -p 0 0x680
  0x1fffffffb0b9b0cc
  $ wrmsr -p 0 0x680 0x1fffffffb0b9b0cc
  write(): Input/output error

The quirk for LBR_FROM_ MSRs is required before calls to wrmsrl() and
after rdmsrl().

This patch introduces it for wrmsrl()'s done for testing LBR support.

Future patch in series adds the quirk for context switch, that would
be required if LBR callstack is to be enabled for ring 0.

Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Stephane Eranian <eranian@google.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: http://lkml.kernel.org/r/1466533874-52003-3-git-send-email-davidcc@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-06-27 11:34:19 +02:00
David Carrillo-Cisneros
f09509b939 perf/x86/intel: Print LBR support statement after validation
The following commit:

  338b522ca4 ("perf/x86/intel: Protect LBR and extra_regs against KVM lying")

added an additional test to LBR support detection that is performed after
printing the LBR support statement to dmesg.

Move the LBR support output after the very last test, to make sure we
print the true status of LBR support.

Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Stephane Eranian <eranian@google.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: http://lkml.kernel.org/r/1466533874-52003-2-git-send-email-davidcc@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-06-27 11:34:18 +02:00
Ingo Molnar
8114e90ea4 Linux 4.7-rc5
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQEcBAABAgAGBQJXcHi9AAoJEHm+PkMAQRiGSJ0H/2o4t9VWYmhyPC1sdIHoCExJ
 P4tBrcZYBmKcsOmIfnJDa5g/+IdhouEUM0v0fHPogS2UUWT9eRuJWYD3sY+HpEQ+
 heKTli8X73gsFB25odeIbIt0jAoSiiMYWDrWqLNsuUV1tjEYVA8rH0SM94FiOC/5
 7WVWXLTuH+Rm7JHP18BnKxmMMbzrTFmwisLMqFKyfZRRSlS+/ix7iLUNO9AFa39B
 YHxNPihLrZ0oONyCOAQoHTIXXrw0cQbxV2utg3vnMcCZdme2xOn+iXMntTSKfZ39
 iC9/T0vsO3R6OrRo2aDZAnCPUAniXnMEIhrKG37WMyXpj6cucZ/2QiNXcXviGV4=
 =iLte
 -----END PGP SIGNATURE-----

Merge tag 'v4.7-rc5' into perf/core, to pick up fixes

Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-06-27 11:20:46 +02:00
Linus Torvalds
4c2e07c6a2 Linux 4.7-rc5 2016-06-26 17:52:03 -07:00
Linus Torvalds
2ac9b9735b SCSI fixes on 20160625
Two straightforward fixes.  One is a concurrency issue only affecting
 SAS connected SATA drives, but which could hang the storage subsystem
 if it triggers (because the outstanding command count on error never
 goes back to zero) and the other is a NO_TAG fallout from the switch
 to hostwide tags which causes the system to crash on module insertion
 (we've checked carefully and only the 53c700 family of drivers is
 vulnerable to this issue).
 
 Signed-off-by: James Bottomley <jejb@linux.vnet.ibm.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABAgAGBQJXbtgBAAoJEAVr7HOZEZN4/EQP/0diQXZawG4Ncy4dYmrzYDeR
 4R5OqkV5hJapzJD4De/DqTRxKVIsxVLkgM4wVT7KHv0QndX81ipdKsiWyUyXJ3nb
 5HBvJ/GhAUnVyVM1nMGqK81Sk68zJiLoJ32lnE099GP6eJKtRtWgfKvEHPimhDWc
 S42s6t6dhyirmXmVQ0Jyx1/c1y8RuL5dTCMXjkP1LdTc5UnZ7b3HeKIxE0YJ3xRs
 ZsHdEPDk7UR1UUXWIdqjx/P0elgDMExkOaAQUCeZV2aWiV8OgW+OSSzjSxDvlJLk
 IBeggRjdiqEBCyuU5QqfQjISaFR0POf5q41Bomg+Zq9XtkdEovRhSwdkP2/GY/TD
 wEozTZKkRh1RcYtCNOASOgvmpHXcGBWhMk6iqmsbl/LIL5UXdvB9EAzhHlAZ/kai
 Szs3w7IBye6CfISPoFPstNav8DFkse2lf6fVdEEdmRLF8wXGhAXugAdEw3fbuiJX
 9SMwTQqSEMZCQJm4rW2vMSncmatvKfce/SXLvrEEpWFyOM984Q0ZGUTMCCKDstNm
 e8LmnRlMWLa/mYoo9DFIfkgRNd1gH6j+gIPsj+Rtkhk4Q3YC9Rr6gERvuRjGM9XU
 EI611dRUA2YQtclG2DKHkkY1wdN15RyrGR50I3VLaRv0RzwY5HCV1JGEemAokgpU
 BfXrmW3kPfh7fUAHhLqF
 =5jjT
 -----END PGP SIGNATURE-----

Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "Two straightforward fixes.

  One is a concurrency issue only affecting SAS connected SATA drives,
  but which could hang the storage subsystem if it triggers (because the
  outstanding command count on error never goes back to zero) and the
  other is a NO_TAG fallout from the switch to hostwide tags which
  causes the system to crash on module insertion (we've checked
  carefully and only the 53c700 family of drivers is vulnerable to this
  issue)"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  53c700: fix BUG on untagged commands
  scsi: fix race between simultaneous decrements of ->host_failed
2016-06-26 10:08:49 -07:00
Ingo Molnar
9840b1ae45 perf/core improvements and fixes:
New features:
 
 - Add 'callindent' option to 'perf script -F', to indent the Intel PT
   call stack, making this output more ftrace-like (Adrian Hunter, Andi Kleen)
 
 User visible:
 
 - Enlarge 'pid' column width, to cope with large pids (Jiri Olsa)
 
 Infrastructure:
 
 - Cross platform unwind fixes (He Kuang)
 
 - Make destructors accept NULL, behaving like free() (Arnaldo Carvalho de Melo)
 
 - Remove reference to perl interpreted in the recently added 'perf script'
   stackcollapse python script (Arnaldo Carvalho de Melo)
 
 - Rename CLASS__for_each() macros to CLASS__for_each_entry(), to use the
   list_for_each_entry() semantics, as most of these class specific loop helpers
   are list_for_each_entry*() wrappers  (Arnaldo Carvalho de Melo)
 
 - Expose the hist_browser code, will be used with data structures other
   than perf_evsel (Jiri Olsa)
 
 - 'perf config' refactorings (Taeung Song)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJXbFIcAAoJENZQFvNTUqpADw0QAJzIZK63uJ+kA3eq91go3oJi
 GDYqhA/HSV6cBHKG4CEuemKLYIK6GrnmLYK8wPquh8h1VkoRmBuV7AoLUbUdVW6P
 uINnJXqC45d/picN6z4K/KLfZAt/cT3FEl/JIRcMw72SyNhHfOvcPEUWZ+FCikWR
 11FtuU4bjIc+ctiXxn+Gwx1v3NacATRDIBiqHaUPVZtbWLXOcWKvgX6F6a0WCDF9
 0SPSyoW6nZDEl4aZScQ4eW8XwF4xFZesj0q/8JOP0XrMGQ7HtcvRSSoXhTrTlE5f
 MGF6OIfNOBuQhqKDrpfU/jwCqORA4dcv67iTo2MCfq+w3FiLMMCU7pB9543N5YT6
 WW70k2/AvFnhuD5gRZMHGZujRw7Ya1ZnVt9V6WtT5ia4he7dJC/7g26nee1OLRrT
 ug0l/03xOVVsZYQrAFo3efMYS7uMqMUP1Sdp5ujZ/KoEuSsQ/PJSvGyInsB9k994
 nmz4jGhDdRV7AqrxnhIwmcQJmukWSPjYF3Ei3rHRxa18HC29rKPQ9GvJHMMKt7wT
 JRP/Mle3ZyzRnMjFP+Rc/MOzQruqatCy3d/NH7ndL/UFzlW+873USK8Uj9VxuX20
 fvgl4yVcHJIzjiguuzF2AADpweWUdyk0oKMcyXblGT3Iokmr3su15Ml/Lg/U4sVN
 ey2y0qcut8K1uV1++Wlq
 =HRRs
 -----END PGP SIGNATURE-----

Merge tag 'perf-core-for-mingo-20160623' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

New features:

- Add 'callindent' option to 'perf script -F', to indent the Intel PT
  call stack, making this output more ftrace-like (Adrian Hunter, Andi Kleen)

User visible changes:

- Enlarge 'pid' column width, to cope with large pids (Jiri Olsa)

Infrastructure changes:

- Fix cross platform unwind (He Kuang)

- Make destructors accept NULL, behaving like free() (Arnaldo Carvalho de Melo)

- Remove reference to perl interpreted in the recently added 'perf script'
  stackcollapse python script (Arnaldo Carvalho de Melo)

- Rename CLASS__for_each() macros to CLASS__for_each_entry(), to use the
  list_for_each_entry() semantics, as most of these class specific loop helpers
  are list_for_each_entry*() wrappers  (Arnaldo Carvalho de Melo)

- Expose the hist_browser code, will be used with data structures other
  than perf_evsel (Jiri Olsa)

- Refactor 'perf config' (Taeung Song)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-06-26 12:41:59 +02:00