aboutsummaryrefslogtreecommitdiffstats
path: root/tools (follow)
AgeCommit message (Collapse)AuthorFilesLines
2012-03-30perf tools: Remove auto-generated bison/flex filesIngo Molnar9-8476/+30
These should not be in the Git history - they are auto-generated. Extend the Makefile rules of the parser files to include the generation run. Signed-off-by: Ingo Molnar <mingo@elte.hu> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20120327183335.GA27621@gmail.com [ committer note: Fixed up O= handling ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-29perf annotate: Fix off by one symbol hist size allocation and hit accountingArnaldo Carvalho de Melo1-3/+3
We were not noticing it because symbol__inc_addr_samples was erroneously dropping samples that hit the last byte in a function. Working on a fix for a problem reported by David Miller, Stephane Eranian and Sorin Dumitru, where addresses < sym->start were causing problems, I noticed this other problem. Cc: David Ahern <dsahern@gmail.com> Cc: David Miller <davem@davemloft.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sorin Dumitru <dumitru.sorin87@gmail.com> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-pqjaq4cr1xs2xen73pjhbav4@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-29perf tools: Add missing ref-cycles event back to event parserNamhyung Kim1-0/+1
The commit 89812fc81f8d ("perf tools: Add parser generator for events parsing") changed event parsing engine but missed the ref-cycles event. Add it. Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1333016517-10591-1-git-send-email-namhyung.kim@lge.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-28perf annotate: addr2line wants addresses in same format as objdumpDavid Miller1-1/+1
Therefore, in symbol__get_source_line(), use map__rip_2objdump instead of calling map->unmap_ip() unconditionally. Link: http://lkml.kernel.org/r/20120325.162812.59519424882536855.davem@davemloft.net Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-28perf probe: Finder fails to resolve function name to addressPrashanth Nageshappa1-1/+3
If DIE entries corresponding to declarations appear before definition entry, probe finder returns error instead of continuing to look further for a definition entry. This patch ensures we reach to the DIE entry corresponding to the definition and get the function address. V2: A simpler solution based on Masami's suggestion. Signed-off-by: Prashanth Nageshappa <prashanth@linux.vnet.ibm.com> Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: Steven Rostedt <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/4F703FB9.9020407@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-27perf symbols: Handle NULL dso in dso__name_lenDavid Miller1-0/+2
We should use "[unknown]" in this case, in concert with the code in _hist_entry__dso_snprintf(). Otherwise we'll crash when recomputing the histogram column lengths in hists__calc_col_len(). Signed-off-by: David S. Miller <davem@davemloft.net> Link: http://lkml.kernel.org/r/20120325.162822.2267799792062571623.davem@davemloft.net Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-27perf symbols: Do not include libgen.hDavid Miller1-1/+0
That causes us to end up using the XPG version of basename which can modify it's argument. Signed-off-by: David S. Miller <davem@davemloft.net> Link: http://lkml.kernel.org/r/20120327.000301.1122788061724345175.davem@davemloft.net Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-26perf tools: Fix bug in raw sample parsingStephane Eranian1-0/+2
In perf_event__parse_sample(), the array variable was not incremented by the amount of data used by the raw_data. That was okay until we added PERF_SAMPLE_BRANCH_STACK which depends on the array variable pointing to the beginning of the branch stack data. But that was not the case if branch stack was combined with raw mode sampling. That led to bogus branch stack addresses and count. The bug would show up with: $ perf record -R -b foo This patch fixes the problem by correctly moving the array pointer forward for RAW samples. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20120317222317.GA8803@quad [ committer note: Fix also later submitted by Jiri Olsa ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-26perf tools: Fix display of first level of callchainsFrederic Weisbecker1-64/+93
The callchain stdio mode display was written using a sorted by symbol report. In this mode we have only one callchain root per hist so we forgot to handle cases where we have multiple callchain root, as in per dso sorting for example. Fix this by handling these roots like any other branch, with the hist as the parent. Before: 1.97% libpthread-2.12.1.so | --- __libc_write create_worker bench_sched_messaging cmd_bench run_builtin main __libc_start_main | --- __libc_read create_worker bench_sched_messaging cmd_bench run_builtin main __libc_start_main After: 1.97% libpthread-2.12.1.so | |--36.97%-- __libc_write | create_worker | bench_sched_messaging | cmd_bench | run_builtin | main | __libc_start_main | |--31.47%-- __libc_read | create_worker | bench_sched_messaging | cmd_bench | run_builtin | main | __libc_start_main ... Single roots keep their entry without percentage because they have the same overhead than the hist they refer to. ie: 100% in fractal mode and the percentage of the hist in graph mode: 0.00% [k] reschedule_interrupt | --- default_idle amd_e400_idle cpu_idle start_secondary Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1332526010-15400-1-git-send-email-fweisbec@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-22perf diff: Fix to work with new hists designJiri Olsa5-30/+43
The perf diff command is broken since: perf hists: Threaded addition and sorting of entries commit 1980c2ebd7020d82c024b8c4046849b38e78e7da Several places were broken: - hists data need to be collected into opened sessions instead of into events - session's hists data need to be initialized properly when the session is created - hist_entry__pcnt_snprintf: the percentage and displacement buffer preparation must not use 'ret' because it's used as a pointer to the final buffer Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20120322133726.GB1601@m.brq.redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-22perf tools: Fix modifier to be applied on correct eventsJiri Olsa6-337/+543
The event modifier needs to be applied only on the event definition it is attached to. The current state is that in case of multiple events definition (in single '-e' option, separated by ',') all will get modifier of the last one. Fixing this by adding separated list for each event definition, so the modifier is applied only to proper event(s). Added automated test to catch this, plus some other modifier tests. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1332267341-26338-3-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-22perf tools: Fix various casting issues for 32 bitsJiri Olsa2-2/+2
- util/parse-events.c(parse_events_add_breakpoint) need to use unsigned long instead of u64, otherwise we get following gcc error on 32 bits: error: cast from pointer to integer of different size - util/header.c(print_event_desc) cannot retype to signed type, otherwise we get following gcc error on 32 bits: error: comparison between signed and unsigned integer expressions Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1332267341-26338-2-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-22perf tools: Simplify event_read_id exit pathBorislav Petkov1-6/+4
We're freeing the token in any case so simplify the exit path by unifying it. No functional change. Signed-off-by: Borislav Petkov <bp@amd64.org> Link: http://lkml.kernel.org/r/1332339347-21342-1-git-send-email-bp@amd64.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-22Merge branch 'perf/urgent' into perf/coreArnaldo Carvalho de Melo14-34/+49
Merge Reason: to pick the fix: commit e7f01d1 perf tools: Use scnprintf where applicable Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-19perf report: Add a simple GTK2-based 'perf report' browserPekka Enberg8-4/+272
This patch adds a simple GTK2-based browser to 'perf report' that's based on the TTY-based browser in builtin-report.c. To launch "perf report" using the new GTK interface just type: $ perf report --gtk The interface is somewhat limited in features at the moment: - No callgraph support - No KVM guest profiling support - No color coding for percentages - No sorting from the UI - ..and many, many more! That said, I think this patch a reasonable start to build future features on. Signed-off-by: Pekka Enberg <penberg@kernel.org> Cc: Colin Walters <walters@verbum.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Ingo Molnar <mingo@kernel.org> Link: http://lkml.kernel.org/r/alpine.LFD.2.02.1202231952410.6689@tux.localdomain [ committer note: Added #pragma to make gtk no strict prototype problem go away as suggested by Colin Walters modulo avoiding push/pop ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-19perf report: Document --symbol-filter optionNamhyung Kim1-0/+3
Add missing description of --symbol-filter in Documentation/perf-report.txt. Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1332125628-23088-1-git-send-email-namhyung.kim@lge.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-19perf ui browser: Clean lines inside of the input windowNamhyung Kim1-3/+7
As Arnaldo pointed out, it should be cleared to prevent the window from displaying overlapped strings on the region. Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1332125180-23041-1-git-send-email-namhyung.kim@lge.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-16perf report: Treat an argument as a symbol filterNamhyung Kim1-5/+10
As Ingo requested, it'd be better off treating first (and the only) argument as a symbol filter, so that user doesn't need to input the symbol on the dialog window on TUI. Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1331887855-874-5-git-send-email-namhyung.kim@lge.com Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-16perf report: Add --symbol-filter optionNamhyung Kim1-0/+6
Add new --symbol-filter command line option to set appropriate filter string. Its short version is missing as I couldn't find an ideal one and --filter option of perf record also has no short version. Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1331887855-874-4-git-send-email-namhyung.kim@lge.com Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-16perf ui browser: Add 's' key to filter by symbol nameNamhyung Kim1-1/+13
Now user can enter symbol name interested via ui_browser__input_window, and perf can process it using hists__filter_by_symbol(). Giving empty symbol (by pressing 's' followed by ENTER) will disable the filtering. Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1331887855-874-3-git-send-email-namhyung.kim@lge.com Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-16perf ui browser: Introduce ui_browser__input_windowNamhyung Kim3-0/+82
The ui_browser__input_window() function is to get user's key input. Current implementation can handle maximum 49 characters. Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1331887855-874-2-git-send-email-namhyung.kim@lge.com Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-16perf hists: Add hists__filter_by_symbolNamhyung Kim2-0/+37
This function will be used for simple (sub-)string matching filter based on user input. Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1331887855-874-1-git-send-email-namhyung.kim@lge.com Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-16perf tools: Do not disable members of group eventNamhyung Kim3-5/+10
When event group is enabled for forked task (i.e. no target task/cpu was specified) all events were disabled and marked ->enable_on_exec. However they wouldn't be counted at all since only group leader will be enabled on exec actually. In contrast to perf stat, perf record doesn't have a real problem as it enables all the event before proceeding. But it needs to be fixed anyway IMHO. Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1331887340-32448-2-git-send-email-namhyung.kim@lge.com Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-16perf stat: Fix event grouping on forked taskNamhyung Kim1-1/+1
When event group is enabled for forked task (i.e. no target task was specified) all events were disabled and marked ->enable_on_exec. However they are not counted at all since only group leader will be enabled on exec actually. So the result looked like below: $ ./perf stat --group -- sleep 1 Performance counter stats for 'sleep 1': 0.554926 task-clock # 0.001 CPUs utilized <not counted> context-switches <not counted> CPU-migrations <not counted> page-faults <not counted> cycles <not supported> stalled-cycles-frontend <not supported> stalled-cycles-backend <not counted> instructions <not counted> branches <not counted> branch-misses 1.001228093 seconds time elapsed Fix it by disabling group leader only. Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1331887340-32448-1-git-send-email-namhyung.kim@lge.com Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-16perf tools: Add support to specify pmu style eventJiri Olsa5-100/+172
Added new event rule to the event definition grammar: event_def: event_pmu | ... event_pmu: PE_NAME '/' event_config '/' Using this rule, event could be now specified like: cpu/config=1,config1=2,config2=3/u where pmu name 'cpu' is looked up via following path: ${sysfs_mount}/bus/event_source/devices/${pmu} and config options are bound to the pmu's format definiton: ${sysfs_mount}/bus/event_source/devices/${pmu}/format The hardcoded config options still stays and have precedence over any format field defined with same name. Acked-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-50d8nr94f8k4wkezutrxvthe@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-16perf tools: Add perf pmu object to access pmu format definitionJiri Olsa10-0/+4541
Adding pmu object which provides interface to pmu's sysfs event format definition located at: ${sysfs_mount}/bus/event_source/devices/${pmu}/format Following interface is exported: struct perf_pmu* perf_pmu__find(char *name); - this function returns pmu object, which is then passed as a handle to other interface functions int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr, struct list_head *head_terms); - this function configures perf_event_attr struct based on pmu's format definitions and config terms data, containined in head_terms list. Parser generator is used to retrive the pmu's format definition. The generated parser is part of the patch. Added makefile rule 'pmu-parser' to generate the parser code out of the bison/flex sources. Added builtin test 'Test perf pmu format parsing', which could be run like: perf test pmu Acked-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-errz96u1668gj9wlop1zhpht@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-16perf tools: Add config options support for event parsingJiri Olsa9-447/+866
Adding a new rule to the event grammar to be able to specify values of additional attributes of symbolic event. The new syntax for event symbolic definition is: event_legacy_symbol: PE_NAME_SYM '/' event_config '/' | PE_NAME_SYM sep_slash_dc event_config: event_config ',' event_term | event_term event_term: PE_NAME '=' PE_NAME | PE_NAME '=' PE_VALUE PE_NAME sep_slash_dc: '/' | ':' | At the moment the config options are hardcoded to be used for legacy symbol events to define several perf_event_attr fields. It is: 'config' to define perf_event_attr::config 'config1' to define perf_event_attr::config1 'config2' to define perf_event_attr::config2 'period' to define perf_event_attr::sample_period Legacy events could be now specified as: cycles/period=100000/ If term is specified without the value assignment, then 1 is assigned by default. Acked-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-mgkavww9790jbt2jdkooyv4q@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-16perf tools: Add parser generator for events parsingJiri Olsa10-341/+4752
Changing event parsing to use flex/bison parse generator. The event syntax stays as it was. grammar description: events: events ',' event | event event: event_def PE_MODIFIER_EVENT | event_def event_def: event_legacy_symbol sep_dc | event_legacy_cache sep_dc | event_legacy_breakpoint sep_dc | event_legacy_tracepoint sep_dc | event_legacy_numeric sep_dc | event_legacy_raw sep_dc event_legacy_symbol: PE_NAME_SYM event_legacy_cache: PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT | PE_NAME_CACHE_TYPE event_legacy_raw: PE_SEP_RAW PE_VALUE event_legacy_numeric: PE_VALUE ':' PE_VALUE event_legacy_breakpoint: PE_SEP_BP ':' PE_VALUE ':' PE_MODIFIER_BP event_breakpoint_type: PE_MODIFIER_BPTYPE | empty PE_NAME_SYM: cpu-cycles|cycles | stalled-cycles-frontend|idle-cycles-frontend | stalled-cycles-backend|idle-cycles-backend | instructions | cache-references | cache-misses | branch-instructions|branches | branch-misses | bus-cycles | cpu-clock | task-clock | page-faults|faults | minor-faults | major-faults | context-switches|cs | cpu-migrations|migrations | alignment-faults | emulation-faults PE_NAME_CACHE_TYPE: L1-dcache|l1-d|l1d|L1-data | L1-icache|l1-i|l1i|L1-instruction | LLC|L2 | dTLB|d-tlb|Data-TLB | iTLB|i-tlb|Instruction-TLB | branch|branches|bpu|btb|bpc | node PE_NAME_CACHE_OP_RESULT: load|loads|read | store|stores|write | prefetch|prefetches | speculative-read|speculative-load | refs|Reference|ops|access | misses|miss PE_MODIFIER_EVENT: [ukhp]{0,5} PE_MODIFIER_BP: [rwx] PE_SEP_BP: 'mem' PE_SEP_RAW: 'r' sep_dc: ':' | Added flex/bison files for event grammar parsing. The generated parser is part of the patch. Added makefile rule 'event-parser' to generate the parser code out of the bison/flex sources. Acked-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-u4pfig5waq3ll2bfcdex8fgi@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-15perf tools: Adjust make rulesJan Beulich1-1/+5
Add rules to generate pre-processed files (just like are available for the normal kernel build), and adjust the rule to create assembly files from C ones to produce its output in the output directory rather than in the source tree. E.g. $ make -C tools/perf/ O=/tmp/perf /tmp/perf/builtin-top.i make: Entering directory `/home/git/linux/tools/perf' CC /tmp/perf/builtin-top.i make: Leaving directory `/home/git/linux/tools/perf' $ wc -l /tmp/perf/builtin-top.i 31379 /tmp/perf/builtin-top.i $ Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/4F588A0802000078000770FF@nat28.tlf.novell.com Signed-off-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-14perf tools, x86: Build perf on older user-space as wellIngo Molnar4-0/+10
On ancient systems I get this build failure: util/../../../arch/x86/include/asm/unistd.h:67:29: error: asm/unistd_64.h: No such file or directory In file included from util/cache.h:7, from builtin-test.c:8: util/../perf.h: In function ‘sys_perf_event_open’:In file included from util/../perf.h:16 perf.h:170: error: ‘__NR_perf_event_open’ undeclared (first use in this function) The reason is that this old system does not have the split unistd.h headers yet, from which to pick up the syscall definitions. Add the syscall numbers to the already existing i386 and x86_64 blocks in perf.h, and also provide empty include file stubs. With this patch perf builds and works fine on 5 years old user-space as well. Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Link: http://lkml.kernel.org/n/tip-jctwg64le1w47tuaoeyftsg9@git.kernel.org Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-14perf tools: Use scnprintf where applicableArnaldo Carvalho de Melo8-33/+35
Several places were expecting that the value returned was the number of characters printed, not what would be printed if there was space. Fix it by using the scnprintf and vscnprintf variants we inherited from the kernel sources. Some corner cases where the number of printed characters were not accounted were fixed too. Reported-by: Anton Blanchard <anton@samba.org> Cc: Anton Blanchard <anton@samba.org> Cc: Eric B Munson <emunson@mgebm.net> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Yanmin Zhang <yanmin_zhang@linux.intel.com> Cc: stable@kernel.org Link: http://lkml.kernel.org/n/tip-kwxo2eh29cxmd8ilixi2005x@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-14perf tools: Incorrect use of snprintf results in SEGVAnton Blanchard1-0/+3
I have a workload where perf top scribbles over the stack and we SEGV. What makes it interesting is that an snprintf is causing this. The workload is a c++ gem that has method names over 3000 characters long, but snprintf is designed to avoid overrunning buffers. So what went wrong? The problem is we assume snprintf returns the number of characters written: ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", self->level); ... ret += repsep_snprintf(bf + ret, size - ret, "%s", self->ms.sym->name); Unfortunately this is not how snprintf works. snprintf returns the number of characters that would have been written if there was enough space. In the above case, if the first snprintf returns a value larger than size, we pass a negative size into the second snprintf and happily scribble over the stack. If you have 3000 character c++ methods thats a lot of stack to trample. This patch fixes repsep_snprintf by clamping the value at size - 1 which is the maximum snprintf can write before adding the NULL terminator. I get the sinking feeling that there are a lot of other uses of snprintf that have this same bug, we should audit them all. Cc: David Ahern <dsahern@gmail.com> Cc: Eric B Munson <emunson@mgebm.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Yanmin Zhang <yanmin_zhang@linux.intel.com> Cc: stable@kernel.org Link: http://lkml.kernel.org/r/20120307114249.44275ca3@kryten Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-13perf record: Fix buffer overrun bug in tracepoint_id_to_path()Stephane Eranian1-1/+1
This patch fixes a buffer overrun bug in tracepoint_id_to_path(). The bug manisfested itself as a memory error reported by perf record. I ran into it with perf sched: $ perf sched rec noploop 2 noploop for 2 seconds [ perf record: Woken up 14 times to write data ] [ perf record: Captured and wrote 42.701 MB perf.data (~1865622 samples) ] Fatal: No memory to alloc tracepoints list It turned out that tracepoint_id_to_path() was reading the tracepoint id using read() but the buffer was not large enough to include the \n terminator for id with 4 digits or more. The patch fixes the problem by extending the buffer to a more reasonable size covering all possible id length include \n terminator. Note that atoll() stops at the first non digit character, thus it is not necessary to clear the buffer between each read. Signed-off-by: Stephane Eranian <eranian@google.com> Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: fweisbec@gmail.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/20120313155102.GA6465@quad Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-12Merge branch 'perf/hw-branch-sampling' into perf/coreIngo Molnar17-166/+1023
Merge reason: The 'perf record -b' hardware branch sampling feature is ready for upstream. Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-12perf report: Fix annotate double quit issue in branch view modeStephane Eranian1-7/+31
This patch fixes perf report to not go back two levels when pressing the 'q' key while annotating in branch view mode. When pressing 'q' in annotate mode and if the branch source and target belong to different functions, perf now brings up the annotation popup menu again to offer the option to annotate the other branch source or target. As part of the code restructuring in perf_evsel__hists_browse() we also fix a memory leak on options[] in case of error. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1331565210-10865-3-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-12perf report: Remove duplicate annotate choice in branch view modeStephane Eranian1-0/+2
This patch removes the duplicated annotate selection when browsing in branch view mode. If the sym and dso oof the branch source and target are the same, then only one annotate choice is proposed. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1331565210-10865-2-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-12Merge branch 'perf/urgent' into perf/coreIngo Molnar1-3/+5
Merge reason: We are going to queue up a dependent patch. Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-09perf report: Enable TUI in branch view modeStephane Eranian5-38/+111
This patch updates perf report to support TUI mode when the perf.data file contains samples with branch stacks. For each row in the report, it is possible to annotate either the source or target of each branch. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1331246868-19905-5-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-09perf report: Auto-detect branch stack sampling modeStephane Eranian4-20/+41
This patch enhances perf report to auto-detect when the perf.data file contains samples with branch stacks. That way it is not necessary to use the -b option. To force branch view mode to off, simply use --no-branch-stack. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1331246868-19905-4-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-09perf record: Add HEADER_BRANCH_STACK tagStephane Eranian3-1/+17
This patch adds a new feature bit, namely, HEADER_BRANCH_STACK. When present, it indicates that sample records may contain branch stack. This could be useful to a viewer to switch to branch mode without having to parse all the samples or without a specific cmdline option. This will be used in a subsequent patch to enhance perf report with branch stacks. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1331246868-19905-3-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-09perf record: Provide default branch stack sampling mode optionStephane Eranian2-34/+57
This patch chanegs the logic of the -b, --branch-stack options of perf record. Based on users' request, the patch provides a default filter mode with the -b (or --branch-any) option. With the option, any type of taken branches is sampled. With -j (or --branch-filter), the user can specify any valid combination of branch types and privilege levels if supported by the underlying hardware. The -b (--branch any) is a shortcut for: --branch-filter any. $ perf record -b foo or: $ perf record --branch-filter any foo For more specific filtering: $ perf record --branch-filter ind_call,u foo Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1331246868-19905-2-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-09perf tools: Make perf able to read files from older ABIsStephane Eranian1-28/+94
This patches provides a way to handle legacy perf.data files. Legacy files are those using the older PERFFILE signature. For those, it is still necessary to detect endianness but without comparing their header->attr_size with the tool's own version as it may be different. Instead, we use a reference table for all known sizes from the legacy era. We try all the combinations for sizes and endianness. If we find a match, we proceed, otherwise we return: "incompatible file format". This is also done for the pipe-mode file format. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: robert.richter@amd.com Cc: ming.m.lin@intel.com Cc: andi@firstfloor.org Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1328826068-11713-19-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-09perf tools: Fix ABI compatibility bug in print_event_desc()Stephane Eranian1-10/+9
This patches cleans up local variable types for msz and ret. They need to be size_t and ssize_t respectively. It also fixes a bug whereby perf would not read attr struct with a different size than what it knows about. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: robert.richter@amd.com Cc: ming.m.lin@intel.com Cc: andi@firstfloor.org Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1328826068-11713-18-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-09perf tools: Enable reading of perf.data files from different ABI revStephane Eranian2-7/+50
This patch allows perf to process perf.data files generated using an ABI that has a different perf_event_attr struct size, i.e., a different ABI version. The perf_event_attr can be extended, yet perf needs to cope with older perf.data files. Similarly, perf must be able to cope with a perf.data file which is using a newer version of the ABI than what it knows about. This patch adds read_attr(), a routine that reads a perf_event_attr struct from a file incrementally based on its advertised size. If the on-file struct is smaller than what perf knows, then the extra fields are zeroed. If the on-file struct is bigger, then perf only uses what it knows about, the rest is skipped. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: robert.richter@amd.com Cc: ming.m.lin@intel.com Cc: andi@firstfloor.org Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1328826068-11713-17-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-09perf report: Add support for taken branch samplingRoberto Agostino Vitillo2-9/+105
This patch adds support for taken branch sampling, i.e, the PERF_SAMPLE_BRANCH_STACK feature to perf report. In other words, to display histograms based on taken branches rather than executed instructions addresses. The new option is called -b and it takes no argument. To generate meaningful output, the perf.data must have been obtained using perf record -b xxx ... where xxx is a branch filter option. The output shows symbols, modules, sorted by 'who branches where' the most often. The percentages reported in the first column refer to the total number of branches captured and not the usual number of samples. Here is a quick example. Here branchy is simple test program which looks as follows: void f2(void) {} void f3(void) {} void f1(unsigned long n) { if (n & 1UL) f2(); else f3(); } int main(void) { unsigned long i; for (i=0; i < N; i++) f1(i); return 0; } Here is the output captured on Nehalem, if we are only interested in user level function calls. $ perf record -b any_call,u -e cycles:u branchy $ perf report -b --sort=symbol 52.34% [.] main [.] f1 24.04% [.] f1 [.] f3 23.60% [.] f1 [.] f2 0.01% [k] _IO_new_file_xsputn [k] _IO_file_overflow 0.01% [k] _IO_vfprintf_internal [k] _IO_new_file_xsputn 0.01% [k] _IO_vfprintf_internal [k] strchrnul 0.01% [k] __printf [k] _IO_vfprintf_internal 0.01% [k] main [k] __printf About half (52%) of the call branches captured are from main() -> f1(). The second half (24%+23%) is split in two equal shares between f1() -> f2(), f1() ->f3(). The output is as expected given the code. It should be noted, that using -b in perf record does not eliminate information in the perf.data file. Consequently, a typical profile can also be obtained by perf report by simply not using its -b option. It is possible to sort on branch related columns: - dso_from, symbol_from - dso_to, symbol_to - mispredict Signed-off-by: Roberto Agostino Vitillo <ravitillo@lbl.gov> Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: robert.richter@amd.com Cc: ming.m.lin@intel.com Cc: andi@firstfloor.org Cc: asharma@fb.com Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1328826068-11713-14-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-09perf record: Add support for sampling taken branchRoberto Agostino Vitillo4-0/+104
This patch adds a new option to enable taken branch stack sampling, i.e., leverage the PERF_SAMPLE_BRANCH_STACK feature of perf_events. There is a new option to active this mode: -b. It is possible to pass a set of filters to select the type of branches to sample. The following filters are available: - any : any type of branches - any_call : any function call or system call - any_ret : any function return or system call return - any_ind : any indirect branch - u: only when the branch target is at the user level - k: only when the branch target is in the kernel - hv: only when the branch target is in the hypervisor Filters can be combined by passing a comma separated list to the option: $ perf record -b any_call,u -e cycles:u branchy Signed-off-by: Roberto Agostino Vitillo <ravitillo@lbl.gov> Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: robert.richter@amd.com Cc: ming.m.lin@intel.com Cc: andi@firstfloor.org Cc: asharma@fb.com Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1328826068-11713-13-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-09perf tools: Add code to support PERF_SAMPLE_BRANCH_STACKRoberto Agostino Vitillo10-78/+468
This patch adds: - ability to parse samples with PERF_SAMPLE_BRANCH_STACK - sort on branches (dso_from, symbol_from, dso_to, symbol_to, mispredict) - build histograms on branches Signed-off-by: Roberto Agostino Vitillo <ravitillo@lbl.gov> Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: robert.richter@amd.com Cc: ming.m.lin@intel.com Cc: andi@firstfloor.org Cc: asharma@fb.com Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1328826068-11713-12-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
2012-03-05Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tipLinus Torvalds5-18/+42
Pull perf fixes from Ingo Molnar: "It contains three cherry-picked fixes from perf/core, which turned out to be more urgent than we originally thought." * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf tools: Handle kernels that don't support attr.exclude_{guest,host} perf tools: Change perf_guest default back to false perf record: No build id option fails
2012-03-05perf annotate: Add missing newline on error messageNamhyung Kim1-1/+1
If perf.data couldn't find vmlinux image for the given build-id, it would print error message. However it lacked a newline at the end, so the output looked like below: $ perf annotate --stdio No vmlinux file with build id 63b554b2e90f14a4bced200008865e757d3e8b36 was found in the path. Please use: perf buildid-cache -av vmlinux or: --vmlinux vmlinux Percent | Source code & Disassembly of a.out ------------------------------------------------ : : : : Disassembly of section .text: : : 00000000004004f4 <foo>: 0.00 : 4004f4: push %rbp 0.00 : 4004f5: mov %rsp,%rbp 0.00 : 4004f8: movl $0x0,-0x4(%rbp) 0.00 : 4004ff: jmp 400517 <foo+0x23> 14.70 : 400501: mov 0x200b28(%rip),%rax # 601030 <count> 0.02 : 400508: add $0x1,%rax 0.01 : 40050c: mov %rax,0x200b1d(%rip) # 601030 <count> 0.01 : 400513: addl $0x1,-0x4(%rbp) 13.92 : 400517: cmpl $0x98967f,-0x4(%rbp) 71.33 : 40051e: jle 400501 <foo+0xd> 0.00 : 400520: leaveq 0.00 : 400521: retq Fix it by adding a newline at the end of the message. It doesn't affect the tui output AFAICS. New output will look like this: ... or: --vmlinux vmlinux Percent | Source code & Disassembly of a.out ------------------------------------------------ : : : : Disassembly of section .text: ... Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1329986784-4916-6-git-send-email-namhyung.kim@lge.com Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-03-05perf annotate: Fix help string on tuiNamhyung Kim1-3/+3
Separate multiple binding using /, capitalize descriptions, add missing key binding. Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1329986784-4916-5-git-send-email-namhyung.kim@lge.com Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>