Commit Graph

520065 Commits

Author SHA1 Message Date
Andi Kleen
5b021ddf81 perf tools: Allow events with dot
The Intel events use a dot to separate event name and unit mask.  Allow
dot in names in the scanner, and remove special handling of dot as EOF.
Also remove the hack in jevents to replace dot with underscore. This way
dotted events can be specified directly by the user.

I'm not fully sure this change to the scanner is correct (what was the
dot special case good for?), but I haven't found anything that breaks
with it so far at least.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/1433921123-25327-8-git-send-email-sukadev@linux.vnet.ibm.com
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-23 18:21:37 -03:00
Sukadev Bhattiprolu
70c646e0e4 perf pmu: Split perf_pmu__new_alias()
Separate the event parsing code in perf_pmu__new_alias() out into a
separate function __perf_pmu__new_alias() so that code can be called
indepdently.

This is based on an earlier patch from Andi Kleen.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/1433921123-25327-5-git-send-email-sukadev@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-23 18:21:30 -03:00
Sukadev Bhattiprolu
c5de47f2e8 perf pmu: Use __weak definition from <linux/compiler.h>
Jiri Olsa pointed out, that the <linux/compiler.h> defines the attribute
'__weak'. We might as well use that.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/1433921123-25327-4-git-send-email-sukadev@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-23 18:21:15 -03:00
Jiri Olsa
8e55735150 perf build: Fix single target build dependency check
Currently if we build a single target like:

  $ touch util/map.c && make util/map.o

It will not rebuild util/map.o if it already exists and util/map.c is
modified.

The reason is that the top-level 'Makefile' processes util/map.o as an
implicit rule and if util/map.o exists make considers the 'util/map.o'
target as done and will not nest into Makefile.perf.

Adding FORCE for '%', because that's what we want to nest into
Makefile.perf for any target.

Adding Makefile into phony targets, because make tries to rebuild it and
it's also resolved as '%' target.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1434977452-32520-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-22 11:27:09 -03:00
Jiri Olsa
eb30d2c507 perf tests: Add test for make install with prefix
Lukas Wunner reported issue (and fix[1]) with 'make install prefix=...'.
Adding automated test for this, so it wouldn't happen again.

[1]: 75e84ab906 ("perf tools: Fix build breakage if prefix= is specified")

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1434977452-32520-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-22 11:24:05 -03:00
Jiri Olsa
502819c5f3 perf tests: Add testing for Makefile.perf
Currently we test only builds through top level Makefile, but seems like
there's a bunch of users using Makefile.perf directly.

Changing the make suite to be run for Makefile.perf as well.  It takes
now considerable amount of time, but hopefully we catch more issues.

Also fixing the output indentation for make_kernelsrc and
make_kernelsrc_tools tests.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1434977452-32520-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-22 11:21:57 -03:00
Namhyung Kim
13d1e536b1 perf top: Move toggling event logic into hists browser
Current 'f' key action to enable/disable events won't work if there're
more than one event since perf_evsel_menu__run() doesn't return the key.
So move it to the hists browser loop so that it can be processed as like
other key action, and it's more natural to handle it there IMHO.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1434858076-6533-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-22 11:21:11 -03:00
Ingo Molnar
a9a3cd900f perf/core improvements and fixes:
User visible:
 
 - Replace CTRL+z with 'f' as hotkey for enable/disable events (Arnaldo Carvalho de Melo)
 
 - Do not exit when 'f' is pressed in 'report' mode (Arnaldo Carvalho de Melo)
 
 - Tell the user how to unfreeze events after pressing 'f' in 'perf top' (Arnaldo Carvalho de Melo)
 
 - React to unassigned hotkey pressing in 'top/report' (Arnaldo Carvalho de Melo)
 
 - Display total number of samples with --show-total-period in 'annotate' (Martin Liška)
 
 - Add timeout to make procfs mmap processing more robust (Kan Liang)
 
 - Fix sort__sym_cmp to also compare end of symbol (Yannick Brosseau)
 
 Infrastructure:
 
 - Ensure thread-stack is flushed (Adrian Hunter)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJVhI78AAoJENZQFvNTUqpAwyIQAKtFpvsrgWkv4ahxOmd4vXl/
 NVxnbgP+zRf37aaQS2gH8Oe+77sQmSyY4ntTsHx7tA6QzqQ8Ag7xWfXPmyfxBkE3
 yUHciu+n2++mpYUZWOzCp1JcwwPqqpcSiLedzMruhmwrZB2rkaB67Stl9GfRmEtn
 FTnjtGo5OKuSeKdZHNbCT9GExkPaIHMv4Hd2IwrYtAPi4Ss7V0W9QteP9Sg6emFg
 OgFhAjEietYKIEEphjHDiLqRe8q0fNTkaZMnlxsmzx4KWX0MkyP1siNALdr6jZCy
 icf8w8v20l6yhlejZp6XzXQ6b5OMHjbtEs+8Oszz3nfrJl/Bpgb7yA0IhJl4SB7L
 DFiasiTw7j7cPcD+XIT9lYT9cyCKjJwRPgZKdvaUNLl7/UmVCiPYjfnAawSy0ga2
 t6eSLDqjgMrrq5WmIlQInWJC2+YUyYAPf/8YBQGbejiypic7LFvKfDAs2s5eC+vB
 DoWY87rkPqSdXVLOGYjjKTr5YVnMSKOPxoDITTZy8ETOTNq4ivAV8oBQRt+GRwVr
 bEqp911cdjK564gW2up7nzL5mb1JA9aU2xgFNd3APqtGGTcNiH9LTZ/anWe46MJQ
 hIUonSD9pHNElexhP/vmUeNjRYYbGgWPOY/ftq3xxlOfQPy/fAETq6j2vi/9j6Hs
 KKfgmgbYYG+IdoqsWfO0
 =hRlL
 -----END PGP SIGNATURE-----

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

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

User visible changes:

  - Replace CTRL+z with 'f' as hotkey for enable/disable events (Arnaldo Carvalho de Melo)

  - Do not exit when 'f' is pressed in 'report' mode (Arnaldo Carvalho de Melo)

  - Tell the user how to unfreeze events after pressing 'f' in 'perf top' (Arnaldo Carvalho de Melo)

  - React to unassigned hotkey pressing in 'top/report' (Arnaldo Carvalho de Melo)

  - Display total number of samples with --show-total-period in 'annotate' (Martin Liška)

  - Add timeout to make procfs mmap processing more robust (Kan Liang)

  - Fix sort__sym_cmp to also compare end of symbol (Yannick Brosseau)

Infrastructure changes:

  - Ensure thread-stack is flushed (Adrian Hunter)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-06-20 01:11:11 +02:00
Kan Liang
9d9cad763c perf tools: Configurable per thread proc map processing time out
The time out to limit the individual proc map processing was hard code
to 500ms. This patch introduce a new option --proc-map-timeout to make
the time limit configurable.

Signed-off-by: Kan Liang <kan.liang@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ying Huang <ying.huang@intel.com>
Link: http://lkml.kernel.org/r/1434549071-25611-2-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-19 18:27:13 -03:00
Kan Liang
930e6fcd2b perf tools: Add time out to force stop proc map processing
System wide sampling like 'perf top' or 'perf record -a' read all
threads /proc/xxx/maps before sampling. If there are any threads which
generating a keeping growing huge maps, perf will do infinite loop
during synthesizing. Nothing will be sampled.

This patch fixes this issue by adding per-thread timeout to force stop
this kind of endless proc map processing.

PERF_RECORD_MISC_PROC_MAP_PARSE_TIME_OUT is introduced to indicate that
the mmap record are truncated by time out. User will get warning
notification when truncated mmap records are detected.

Reported-by: Ying Huang <ying.huang@intel.com>
Signed-off-by: Kan Liang <kan.liang@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ying Huang <ying.huang@intel.com>
Link: http://lkml.kernel.org/r/1434549071-25611-1-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-19 18:20:15 -03:00
Yannick Brosseau
c05676c062 perf report: Fix sort__sym_cmp to also compare end of symbol
When using a map file from a JIT, due to memory reuse, we can obtain
multiple symbols with the same start address but a different length.

The symbols__find does check for the end so not doing it in
sort__sym_cmp was causing the hist_entry in the annotate part of a
report to match to the wrong entry, causing a fatal error.

Signed-off-by: Yannick Brosseau <scientist@fb.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: kernel-team@fb.com
Link: http://lkml.kernel.org/r/1434584470-17771-1-git-send-email-scientist@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-19 18:14:05 -03:00
Arnaldo Carvalho de Melo
3e323dc0a8 perf hists browser: React to unassigned hotkey pressing
When that happens we were just ignoring the key press, now this
message is presented in the bottom line (the help line):

  "Press '?' for help on key bindings"

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-iyma2j5kj3q9i1stl4mfh90n@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-19 18:14:05 -03:00
Arnaldo Carvalho de Melo
ae3b6ab603 perf top: Tell the user how to unfreeze events after pressing 'f'
When the user presses 'f' to disable events the visual cues are, well,
the percentages not changing and the number of events freezing.

Be more explicit by changing the help line at the bottom of the screen
to show the following messages when 'f' is pressed:

  "Press 'f' again to re-enable the events"

And then, when 'f' is pressed again:

  "Press 'f' to disable the events or 'h'

Suggested-by: Ingo Molnar <mingo@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-uhiswg9a9rxm5gxg7ptjskjn@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-19 18:13:59 -03:00
Arnaldo Carvalho de Melo
5f00b0f45b perf hists browser: Honour the help line provided by builtin-{top,report}.c
The hists_browser was replacing whatever helpline provided by 'top' or
'report' with a static "Press '?' for help on key bindings", fix it.

Now the message passed by top appears at the bottom of the screen:

"For a higher level overview, try: perf top --sort comm,dso"

As well the message that will be added when the user presses 'f' to
disable the events, something along the lines of "press f again to
re-enable...".

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-dacaja70mbfz3a0yj1n180gx@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-19 17:30:20 -03:00
Arnaldo Carvalho de Melo
516e536849 perf hists browser: Do not exit when 'f' is pressed in 'report' mode
The 'f' hotkey is only used when in 'top', dynamic mode, to
enable/disable events, currently not making sense in the 'report',
static mode, where we can't go from showing the histogram entries
created from a perf.data file to adding more events after recreating the
evlist created from the perf.data file, albeit possible, this is not
implemented right now.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-lholzf472pu98dkkijggwx2m@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-19 16:59:43 -03:00
Arnaldo Carvalho de Melo
fbb7997e30 perf top: Replace CTRL+z with 'f' as hotkey for enable/disable events
I.e. 'freeze'/'unfreeze', this is because CTRL+z has a well known
action, i.e. suspend the app, perf needs to follow that convention, that
will be done on a separate patch, tho.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-oedcl6ovohara4koig14ayip@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-19 16:56:04 -03:00
Arnaldo Carvalho de Melo
276af92f10 perf annotate: Rename source_line_percent to source_line_samples
To better reflect the purpose of this struct, that is to hold
info about samples, its total number and is percentage.

Cc: Martin Liska <mliska@suse.cz>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/n/tip-6bf8gwcl975uurl0ttpvtk69@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-19 16:39:21 -03:00
Martin Liška
0c4a5bcea4 perf annotate: Display total number of samples with --show-total-period
To compare two records on an instruction base, with --show-total-period
option provided, display total number of samples that belong to a line
in assembly language.

New hot key 't' is introduced for 'perf annotate' TUI.

Signed-off-by: Martin Liska <mliska@suse.cz>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/5583E26D.1040407@suse.cz
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-19 16:39:18 -03:00
Adrian Hunter
a5499b3719 perf tools: Ensure thread-stack is flushed
The thread-stack represents a thread's current stack.  When a thread
exits there can still be many functions on the stack e.g. exit() can be
called many levels deep, so all the callers will never return.  To get
that information output, the thread-stack must be flushed.

Previously it was assumed the thread-stack would be flushed when the
struct thread was deleted.  With thread ref-counting it is no longer
clear when that will be, if ever. So instead explicitly flush all the
thread-stacks at the end of a session.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1432906425-9911-3-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-19 16:03:33 -03:00
Ingo Molnar
79928928c5 perf/core improvements and fixes:
User visible:
 
 - Allow disabling/enabling events dynamicly in 'perf top':
   a 'perf top' session can instantly become a 'perf report'
   one, i.e. going from dynamic analysis to a static one,
   returning to a dynamic one is possible, to toogle the
   modes, just press CTRL+z. (Arnaldo Carvalho de Melo)
 
 - Greatly speed up 'perf probe --list' by caching debuginfo
   (Masami Hiramatsu)
 
 - Fix 'perf trace' race condition at the end of started
   workloads (Sukadev Bhattiprolu)
 
 - Fix a problem when opening old perf.data with different
   byte order (Wang Nan)
 
 Infrastructure:
 
 - Ignore .config-detected in .gitignore (Wang Nan)
 
 - Move libtraceevent dynamic list to separated LDFLAGS
   variable (Wang Nan)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJVgeMMAAoJENZQFvNTUqpAN6oP/jnkFswb0ul0ZhznxDrHfLwy
 +mjItjuDpWBS2haRF7IPaBkMu+NwKbTIT45r2P+EcV8PvVbevxjaTmtzMgnbFxNE
 al80A+y3HtFPbRj7Am5yaYnd5Z/BOVLfvqk41vX+GNBr9esqgrNNFwTbVatnn1fM
 RF2fbr83VcQJO6CysT4EwxHS2dsFfG3R1R3VsO5aVrsGNjWoBhB+5ljRr4KHYUBN
 CmEUut+J7vELZvmoJfiJzpfsesRydZegAHJc0MLPADvgGFn/bZbyZ95YfvFJcPq9
 Tf/GPp4J2J0iJccNdV2RhBZNCUlDvz4PPdxZsAhaSdA/4Z0uwzcTLPA7GNlQZ0I5
 h+tqBJTSM91m+6N2FRzZAEJpEnAdHONljNJeAl3XRR6/W1dh9HxxzWf5ECvu1Lpf
 az4z3Wf5tnoNwRBP2wxV8vau/r0IgRDclw8TY8bRgdeMNSBxcG0i5G80uSFQRV1m
 KoHGUA1ykjX/9NVAr7giOJ/B8UR2yK2TPWEzQH781RVKZZlH4mnXgNt0OqmXonuU
 WKZSLKbGg8wCKRVbmf/Q/pf15jYLQnKKqm39YjTadkW+u4GeW9C89YyTaQeahy1o
 efIVm4ecS4MOtqaOsedYqMvgf0Gtv1Ud+2hT0qH01jz1IsUCHgtPCkvjAysnOBK8
 51AoegTS5VWzX3xa9Hy+
 =hhW4
 -----END PGP SIGNATURE-----

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

  - List perf probes to stdout. (Masami Hiramatsu)

  - Return error when none of the requested probes were
    installed. (Masami Hiramatsu)

  - Cut off the gcc optimization postfixes from
    function name in 'perf probe'. (Masami Hiramatsu)

  - Allow disabling/enabling events dynamicly in 'perf top':
    a 'perf top' session can instantly become a 'perf report'
    one, i.e. going from dynamic analysis to a static one,
    returning to a dynamic one is possible, to toogle the
    modes, just press CTRL+z. (Arnaldo Carvalho de Melo)

  - Greatly speed up 'perf probe --list' by caching debuginfo.
    (Masami Hiramatsu)

  - Fix 'perf trace' race condition at the end of started
    workloads. (Sukadev Bhattiprolu)

  - Fix a problem when opening old perf.data with different
    byte order. (Wang Nan)

Infrastructure changes:

  - Replace map->referenced & maps->removed_maps with
    map->refcnt. (Arnaldo Carvalho de Melo)

  - Introduce the xyarray__reset() function. (Jiri Olsa)

  - Add thread_map__(alloc|realloc)() helpers. (Jiri Olsa)

  - Move perf_evsel__(alloc|free|reset)_counts into stat object. (Jiri Olsa)

  - Introduce perf_counts__(new|delete|reset)() functions. (Jiri Olsa)

  - Ignore .config-detected in .gitignore. (Wang Nan)

  - Move libtraceevent dynamic list to separated LDFLAGS
    variable. (Wang Nan)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-06-18 09:40:46 +02:00
Arnaldo Carvalho de Melo
5d484f99ae perf top: Allow disabling/enabling events dynamicly
Now it is possible to press CTRL+z at anytime and that will disable the
events being monitored, essentially turning 'top' into 'report', with
pressing CTRL+z again making it enable the events again, returning to
the 'top' behaviour, i.e. dynamic + decaying of older samples.

One may want, for instance, play with:

    -d, --delay <n>       number of seconds to delay between refreshes

and:

    -z, --zero            zero history across updates

Plus CTRL+z to see only the events since last zeroing, etc.

Suggested-by: Ingo Molnar <mingo@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-zq7tnh5462blt2yda0bcxh5b@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-17 16:50:52 -03:00
Arnaldo Carvalho de Melo
2b56bcfb6f perf evlist: Add toggle_enable() method
For an upcoming feature in 'perf top' we will have a hotkey to
enable/disable events, so remember if the events in the list are
enabled or disabled and allows toggling this state using a new
method.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-64c4jvdl5feg2zhimxvokqka@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-17 16:40:26 -03:00
Sukadev Bhattiprolu
7951722da2 perf trace: Fix race condition at the end of started workloads
I get following crash on multiple systems and across several releases
(at least since v3.18).

	Core was generated by `/tmp/perf trace sleep 0.2 '.
	Program terminated with signal SIGSEGV, Segmentation fault.
	#0  perf_mmap__read_head (mm=0x3fff9bf30070) at util/evlist.h:195
	195		u64 head = ACCESS_ONCE(pc->data_head);
	(gdb) bt
	#0  perf_mmap__read_head (mm=0x3fff9bf30070) at util/evlist.h:195
	#1  perf_evlist__mmap_read (evlist=0x10027f11910, idx=<optimized out>)
	    at util/evlist.c:637
	#2  0x000000001003ce4c in trace__run (argv=<optimized out>,
	    argc=<optimized out>, trace=0x3fffd7b28288) at builtin-trace.c:2259
	#3  cmd_trace (argc=<optimized out>, argv=<optimized out>,
	    prefix=<optimized out>) at builtin-trace.c:2799
	#4  0x00000000100657b8 in run_builtin (p=0x10176798 <commands+480>, argc=3,
	    argv=0x3fffd7b2b550) at perf.c:370
	#5  0x00000000100063e8 in handle_internal_command (argv=0x3fffd7b2b550, argc=3)
	    at perf.c:429
	#6  run_argv (argv=0x3fffd7b2af70, argcp=0x3fffd7b2af7c) at perf.c:473
	#7  main (argc=3, argv=0x3fffd7b2b550) at perf.c:588

The problem seems to be a race condition, when the application has just
exited.  Some/all fds associated with the perf-events (tracepoints) go
into a POLLHUP/ POLLERR state and the mmap region associated with those
events are unmapped (in perf_evlist__filter_pollfd()).

But we go back and do a perf_evlist__mmap_read() which assumes that the
mmaps are still valid and we hit the crash.

If the mapping for an event is released, its refcnt is 0 (and ->base
is NULL), so ensure we have non-zero refcount before accessing the map.

Note that perf-record has a similar logic but unlike perf-trace, the
record__mmap_read_all() checks the evlist->mmap[i].base before accessing
the map.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Li Zhang <zhlcindy@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/20150612060003.GA19913@us.ibm.com
[ Fixed it up to use atomic_read() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-17 16:38:48 -03:00
Masami Hiramatsu
7737af010b perf probe: Speed up perf probe --list by caching debuginfo
Speed up the "perf probe --list" by caching the last used debuginfo.
perf probe --list always open and load debuginfo for each entry of probe
list. This takes very a long time.

E.g. with vfs_* events (total 96 probes)

  [root@localhost perf]# time  ./perf probe -l &> /dev/null

  real    0m25.376s
  user    0m24.381s
  sys     0m1.012s

To solve this issue, this adds debuginfo_cache to cache the
last used debuginfo on memory.

With this fix, the perf-probe --list significantly improves
its speed.

  [root@localhost perf]#  time  ./perf probe -l &> /dev/null

  real    0m0.161s
  user    0m0.136s
  sys     0m0.025s

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Naohiro Aota <naota@elisp.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150617145854.19715.15314.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-17 16:37:53 -03:00
Masami Hiramatsu
d350bd571f perf probe: Show usage even if the last event is skipped
When the last part of converted events are blacklisted or out-of-text,
those are skipped and perf probe doesn't show usage examples.  This
fixes it to show the example even if the last part of event list is
skipped.

E.g. without this patch, events are added, but suddenly end:

  # perf probe vfs_*
  vfs_caches_init_early is out of .text, skip it.
  vfs_caches_init is out of .text, skip it.
  Added new events:
    probe:vfs_fallocate  (on vfs_*)
    probe:vfs_open       (on vfs_*)
  ...
    probe:vfs_dentry_acceptable (on vfs_*)
    probe:vfs_load_quota_inode (on vfs_*)
  #

With this fix:

  # perf probe vfs_*
  vfs_caches_init_early is out of .text, skip it.
  vfs_caches_init is out of .text, skip it.
  Added new events:
    probe:vfs_fallocate  (on vfs_*)
  ...
    probe:vfs_load_quota_inode (on vfs_*)

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

	perf record -e probe:vfs_load_quota_inode -aR sleep 1

Note that this can be reproduced ONLY IF the vfs_caches_init* is the
last part of matched symbol list. I've checked this happens on
"3.19.0-generic #18-Ubuntu" kernel binary.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Naohiro Aota <naota@elisp.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150616115057.19906.5502.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-17 16:31:42 -03:00
Wang Nan
5d618324dd perf tools: Move libtraceevent dynamic list to separated LDFLAGS variable
Commit e3d09ec812 ("tools lib traceevent:
Export dynamic symbols used by traceevent plugins") adds libtraceevent
dynamic list directly into LDFLAGS, which makes all targets depend on
that list through LDFLAGS.

This is not good since some of targets like libgtk.so doesn't use plugin
at all, but require the existance of that list because of linker
options.

This patch isolates the -Xlink option into LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS,
makes only perf and perf.so use it.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1434552389-89144-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-17 16:29:25 -03:00
Wang Nan
b30b617292 perf tools: Fix a problem when opening old perf.data with different byte order
Following error occurs when trying to use 'perf report' on x86_64 to
cross analysis a perf.data generated by an old perf on a big-endian
machine:

 # perf report
 *** Error in `/home/w00229757/perf': free(): invalid next size (fast): 0x00000000032c99f0 ***
 ======= Backtrace: =========
 /lib64/libc.so.6(+0x6eeef)[0x7ff6ff7e2eef]
 /lib64/libc.so.6(+0x78cae)[0x7ff6ff7eccae]
 /lib64/libc.so.6(+0x79987)[0x7ff6ff7ed987]
 /path/to/perf[0x4ac734]
 /path/to/perf[0x4ac829]
 /path/to/perf(perf_header__process_sections+0x129)[0x4ad2c9]
 /path/to/perf(perf_session__read_header+0x2e1)[0x4ad9e1]
 /path/to/perf(perf_session__new+0x168)[0x4bd458]
 /path/to/perf(cmd_report+0xfa0)[0x43eb70]
 /path/to/perf[0x47adc3]
 /path/to/perf(main+0x5f6)[0x42fd06]
 /lib64/libc.so.6(__libc_start_main+0xf5)[0x7ff6ff795bd5]
 /path/to/perf[0x42fe35]
 ======= Memory map: ========
 [SNIP]

The bug is in perf_event__attr_swap(). It swaps all fields in 'struct
perf_event_attr' without checking whether the swapped field exist or
not. In addition, in read_event_desc() allocs memory for attr according
to size read from perf.data.

Therefore, if the perf.data is collected by an old perf (without
aux_watermark, for example), when perf_event__attr_swap() swaping
attr->aux_watermark it destroy malloc's metadata.

This patch introduces boundary checking in perf_event__attr_swap(). It
adds macros bswap_field_64 and bswap_field_32 into
perf_event__attr_swap() to make it only swap exist fields.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1434534999-85347-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-17 16:28:08 -03:00
Wang Nan
386299735e perf tools: Ignore .config-detected in .gitignore
Commit fcfd6611fb ("tools build: Add
detected config support") dynamically creates .config-detected. Add it
to .gitignore.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Link: http://lkml.kernel.org/r/1434542358-5430-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-17 12:44:55 -03:00
Masami Hiramatsu
b031220d52 perf probe: Fix to return error if no probe is added
Fix perf probe to return an error if no probe is added due to the given
probe point being on the blacklist.

To fix this problem, this moves the blacklist checking to right after
finding symbols/probe-points and marks them as skipped.

If all the symbols are skipped, "perf probe"  returns an error as it
fails to find the corresponding probe address.

E.g. currently if a blacklisted probe is given:

  # perf probe do_trap && echo 'succeed'
  Added new event:
  Warning: Skipped probing on blacklisted function: sync_regs
  succeed

No! It must fail! With this patch, it correctly fails:

  # perf probe do_trap && echo 'succeed'
  do_trap is blacklisted function, skip it.
  Probe point 'do_trap' not found.
    Error: Failed to add events.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Naohiro Aota <naota@elisp.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150616115055.19906.31359.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-16 11:39:51 -03:00
Hou Pengyang
f005813afb perf unwind: Fix a compile error
When libunwind is on, there is a compile error as :

  util/unwind-libunwind.c:363:21: error: 'dso' undeclared (first use in this function)
      dso__data_put_fd(dso);

This patch fixes it.

Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: 4bb11d012a ("perf tools: Add dso__data_get/put_fd()")
Link: http://lkml.kernel.org/r/1434453395-10560-1-git-send-email-houpengyang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-16 10:40:03 -03:00
Jiri Olsa
9df38e82e2 perf stat: Introduce perf_counts__(new|delete|reset) functions
Move 'struct perf_counts' allocation|free|reset code into separate
functions.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1434269985-521-13-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-16 10:34:41 -03:00
Jiri Olsa
a9a3a4d92d perf tools: Move perf_evsel__(alloc|free|reset)_counts into stat object
It's stat specific. Updating python build objects with stat.c.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1434269985-521-12-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-16 10:34:40 -03:00
Jiri Olsa
9d7e8c3a96 perf tools: Add thread_map__(alloc|realloc) helpers
In order to have 'struct thread_map' allocation on single place and can
change it easily in following patch.

Using alloc|realloc for static helpers, because thread_map__new is
already used in public interface.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1434269985-521-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-16 10:34:40 -03:00
Jiri Olsa
b45f65e8fd perf tools: Introduce xyarray__reset function
To zero all the xyarray contents. It will be used in following patches.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1434269985-521-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-16 10:34:39 -03:00
Masami Hiramatsu
ba7ecb02e7 perf probe: List probes in stdout
Since commit 5e17b28f1e ("perf probe: Add --quiet option to
suppress output result message") have replaced printf with pr_info,
perf probe -l outputs its result in stderr. However, that is not
what the commit expected.

E.g.:

  # perf probe -l > /dev/null
    probe:vfs_read       (on vfs_read@ksrc/linux-3/fs/read_write.c)

With this fix:

  # perf probe -l > list
  # cat list
    probe:vfs_read       (on vfs_read@ksrc/linux-3/fs/read_write.c)

Of course, --quiet(-q) still works on --add/--del.

  # perf probe -q vfs_write
  # perf probe -l
    probe:vfs_read       (on vfs_read@ksrc/linux-3/fs/read_write.c)
    probe:vfs_write      (on vfs_write@ksrc/linux-3/fs/read_write.c)
  -----

Reported-by: Naohiro Aota <naota@elisp.net>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Naohiro Aota <naota@elisp.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150613013116.24402.2923.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-16 10:34:39 -03:00
Wang Nan
a35489a6a2 tools lib traceevent: Fix python/perf.so compiling error
'make build-test' finds an error that make_python_perf_so fails due to
missing of libtraceevent-dynamic-list:

 '.../python2' util/setup.py \
   --quiet build_ext; \
   mkdir -p python && \
   cp python_ext_build/lib/perf.so python/
   /path/to/ld: cannot open linker script file /path/to/kernel/tools/lib/traceevent/libtraceevent-dynamic-list: No such file or directory
   collect2: error: ld returned 1 exit status
   error: command 'x86_64-linux-gcc' failed with exit status 1
   cp: cannot stat 'python_ext_build/lib/perf.so': No such file or directory
   make[3]: *** [python/perf.so] Error 1
   make[2]: *** [python/perf.so] Error 2
     test: test -f ./python/perf.so
     make[1]: *** [make_python_perf_so] Error 1
     make: *** [build-test] Error 2
     make: Leaving directory `/path/to/kernel/tools/perf'

This is caused by commit e3d09ec812
("tools lib traceevent: Export dynamic symbols used by traceevent
plugins") that, it adds the list file to LDFLAGS but forgot to add it to
dependency list of python/perf.so.

This patch fixes this problem.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Link: http://lkml.kernel.org/r/1434079031-123162-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-16 10:34:38 -03:00
Arnaldo Carvalho de Melo
5c24b67aae perf tools: Replace map->referenced & maps->removed_maps with map->refcnt
Use just reference counts, so that when no more hist_entry instances
references a map and the thread instance goes away by processing a
PERF_RECORD_EXIT, we can delete the maps.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-oym7lfhcc7ss6xpz44h7nbxs@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-16 10:34:38 -03:00
Masami Hiramatsu
35a23ff928 perf probe: Cut off the gcc optimization postfixes from function name
Cut off the postfixes which gcc added for optimized routines from the
event name automatically generated from symbol name, since *probe-events
doesn't accept it.  Those symbols will be used if we don't use debuginfo
to find target functions.

E.g. without this fix;
  -----
  # perf probe -va alloc_buf.isra.23
  probe-definition(0): alloc_buf.isra.23
  symbol:alloc_buf.isra.23 file:(null) line:0 offset:0 return:0 lazy:(null)
  [...]
  Opening /sys/kernel/debug/tracing/kprobe_events write=1
  Added new event:
  Writing event: p:probe/alloc_buf.isra.23 _text+4869328
  Failed to write event: Invalid argument
    Error: Failed to add events. Reason: Invalid argument (Code: -22)
  -----
With this fix;
  -----
  perf probe -va alloc_buf.isra.23
  probe-definition(0): alloc_buf.isra.23
  symbol:alloc_buf.isra.23 file:(null) line:0 offset:0 return:0 lazy:(null)
  [...]
  Opening /sys/kernel/debug/tracing/kprobe_events write=1
  Added new event:
  Writing event: p:probe/alloc_buf _text+4869328
    probe:alloc_buf      (on alloc_buf.isra.23)

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

  	perf record -e probe:alloc_buf -aR sleep 1

  -----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Naohiro Aota <naota@elisp.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150612050820.20548.41625.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-12 16:14:48 -03:00
Ingo Molnar
61d67d5684 perf/core improvements and fixes:
User visible:
 
 - Beautify perf_event_open syscall in 'perf trace'. (Arnaldo Carvalho de Melo)
 
 - Error out unsupported group leader immediately in 'perf stat'. (Kan Liang)
 
 - Amend some 'perf record' option summaries (period, etc) (Peter Zijlstra)
 
 - Avoid possible race condition in copyfile() in 'perf buildid-cache'. (Milos Vyletel)
 
 Infrastructure:
 
 - Display 0x for hex values when printing the attribute. (Adrian Hunter)
 
 - Update MANIFEST per files removed from kernel. (David Ahern)
 
 Build fixes:
 
 - Fix PRIu64 printf related failure on 32-bit arch. (He Kuang)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJVekB2AAoJENZQFvNTUqpAVHsP/iP0PSmOC2TCW+si3z6NADYo
 VISHlS2J5L5QWH9xVm7eguZUJUlPL1Jft5l+bK51m52+gZYskjRx5yDj7kDIyT9l
 IvgoQPHqt9Atb1W5zV6FChoCjZZjBpz76CaF2SliWGzf7Pl1IGZiCthN7TMaAT+m
 15fglKhxqqRqXNey4aD8UpUG/7ym0VIUH0QutfS7CtDk5RczGEG8WYzMA+ohDTEm
 zPBuhCop0poEXOUtugyKql13h3moNqMyUc6/JQwPm6pdbxCHTrROmGEUNQqpuema
 G8piYCsWagCgy3QwOZzJwutxeCnkoVcjtuOP46n6Y6v7quOxZDvup5gNov0qGMRt
 m3X3K0z9MPbCbQ5xpj3G2hWuiGUotauXWSjReSxel+B7nHhLvBAvamp+0BhxkjZU
 azPt7iP+IMEIImAYj+OM95b67R5ztDefZfV/z3xIEq9A5LUVCVBcD1BdCjWk2laz
 xgxorebg9GKGIU7U3dB6yNbHtpWwzhV1ayyGrYA+dFAsHK6pFnYAVYAOORJTIghM
 aw/9QzWFlwkGCNxZn5WAIKav/TT8iTPqu0kahwtluE8n5jSBJi2+bJyGLEv+uDjC
 iVRKGrv/7zzLa3YNgDcTZxzL8rZaUunVd94IXA/CVZmS9m4FSHhkZkcHc9BQJ4QH
 tEjMTQxsrDjvJ/MyUARo
 =ZWn3
 -----END PGP SIGNATURE-----

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

Pull perf/core improvements and fixes:

User visible changes:

  - Beautify the perf_event_open() syscall in 'perf trace'. (Arnaldo Carvalho de Melo)

  - Error out unsupported group leader immediately in 'perf stat'. (Kan Liang)

  - Amend some 'perf record' option summaries (period, etc). (Peter Zijlstra)

  - Avoid possible race condition in copyfile() in 'perf buildid-cache'. (Milos Vyletel)

Infrastructure changes:

  - Display 0x for hex values when printing the attribute. (Adrian Hunter)

  - Update MANIFEST per files removed from kernel. (David Ahern)

Build fixes:

  - Fix PRIu64 printf related failure on 32-bit arch. (He Kuang)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-06-12 10:08:38 +02:00
David Ahern
c8ad706362 perf tools: Update MANIFEST per files removed from kernel
Building perf out of kernel tree is currently broken because the
MANIFEST file refers to kernel files that have been removed. With this
patch make perf-targz-src-pkg succeeds as does building perf using the
generated tarfile.

Signed-off-by: David Ahern <david.ahern@oracle.com>
Link: http://lkml.kernel.org/r/1433526173-172332-1-git-send-email-david.ahern@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-11 22:54:23 -03:00
Arnaldo Carvalho de Melo
a1c2552dba trace: Beautify perf_event_open syscall
Syswide tracing and then running 'stat' and 'trace':

 $ perf trace -e perf_event_open
 1034.649 (0.019 ms): perf/6133 perf_event_open(attr_uptr: 0x36f0360, pid: 16134, cpu: -1, group_fd: -1, flags: FD_CLOEXEC) = -1 EINVAL Invalid argument
 1034.670 (0.008 ms): perf/6133 perf_event_open(attr_uptr: 0x36f0360, pid: 16134, cpu: -1, group_fd: -1) = -1 EINVAL Invalid argument
 1034.681 (0.007 ms): perf/6133 perf_event_open(attr_uptr: 0x36f0360, pid: 16134, cpu: -1, group_fd: -1) = -1 EINVAL Invalid argument
 1034.692 (0.007 ms): perf/6133 perf_event_open(attr_uptr: 0x36f0360, pid: 16134, cpu: -1, group_fd: -1) = -1 EINVAL Invalid argument
 9986.983 (0.014 ms): trace/6139 perf_event_open(attr_uptr: 0x7ffd9c629320, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 3
 9987.026 (0.016 ms): trace/6139 perf_event_open(attr_uptr: 0x37c7e70, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 3
 9987.041 (0.008 ms): trace/6139 perf_event_open(attr_uptr: 0x37c7e70, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 3
 9987.489 (0.092 ms): trace/6139 perf_event_open(attr_uptr: 0x3795ee0, pid: 16140, group_fd: -1, flags: FD_CLOEXEC) = 3
 9987.536 (0.044 ms): trace/6139 perf_event_open(attr_uptr: 0x3795ee0, pid: 16140, cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 4
 9987.580 (0.041 ms): trace/6139 perf_event_open(attr_uptr: 0x3795ee0, pid: 16140, cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 5
 9987.620 (0.037 ms): trace/6139 perf_event_open(attr_uptr: 0x3795ee0, pid: 16140, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 7
 9987.659 (0.035 ms): trace/6139 perf_event_open(attr_uptr: 0x37975d0, pid: 16140, group_fd: -1, flags: FD_CLOEXEC) = 8
 9987.692 (0.031 ms): trace/6139 perf_event_open(attr_uptr: 0x37975d0, pid: 16140, cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 9
 9987.727 (0.032 ms): trace/6139 perf_event_open(attr_uptr: 0x37975d0, pid: 16140, cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 10
 9987.761 (0.031 ms): trace/6139 perf_event_open(attr_uptr: 0x37975d0, pid: 16140, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 11

Need to intercept perf_copy_attr() with a kprobe or with eBPF...

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-njb105hab2i3t5dexym9lskl@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-11 22:47:54 -03:00
He Kuang
6ba29c2fa5 perf tools: Fix build failure on 32-bit arch
Failed in 32bit arch build like this:

    CC       /opt/h00206996/output/perf/arm32/builtin-record.o
  util/session.c: In function ‘perf_session__warn_about_errors’:
  util/session.c:1304:9: error: format ‘%lu’ expects argument of type ‘long unsigned int’,
                         but argument 2 has type ‘long long unsigned int’ [-Werror=format=]

  builtin-report.c: In function ‘perf_evlist__tty_browse_hists’:
  builtin-report.c:323:2: error: format ‘%lu’ expects argument of type ‘long unsigned int’,
                          but argument 3 has type ‘u64’ [-Werror=format=]

Replace %lu format strings in warning message with PRIu64 for u64
'total_lost_samples' to fix this problem.

Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1434026664-71642-1-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-11 11:14:21 -03:00
Kan Liang
cb5ef60067 perf stat: Error out unsupported group leader immediately
perf stat ignores the unsupported event and continue to count supported
event. But if the unsupported event is group leader, perf tool will
crash. After applying this patch, the unsupported group leader will
error out immediately.

Without this patch:

  $ perf stat -x, -e '{node-prefetch-refs,cycles}' --  sleep 1
  perf: util/evsel.c:1009: get_group_fd: Assertion `!(fd == -1)' failed.
  Aborted (core dumped)

With this patch:

  $ perf stat -x, -e '{node-prefetch-refs,cycles}' --  sleep 1
  Error:
  The node-prefetch-refs event is not supported.

Commiter note: Here I got a different output, but no core dump:

  [acme@zoo linux]$ perf stat -x, -e '{node-prefetch-refs,cycles}' -- sleep 1
  Error:
  The sys_perf_event_open() syscall returned with 22 (Invalid argument)
  for event (node-prefetch-refs).
  /bin/dmesg may provide additional information.
  No CONFIG_PERF_EVENTS=y kernel support configured?

Signed-off-by: Kan Liang <kan.liang@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Link: http://lkml.kernel.org/r/1434004360-8570-1-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-11 11:07:40 -03:00
Adrian Hunter
7310aed77e perf evsel: Display 0x for hex values when printing the attribute
Need to display '0x' prefix for hex values otherwise it is not obvious
they are hex.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1434027064-7554-1-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-11 10:56:01 -03:00
Peter Zijlstra
5610032135 perf record: Amend option summaries
Because there's too many options and I cannot read, I frequently get
confused between -c and -P, and try to do things like:

  perf record -P 50000 -- foo

Which does not work; try and make the option description slightly longer
and hopefully less confusing.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150610144850.GP19282@twins.programming.kicks-ass.net
[ Do those changes on the man page as well ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-10 12:00:27 -03:00
Milos Vyletel
d7c72606d9 perf tools: Avoid possible race condition in copyfile()
Use unique temporary files when copying to buildid dir to prevent races
in case multiple instances are trying to copy same file. This is done by

- creating template in form <path>/.<filename>.XXXXXX where the suffix is
  used by mkstemp() to create unique file
- change file mode
- copy content
- if successful link temp file to target file
- unlink temp file

At this point the only file left at target path should be the desired
one either created by us or other instance if we raced. This should also
prevent not yet fully copied files to be visible to to other perf
instances that could try to parse them.

On top of that slow_copyfile no longer needs to deal with file mode when
creating file since temporary file is already created and mode is set.

Succesfully tested by myself by running perf record, archive and reading
the data on other system and by running perf buildid-cache on perf
binary itself. I also did revert fix from 0635b0f that to exposes
previously fixed race with EEXIST and recreator test passed sucessfully.

Signed-off-by: Milos Vyletel <milos@redhat.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
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/1433775018-19868-1-git-send-email-milos@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-10 11:51:24 -03:00
Ingo Molnar
028c63b567 perf/core improvements and fixes:
User visible:
 
 - Fix perf.data size reporting in 'perf record' in no-buildid mode (He Kuang)
 
 Infrastructure:
 
 - Protect accesses the dso rbtrees/lists with a rw lock and reference
   count struct dso instances (Arnaldo Carvalho de Melo)
 
 - Export dynamic symbols used by traceevent plugins (He Kuang)
 
 - Add libtrace-dynamic-list file to libtraceevent's .gitignore (He Kuang)
 
 - Refactor shadow stats code in 'perf stat', prep work for further
   patchkits (Jiri Olsa)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJVdaJmAAoJENZQFvNTUqpAAykQAID43Ya872Hc6DJtN6w1Os5c
 xptBVfbYZiDNKLAyJzTj+oN8nUkmUGYD/xs/xflfUucvl9c4IqdMoiVFZy0aaWGc
 P5fNeWGnHWj83MPNJU2DxIBOk6rnnEHhCkPdEvoteKuewd4PYsKNiNPYaxUbTlvH
 vX9BGfjdeJx/1aom1gmvkkZFgbcjiSZJbwx00u4xcwVPD4PIKvdFLtqFODCVRvCd
 m9zWoWjg38rtUfhPNwJmebZWV9XRv/nO+XDABH3enG7rVqSOxW0zymkc7t2/B+SY
 hdzEkM+0Ag2Wpx2xWY+JjppVElvJJS/AGScjLuXqQKgb2ivZRvn6aKVP0jW6AT4e
 2mvdbyk6NTa2AE4U8GqRmU7D1wT202MXYpIl38Iv30WSQVuV3f92Jchj1rZyB2Ch
 H9xdG7S/UEb4RYWfGpPLHJjeK46c+TTnIj3QYS+PcIkbOfv5ZkhLkZNVaWeXEJb7
 CeeO3OTFdwcTxYerIY7KvuY5jrVkptazeBGrRQGzeP+giUG8ZZMT80HJ+5Cj0zlL
 bjPu9AaN/lN/+OLiJkBQIHbotN8g3p36R5IR0LWIBy+2P5IUVnDiHL1PNFPkPSce
 pDQtdpwwrd4+cI+ZYNvATtb4B6efyboCBBQwsFFg/CpwH7x+zcdsQSmOzMlsJA9s
 Pq1mFJt1V+aD+2olXjhj
 =7Kag
 -----END PGP SIGNATURE-----

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

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

User visible changes:

  - Fix perf.data size reporting in 'perf record' in no-buildid mode (He Kuang)

Infrastructure changes:

  - Protect accesses the DSO rbtrees/lists with a rw lock and reference
    count struct dso instances (Arnaldo Carvalho de Melo)

  - Export dynamic symbols used by traceevent plugins (He Kuang)

  - Add libtrace-dynamic-list file to libtraceevent's .gitignore (He Kuang)

  - Refactor shadow stats code in 'perf stat', prep work for further
    patchkits (Jiri Olsa)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-06-09 11:46:04 +02:00
Arnaldo Carvalho de Melo
d3a7c489c7 perf tools: Reference count struct dso
This has a different model than the 'thread' and 'map' struct lifetimes:
there is not a definitive "don't use this DSO anymore" event, i.e. we may
get many 'struct map' holding references to the '/usr/lib64/libc-2.20.so'
DSO but then at some point some DSO may have no references but we still
don't want to straight away release its resources, because "soon" we may
get a new 'struct map' that needs it and we want to reuse its symtab or
other resources.

So we need some way to garbage collect it when crossing some memory
usage threshold, which is left for anoter patch, for now it is
sufficient to release it when calling dsos__exit(), i.e. when deleting
the whole list as part of deleting the 'struct machine' containing it,
which will leave only referenced objects being used.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-majzgz07cm90t2tejrjy4clf@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-08 10:31:40 -03:00
Arnaldo Carvalho de Melo
e880784422 perf tools: Protect accesses the dso rbtrees/lists with a rw lock
To allow concurrent access, next step: refcount struct dso instances, so
that we can ditch unused them when the last map pointing to it goes
away.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-yk1k08etpd2aoe3tnrf0oizn@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-08 10:31:40 -03:00
Arnaldo Carvalho de Melo
9f2de31542 perf machine: Fix up some more method names
Calling the function 'machine__new_module' implies a new 'module' will
be allocated, when in fact what is returned is a 'struct map' instance,
that not necessarily will be instantiated, as if one already exists with
the given module name, it will be returned instead.

So be consistent with other "find and if not there, create" like
functions, like machine__findnew_thread, machine__findnew_dso, etc, and
rename it to machine__findnew_module_map(), that in turn will call
machine__findnew_module_dso().

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-acv830vd3hwww2ih5vjtbmu3@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-08 10:31:34 -03:00