perf/core improvements and fixes
Subsystems (4)
Arnaldo Carvalho de Melo
maintainerHi Ingo,
Please consider pulling, more to come, bpf, make build-test and
hopefully Stephane's JIT stuff, etc.
Best Regards,
- Arnaldo
The following changes since commit 9cc2617de5b9222abb39cd02e90d57dfea99c6d7:
perf/x86/amd: Remove l1-dcache-stores event for AMD (2016-01-06 11:15:39 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo
for you to fetch changes up to 775d8a1b0d75211cc6123915c6b5b688f2002478:
perf evlist: Add --trace-fields option to show trace fields (2016-01-08 14:23:02 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
New features:
- Allow using trace events fields as sort order keys, making 'perf evlist --trace_fields' show those, and then the user can select a subset and use like:
perf top -e sched:sched_switch -s prev_comm,next_comm
That works as well in 'perf report' when handling files containing tracepoints.
The default when just tracepoint events are found in a perf.data file is to format it like ftrace, using the libtraceevent formatters, plugins, etc (Namhyung Kim)
- Add support in 'perf script' to process 'perf stat record' generated files, culminating in a python perf script that calculates CPI (Cycles per Instruction) (Jiri Olsa)
- Show random perf tool tips in the 'perf report' bottom line (Namhyung Kim)
- perf report now defaults to --group if the perf.data file has grouped events, try it with:
# perf record -e '{cycles,instructions}' -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.093 MB perf.data (1247 samples) ]
# perf report
# Samples: 1K of event 'anon group { cycles, instructions }'
# Event count (approx.): 1955219195
#
# Overhead Command Shared Object Symbol 2.86% 0.22% swapper [kernel.kallsyms] [k] intel_idle
1.05% 0.33% firefox libxul.so [.] js::SetObjectElement
1.05% 0.00% kworker/0:3 [kernel.kallsyms] [k] gen6_ring_get_seqno
0.88% 0.17% chrome chrome [.] 0x0000000000ee27ab
0.65% 0.86% firefox libxul.so [.] js::ValueToId<(js::AllowGC)1>
0.64% 0.23% JS Helper libxul.so [.] js::SplayTree<js::jit::LiveRange*, js::jit::LiveRange>::splay
0.62% 1.27% firefox libxul.so [.] js::GetIterator
0.61% 1.74% firefox libxul.so [.] js::NativeSetProperty
0.61% 0.31% firefox libxul.so [.] js::SetPropertyByDefiningUser visible fixes:
- Coect data mmaps so that the DWARF unwinder can handle usecases needing them, like softice (Jiri Olsa)
- Decay callchains in fractal mode, fixing up cases where 'perf top -g' would show entries with more than 100% (Namhyung Kim)
Infrastructure:
- Sync tools/lib with the lib/ in the kernel sources for find_bit.c and move bitmap.[ch] from tools/perf/util/ to tools/lib/ (Arnaldo Carvalho de Melo)
- No need to set attr.sample_freq in some 'perf test' entries that only want to deal with PERF_RECORD_ meta-events, improve a bit error output for CQM test (Arnaldo Carvalho de Melo)
- Fix python binding build, adding some missing object files now required due to cpumap using find_bit stuff (Arnaldo Carvalho de Melo)
- tools/build improvemnts (Jiri Olsa)
- Add more files to cscope/ctags databases (Jiri Olsa)
- Do not show 'trace' in 'perf help' if it is not compiled in (Jiri Olsa)
- Make perf_evlist__open() open evsels with their cpus and threads, like perf record does, making them consistent (Adrian Hunter)
- Fix pmu snapshot initialization bug (Stephane Eranian)
- Add missing headers in perf's MANIFEST (Wang Nan)
----------------------------------------------------------------
Adrian Hunter (1):
perf evlist: Make perf_evlist__open() open evsels with their cpus and threads (like perf record does)
Arnaldo Carvalho de Melo (10):
perf tests: No need to set attr.sample_freq in the perf time to TSC test perf evlist: Introduce perf_evlist__new_dummy constructor
perf test: Use "dummy" events in the PERF_RECORD_ test
perf test: No need for setting attr.sample_freq on the RECORD test perf python: Add missing files to binding link list
perf tests: No need to set attr.sample_freq for tracking !PERF_RECORD_SAMPLE perf tests: Give a bit more information on the CQM test failure path tools lib: Move find_next_bit.c to tools/lib/
tools lib: Sync tools/lib/find_bit.c with the kernel
tools lib: Move bitmap.[ch] from tools/perf/ to tools/{lib,include}/
Jiri Olsa (25):
tools build feature: Fix feature_check_display_code typo tools build feature: Move dwarf post unwind choice output into perf tools build feature: Introduce feature_assign macro
tools build feature: Use value assignment form for FEATURE-DUMP file perf build: Use FEATURE-DUMP in bpf subproject
perf stat record: Keep sample_type 0 for pipe session
perf script: Process cpu/threads maps
perf script: Process stat config event
perf script: Add process_stat/process_stat_interval scripting interface perf script: Add stat default handlers
perf script: Add python support for stat events
perf cpumap: Fix cpu conversion in cpu_map__from_entries perf script: Display stat events by default
perf script: Add stat-cpi.py script
perf tools: Do not show trace command if it's not compiled in perf script: Align event name properly
perf tools: Include all tools/lib directory for tags/cscope/TAGS targets perf tools: Remove list entry from struct sort_entry
perf tools: Add overhead/overhead_children keys defaults via string perf diff: Use perf_hpp__register_sort_field interface
perf evlist: Remove perf_evlist__(enable|disable)_event functions perf unwind: Use find_map function in access_dso_mem
perf unwind: Check for mmaps also in MAP__VARIABLE tree perf libdw: Check for mmaps also in MAP__VARIABLE tree
perf record: Store data mmaps for dwarf unwind
Namhyung Kim (21):
perf hist: Pass struct sample to __hists__add_entry()
perf hist: Save raw_data/size for tracepoint events
tools lib traceevent: Factor out and export print_event_field[s]() perf top: Create the evlist sooner
perf tools: Pass evlist to setup_sorting()
perf tools: Add dynamic sort key for tracepoint events
perf tools: Try to show pretty printed output for dynamic sort keys perf tools: Add 'trace' sort key
perf report/top: Add --raw-trace option
perf tools: Support shortcuts for events in dynamic sort keys
perf tools: Support '<event>.*' dynamic sort key
perf tools: Skip dynamic fields not defined for current event
perf tools: Add 'trace_fields' dynamic sort key
perf tools: Make 'trace' or 'trace_fields' sort key default for tracepoint events perf tools: Add all matching dynamic sort keys for field name
perf report: Add documentation for dynamic sort keys
perf top: Decay periods in callchains
perf report: Change default to use event group view
perf hists: Export a couple of hist functions
perf report: Show random usage tip on the help line
perf evlist: Add --trace-fields option to show trace fields
Stephane Eranian (1):
perf pmu: fix alias->snapshot missing initialization bug
Wang Nan (1):
perf tools: Add missing headers in perf's MANIFEST
tools/build/Makefile.feature | 41 +-
tools/{perf/util => }/include/linux/bitmap.h | 2 +
tools/{perf/util => lib}/bitmap.c | 0
tools/lib/bpf/Makefile | 4 +
tools/lib/find_bit.c | 84 +++
tools/lib/traceevent/event-parse.c | 129 ++---
tools/lib/traceevent/event-parse.h | 4 +
tools/lib/util/find_next_bit.c | 89 ---
tools/perf/Build | 1 +
tools/perf/Documentation/perf-evlist.txt | 3 +
tools/perf/Documentation/perf-report.txt | 27 +
tools/perf/Documentation/perf-top.txt | 3 +
tools/perf/Documentation/tips.txt | 14 +
tools/perf/MANIFEST | 4 +-
tools/perf/Makefile.perf | 7 +-
tools/perf/arch/x86/tests/intel-cqm.c | 2 +-
tools/perf/arch/x86/tests/perf-time-to-tsc.c | 1 -
tools/perf/arch/x86/util/intel-bts.c | 4 +-
tools/perf/arch/x86/util/intel-pt.c | 4 +-
tools/perf/builtin-annotate.c | 9 +-
tools/perf/builtin-diff.c | 15 +-
tools/perf/builtin-evlist.c | 11 +-
tools/perf/builtin-record.c | 6 +-
tools/perf/builtin-report.c | 6 +-
tools/perf/builtin-script.c | 170 +++++-
tools/perf/builtin-stat.c | 9 +-
tools/perf/builtin-top.c | 16 +-
tools/perf/command-list.txt | 2 +-
tools/perf/config/Makefile | 10 +
tools/perf/perf.c | 4 +
tools/perf/scripts/python/stat-cpi.py | 77 +++
tools/perf/tests/hists_cumulate.c | 8 +-
tools/perf/tests/hists_filter.c | 2 +-
tools/perf/tests/hists_link.c | 8 +-
tools/perf/tests/hists_output.c | 10 +-
tools/perf/tests/keep-tracking.c | 3 +-
tools/perf/tests/perf-record.c | 6 +-
tools/perf/tests/switch-tracking.c | 6 +-
tools/perf/ui/browsers/hists.c | 7 +-
tools/perf/ui/gtk/hists.c | 4 +-
tools/perf/ui/hist.c | 14 +-
tools/perf/ui/stdio/hist.c | 6 +-
tools/perf/util/Build | 11 +-
tools/perf/util/callchain.c | 28 +
tools/perf/util/callchain.h | 1 +
tools/perf/util/cpumap.c | 13 +-
tools/perf/util/evlist.c | 72 +--
tools/perf/util/evlist.h | 7 +-
tools/perf/util/evsel.c | 23 +
tools/perf/util/evsel.h | 1 +
tools/perf/util/generate-cmdlist.sh | 15 +
tools/perf/util/hist.c | 78 ++-
tools/perf/util/hist.h | 24 +-
tools/perf/util/pmu.c | 1 +
tools/perf/util/python-ext-sources | 2 +
.../util/scripting-engines/trace-event-python.c | 115 +++-
tools/perf/util/sort.c | 601 ++++++++++++++++++++-
tools/perf/util/sort.h | 12 +-
tools/perf/util/symbol.c | 1 +
tools/perf/util/symbol.h | 3 +-
tools/perf/util/trace-event.h | 4 +
tools/perf/util/unwind-libdw.c | 10 +
tools/perf/util/unwind-libunwind.c | 20 +-
tools/perf/util/util.c | 27 +
tools/perf/util/util.h | 2 +
65 files changed, 1556 insertions(+), 347 deletions(-)
rename tools/{perf/util => }/include/linux/bitmap.h (95%)
rename tools/{perf/util => lib}/bitmap.c (100%)
create mode 100644 tools/lib/find_bit.c
delete mode 100644 tools/lib/util/find_next_bit.c
create mode 100644 tools/perf/Documentation/tips.txt
create mode 100644 tools/perf/scripts/python/stat-cpi.pyArnaldo Carvalho de Melo
maintainerPATCH 1/59 perf hist: Pass struct sample to __hists__add_entry()
From: Namhyung Kim <[email protected]>
This is a preparation to add more info into the hist_entry. Also it already passes too many argument, so passing sample directly will reduce the overhead of the function call.
--- tools/perf/builtin-annotate.c | 7 +++++-- tools/perf/builtin-diff.c | 11 +++++------ tools/perf/tests/hists_link.c | 6 +++--- tools/perf/util/hist.c | 31 +++++++++++++++++-------------- tools/perf/util/hist.h | 4 ++-- 5 files changed, 32 insertions(+), 27 deletions(-)
tools/perf/builtin-annotate.c +5 -2
@@ -47,7 +47,7 @@ struct perf_annotate { };static int perf_evsel__add_sample (struct perf_evsel *evsel, -struct perf_sample *sample__maybe_unused , +struct perf_sample *sample,struct addr_location *al,struct perf_annotate *ann) {
@@ -72,7 +72,10 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,return 0 ; } - he =__hists__add_entry (hists, al,NULL ,NULL ,NULL ,1 ,1 ,0 , true); + sample->period =1 ; + sample->weight =1 ; + + he =__hists__add_entry (hists, al,NULL ,NULL ,NULL , sample, true);if (he ==NULL )return -ENOMEM ;
tools/perf/builtin-diff.c +5 -6
@@ -311,11 +311,11 @@ static int formula_fprintf(struct hist_entry *he, struct hist_entry *pair, }static int hists__add_entry (struct hists *hists, -struct addr_location *al,u64 period, -u64 weight,u64 transaction) +struct addr_location *al, +struct perf_sample *sample) { -if (__hists__add_entry (hists, al,NULL ,NULL ,NULL , period, weight, - transaction, true) !=NULL ) +if (__hists__add_entry (hists, al,NULL ,NULL ,NULL , + sample, true) !=NULL )return 0 ;return -ENOMEM ; }
@@ -336,8 +336,7 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,return -1 ; } -if (hists__add_entry (hists, &al, sample->period, - sample->weight, sample->transaction)) { +if (hists__add_entry (hists, &al, sample)) {pr_warning ("problem incrementing symbol period, skipping event\n" ); goto out_put; }
tools/perf/tests/hists_link.c +3 -3
@@ -64,7 +64,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)struct perf_evsel *evsel;struct addr_location al;struct hist_entry *he; -struct perf_sample sample = { .period =1 , }; +struct perf_sample sample = { .period =1 , .weight =1 , };size_t i =0 , k;/*
@@ -90,7 +90,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) goto out; he =__hists__add_entry (hists, &al,NULL , -NULL ,NULL ,1 ,1 ,0 , true); +NULL ,NULL , &sample, true);if (he ==NULL ) {addr_location__put (&al); goto out;
@@ -116,7 +116,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) goto out; he =__hists__add_entry (hists, &al,NULL , -NULL ,NULL ,1 ,1 ,0 , true); +NULL ,NULL , &sample, true);if (he ==NULL ) {addr_location__put (&al); goto out;
tools/perf/util/hist.c +17 -14
@@ -461,7 +461,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists, struct symbol *sym_parent, struct branch_info *bi, struct mem_info *mi, - u64 period, u64 weight, u64 transaction, + struct perf_sample *sample, bool sample_self) { struct hist_entry entry = {
@@ -478,15 +478,15 @@ struct hist_entry *__hists__add_entry(struct hists *hists, .level = al->level, .stat = { .nr_events = 1, - .period = period, - .weight = weight, + .period = sample->period, + .weight = sample->weight, }, .parent = sym_parent, .filtered = symbol__parent_filter(sym_parent) | al->filtered, .hists = hists, .branch_info = bi, .mem_info = mi, - .transaction = transaction, + .transaction = sample->transaction, };return hists__findnew_entry (hists, &entry, al, sample_self);
@@ -526,12 +526,13 @@ iter_add_single_mem_entry(struct hist_entry_iter *iter, struct addr_location *alu64 cost;struct mem_info *mi = iter->priv;struct hists *hists =evsel__hists (iter->evsel); +struct perf_sample *sample = iter->sample;struct hist_entry *he;if (mi ==NULL )return -EINVAL ; - cost = iter->sample->weight; + cost = sample->weight;if (!cost) cost =1 ;
@@ -542,8 +543,10 @@ iter_add_single_mem_entry(struct hist_entry_iter *iter, struct addr_location *al* and this is indirectly achieved by passing period=weight here * and the he_stat__add_period() function. */ + sample->period = cost; + he =__hists__add_entry (hists, al, iter->parent,NULL , mi, - cost, cost,0 , true); + sample, true);if (!he)return -ENOMEM ;
@@ -630,6 +633,7 @@ iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *astruct branch_info *bi;struct perf_evsel *evsel = iter->evsel;struct hists *hists =evsel__hists (evsel); +struct perf_sample *sample = iter->sample;struct hist_entry *he =NULL ;int i = iter->curr;int err =0 ;
@@ -643,9 +647,11 @@ iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *a* The report shows the percentage of total branches captured * and not events sampled. Thus we use a pseudo period of 1. */ + sample->period =1 ; + sample->weight = bi->flags.cycles ? bi->flags.cycles :1 ; + he =__hists__add_entry (hists, al, iter->parent, &bi[i],NULL , -1 , bi->flags.cycles ? bi->flags.cycles :1 , -0 , true); + sample, true);if (he ==NULL )return -ENOMEM ;
@@ -682,8 +688,7 @@ iter_add_single_normal_entry(struct hist_entry_iter *iter, struct addr_locationstruct hist_entry *he; he =__hists__add_entry (evsel__hists (evsel), al, iter->parent,NULL ,NULL , - sample->period, sample->weight, - sample->transaction, true); + sample, true);if (he ==NULL )return -ENOMEM ;
@@ -744,8 +749,7 @@ iter_add_single_cumulative_entry(struct hist_entry_iter *iter,int err =0 ; he =__hists__add_entry (hists, al, iter->parent,NULL ,NULL , - sample->period, sample->weight, - sample->transaction, true); + sample, true);if (he ==NULL )return -ENOMEM ;
@@ -818,8 +822,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter, } he =__hists__add_entry (evsel__hists (evsel), al, iter->parent,NULL ,NULL , - sample->period, sample->weight, - sample->transaction, false); + sample, false);if (he ==NULL )return -ENOMEM ;
tools/perf/util/hist.h +2 -2
@@ -114,8 +114,8 @@ struct hist_entry *__hists__add_entry(struct hists *hists,struct addr_location *al, struct symbol *parent, struct branch_info *bi, - struct mem_info *mi, u64 period, - u64 weight, u64 transaction, + struct mem_info *mi, + struct perf_sample *sample, bool sample_self);int hist_entry_iter__add (struct hist_entry_iter *iter,struct addr_location *al,int max_stack_depth,void *arg);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 2/59 perf hist: Save raw_data/size for tracepoint events
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
The raw_data and raw_size fields are to provide tracepoint specific information. They will be used by dynamic sort keys later.
--- tools/perf/util/hist.c | 24 ++++++++++++++++++++++++ tools/perf/util/sort.h | 2 ++ 2 files changed, 26 insertions(+)
tools/perf/util/hist.c +24 -0
@@ -369,6 +369,25 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template,if (symbol_conf.use_callchain)callchain_init (he->callchain); +if (he->raw_data) { + he->raw_data =memdup (he->raw_data, he->raw_size); + +if (he->raw_data ==NULL ) { +map__put (he->ms.map); +if (he->branch_info) { +map__put (he->branch_info->from.map); +map__put (he->branch_info->to.map); +free (he->branch_info); + } +if (he->mem_info) { +map__put (he->mem_info->iaddr.map); +map__put (he->mem_info->daddr.map); + } +free (he->stat_acc); +free (he); +return NULL ; + } + }INIT_LIST_HEAD (&he->pairs.node);thread__get (he->thread); }
@@ -487,6 +506,8 @@ struct hist_entry *__hists__add_entry(struct hists *hists, .branch_info = bi, .mem_info = mi, .transaction = sample->transaction, + .raw_data = sample->raw_data, + .raw_size = sample->raw_size, };return hists__findnew_entry (hists, &entry, al, sample_self);
@@ -801,6 +822,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter, .sym = al->sym, }, .parent = iter->parent, + .raw_data = sample->raw_data, + .raw_size = sample->raw_size, };int i;struct callchain_cursor cursor;
@@ -974,6 +997,7 @@ void hist_entry__delete(struct hist_entry *he)if (he->srcfile && he->srcfile[0 ])free (he->srcfile);free_callchain (he->callchain); +free (he->raw_data);free (he); }
tools/perf/util/sort.h +2 -0
@@ -122,6 +122,8 @@ struct hist_entry {struct branch_info *branch_info;struct hists *hists;struct mem_info *mem_info; +void *raw_data; +u32 raw_size;struct callchain_root callchain[0 ];/* must be last member */ };
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 3/59 tools lib traceevent: Factor out and export print_event_field[s]()
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
The print_event_field() and print_event_fields() functions print basic information of a given field or event without the print format. They'll be used by dynamic sort keys later.
Committer note:
Rename it to pevent_print_field[s]() to get proper namespacing, as discussed with Steven Rostedt.
--- tools/lib/traceevent/event-parse.c | 129 +++++++++++++++++++------------------ tools/lib/traceevent/event-parse.h | 4 ++ 2 files changed, 72 insertions(+), 61 deletions(-)
tools/lib/traceevent/event-parse.c +68 -61
@@ -4735,73 +4735,80 @@ static int is_printable_array(char *p, unsigned int len)return 1 ; } -static void print_event_fields (struct trace_seq *s,void *data, -int size__maybe_unused , -struct event_format *event) +void pevent_print_field (struct trace_seq *s,void *data, +struct format_field *field) { -struct format_field *field;unsigned long long val;unsigned int offset, len, i; - - field = event->format.fields; -while (field) { -trace_seq_printf (s," %s=" , field->name); -if (field->flags &FIELD_IS_ARRAY ) { - offset = field->offset; - len = field->size; -if (field->flags &FIELD_IS_DYNAMIC ) { - val =pevent_read_number (event->pevent, data + offset, len); - offset = val; - len = offset >>16 ; - offset &=0xffff ; - } -if (field->flags &FIELD_IS_STRING && -is_printable_array (data + offset, len)) { -trace_seq_printf (s,"%s" , (char *)data + offset); - }else { -trace_seq_puts (s,"ARRAY[" ); -for (i =0 ; i < len; i++) { -if (i) -trace_seq_puts (s,", " ); -trace_seq_printf (s,"%02x" , - *((unsigned char *)data + offset + i)); - } -trace_seq_putc (s,']' ); - field->flags &= ~FIELD_IS_STRING ; - } +struct pevent *pevent = field->event->pevent; + +if (field->flags &FIELD_IS_ARRAY ) { + offset = field->offset; + len = field->size; +if (field->flags &FIELD_IS_DYNAMIC ) { + val =pevent_read_number (pevent, data + offset, len); + offset = val; + len = offset >>16 ; + offset &=0xffff ; + } +if (field->flags &FIELD_IS_STRING && +is_printable_array (data + offset, len)) { +trace_seq_printf (s,"%s" , (char *)data + offset); }else { - val =pevent_read_number (event->pevent, data + field->offset, - field->size); -if (field->flags &FIELD_IS_POINTER ) { -trace_seq_printf (s,"0x%llx" , val); - }else if (field->flags &FIELD_IS_SIGNED ) { -switch (field->size) { -case 4 : -/* -* If field is long then print it in hex. -* A long usually stores pointers. -*/ -if (field->flags &FIELD_IS_LONG ) -trace_seq_printf (s,"0x%x" , (int )val); -else -trace_seq_printf (s,"%d" , (int )val); -break ; -case 2 : -trace_seq_printf (s,"%2d" , (short )val); -break ; -case 1 : -trace_seq_printf (s,"%1d" , (char )val); -break ; -default : -trace_seq_printf (s,"%lld" , val); - } - }else { +trace_seq_puts (s,"ARRAY[" ); +for (i =0 ; i < len; i++) { +if (i) +trace_seq_puts (s,", " ); +trace_seq_printf (s,"%02x" , + *((unsigned char *)data + offset + i)); + } +trace_seq_putc (s,']' ); + field->flags &= ~FIELD_IS_STRING ; + } + }else { + val =pevent_read_number (pevent, data + field->offset, + field->size); +if (field->flags &FIELD_IS_POINTER ) { +trace_seq_printf (s,"0x%llx" , val); + }else if (field->flags &FIELD_IS_SIGNED ) { +switch (field->size) { +case 4 : +/* +* If field is long then print it in hex. +* A long usually stores pointers. +*/ if (field->flags &FIELD_IS_LONG ) -trace_seq_printf (s,"0x%llx" , val); +trace_seq_printf (s,"0x%x" , (int )val);else -trace_seq_printf (s,"%llu" , val); +trace_seq_printf (s,"%d" , (int )val); +break ; +case 2 : +trace_seq_printf (s,"%2d" , (short )val); +break ; +case 1 : +trace_seq_printf (s,"%1d" , (char )val); +break ; +default : +trace_seq_printf (s,"%lld" , val); } + }else { +if (field->flags &FIELD_IS_LONG ) +trace_seq_printf (s,"0x%llx" , val); +else +trace_seq_printf (s,"%llu" , val); } + } +} + +void pevent_print_fields (struct trace_seq *s,void *data, +int size__maybe_unused ,struct event_format *event) +{ +struct format_field *field; + + field = event->format.fields; +while (field) { +trace_seq_printf (s," %s=" , field->name); +pevent_print_field (s, data, field); field = field->next; } }
@@ -4827,7 +4834,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct eventif (event->flags &EVENT_FL_FAILED ) {trace_seq_printf (s,"[FAILED TO PARSE]" ); -print_event_fields (s, data, size, event); +pevent_print_fields (s, data, size, event);return ; }
@@ -5301,7 +5308,7 @@ void pevent_event_info(struct trace_seq *s, struct event_format *event,int print_pretty =1 ;if (event->pevent->print_raw || (event->flags &EVENT_FL_PRINTRAW )) -print_event_fields (s, record->data, record->size, event); +pevent_print_fields (s, record->data, record->size, event);else {if (event->handler && !(event->flags &EVENT_FL_NOHANDLE ))
tools/lib/traceevent/event-parse.h +4 -0
@@ -705,6 +705,10 @@ struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *com struct cmdline *next);int pevent_cmdline_pid (struct pevent *pevent,struct cmdline *cmdline); +void pevent_print_field (struct trace_seq *s,void *data, +struct format_field *field); +void pevent_print_fields (struct trace_seq *s,void *data, +int size__maybe_unused ,struct event_format *event);void pevent_event_info (struct trace_seq *s,struct event_format *event,struct pevent_record *record); int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 4/59 perf top: Create the evlist sooner
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
This is a preparation to support dynamic sort keys for tracepoint events. Dynamic sort keys can be created for specific fields in trace events so it needs the event information, so we need to pass the evlist to the sort routines, create it sooner so that the next patch can do that.
--- tools/perf/builtin-top.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/perf/builtin-top.c +6 -6
@@ -1231,6 +1231,12 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)if (argc)usage_with_options (top_usage, options); +if (!top.evlist->nr_entries && +perf_evlist__add_default (top.evlist) <0 ) { +pr_err ("Not enough memory for event selector list\n" ); + goto out_delete_evlist; + } + sort__mode =SORT_MODE__TOP ;/* display thread wants entries to be collapsed in a different tree */ sort__need_collapse =1 ;
@@ -1277,12 +1283,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) goto out_delete_evlist; } -if (!top.evlist->nr_entries && -perf_evlist__add_default (top.evlist) <0 ) { -ui__error ("Not enough memory for event selector list\n" ); - goto out_delete_evlist; - } - symbol_conf.nr_events = top.evlist->nr_entries;if (top.delay_secs <1 )
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 5/59 perf tools: Pass evlist to setup_sorting()
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
This is a preparation to support dynamic sort keys for tracepoint events. Dynamic sort keys can be created for specific fields in trace events so it needs the event information.
--- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/tests/hists_cumulate.c | 8 ++++---- tools/perf/tests/hists_filter.c | 2 +- tools/perf/tests/hists_link.c | 2 +- tools/perf/tests/hists_output.c | 10 +++++----- tools/perf/util/sort.c | 15 +++++++++------ tools/perf/util/sort.h | 5 +++-- 10 files changed, 27 insertions(+), 23 deletions(-)
tools/perf/builtin-annotate.c +1 -1
@@ -370,7 +370,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)if (ret <0 ) goto out_delete; -if (setup_sorting () <0 ) +if (setup_sorting (NULL ) <0 )usage_with_options (annotate_usage, options);if (annotate.use_stdio)
tools/perf/builtin-diff.c +1 -1
@@ -1279,7 +1279,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) sort__mode =SORT_MODE__DIFF ; -if (setup_sorting () <0 ) +if (setup_sorting (NULL ) <0 )usage_with_options (diff_usage, options);setup_pager ();
tools/perf/builtin-report.c +1 -1
@@ -897,7 +897,7 @@ repeat: symbol_conf.cumulate_callchain = false; } -if (setup_sorting () <0 ) { +if (setup_sorting (session->evlist) <0 ) {if (sort_order)parse_options_usage (report_usage, options,"s" ,1 );if (field_order)
tools/perf/builtin-top.c +1 -1
@@ -1241,7 +1241,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)/* display thread wants entries to be collapsed in a different tree */ sort__need_collapse =1 ; -if (setup_sorting () <0 ) { +if (setup_sorting (top.evlist) <0 ) {if (sort_order)parse_options_usage (top_usage, options,"s" ,1 );if (field_order)
tools/perf/tests/hists_cumulate.c +4 -4
@@ -281,7 +281,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = false;perf_evsel__reset_sample_bit (evsel,CALLCHAIN ); -setup_sorting (); +setup_sorting (NULL );callchain_register_param (&callchain_param); err =add_hist_entries (hists, machine);
@@ -428,7 +428,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = false;perf_evsel__set_sample_bit (evsel,CALLCHAIN ); -setup_sorting (); +setup_sorting (NULL );callchain_register_param (&callchain_param); err =add_hist_entries (hists, machine);
@@ -486,7 +486,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = true;perf_evsel__reset_sample_bit (evsel,CALLCHAIN ); -setup_sorting (); +setup_sorting (NULL );callchain_register_param (&callchain_param); err =add_hist_entries (hists, machine);
@@ -670,7 +670,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = true;perf_evsel__set_sample_bit (evsel,CALLCHAIN ); -setup_sorting (); +setup_sorting (NULL );callchain_register_param (&callchain_param); err =add_hist_entries (hists, machine);
tools/perf/tests/hists_filter.c +1 -1
@@ -122,7 +122,7 @@ int test__hists_filter(int subtest __maybe_unused) goto out;/* default sort order (comm,dso,sym) will be used */ -if (setup_sorting () <0 ) +if (setup_sorting (NULL ) <0 ) goto out;machines__init (&machines);
tools/perf/tests/hists_link.c +1 -1
@@ -294,7 +294,7 @@ int test__hists_link(int subtest __maybe_unused) goto out;/* default sort order (comm,dso,sym) will be used */ -if (setup_sorting () <0 ) +if (setup_sorting (NULL ) <0 ) goto out;machines__init (&machines);
tools/perf/tests/hists_output.c +5 -5
@@ -134,7 +134,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine) field_order =NULL ; sort_order =NULL ;/* equivalent to sort_order = "comm,dso,sym" */ -setup_sorting (); +setup_sorting (NULL );/* * expected output:
@@ -236,7 +236,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine) field_order ="overhead,cpu" ; sort_order ="pid" ; -setup_sorting (); +setup_sorting (NULL );/* * expected output:
@@ -292,7 +292,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine) field_order ="comm,overhead,dso" ; sort_order =NULL ; -setup_sorting (); +setup_sorting (NULL );/* * expected output:
@@ -366,7 +366,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine) field_order ="dso,sym,comm,overhead,dso" ; sort_order ="sym" ; -setup_sorting (); +setup_sorting (NULL );/* * expected output:
@@ -468,7 +468,7 @@ static int test5(struct perf_evsel *evsel, struct machine *machine) field_order ="cpu,pid,comm,dso,sym" ; sort_order ="dso,pid" ; -setup_sorting (); +setup_sorting (NULL );/* * expected output:
tools/perf/util/sort.c +9 -6
@@ -4,6 +4,8 @@#include "comm.h" #include "symbol.h" #include "evsel.h" +#include "evlist.h" +#include <traceevent/event-parse.h> regex_t parent_regex;const char default_parent_pattern[] ="^sys_|^do_page_fault" ;
@@ -1583,7 +1585,8 @@ int hpp_dimension__add_output(unsigned col)return __hpp_dimension__add_output (&hpp_sort_dimensions[col]); } -int sort_dimension__add (const char *tok) +static int sort_dimension__add (const char *tok, +struct perf_evlist *evlist__maybe_unused ) {unsigned int i;
@@ -1712,7 +1715,7 @@ static int setup_sort_order(void)return 0 ; } -static int __setup_sorting (void ) +static int __setup_sorting (struct perf_evlist *evlist) {char *tmp, *tok, *str;const char *sort_keys;
@@ -1743,7 +1746,7 @@ static int __setup_sorting(void)for (tok =strtok_r (str,", " , &tmp); tok; tok =strtok_r (NULL ,", " , &tmp)) { - ret =sort_dimension__add (tok); + ret =sort_dimension__add (tok, evlist);if (ret == -EINVAL ) {error ("Invalid --sort key: `%s'" , tok);break ;
@@ -1954,16 +1957,16 @@ out:return ret; } -int setup_sorting (void ) +int setup_sorting (struct perf_evlist *evlist) {int err; - err =__setup_sorting (); + err =__setup_sorting (evlist);if (err <0 )return err;if (parent_pattern != default_parent_pattern) { - err =sort_dimension__add ("parent" ); + err =sort_dimension__add ("parent" , evlist);if (err <0 )return err; }
tools/perf/util/sort.h +3 -2
@@ -226,10 +226,11 @@ struct sort_entry {extern struct sort_entry sort_thread;extern struct list_head hist_entry__sort_list; -int setup_sorting (void ); +struct perf_evlist ; +struct pevent ; +int setup_sorting (struct perf_evlist *evlist);int setup_output_field (void );void reset_output_field (void ); -extern int sort_dimension__add (const char *);void sort__setup_elide (FILE *fp);void perf_hpp__set_elide (int idx,bool elide);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 6/59 perf tools: Add dynamic sort key for tracepoint events
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
The existing sort keys are less useful for tracepoint events in that they are always sampled at the same place, the function where the tracepoint is located.
For example, a 'perf report' on sched:sched_switch event looks like the following:
# Overhead Command Shared Object Symbol
# ........ ............... ................ ..............
#
47.22% swapper [kernel.vmlinux] [k] __schedule
21.67% transmission-gt [kernel.vmlinux] [k] __schedule
8.23% netctl-auto [kernel.vmlinux] [k] __schedule
5.53% kworker/0:1H [kernel.vmlinux] [k] __schedule
1.98% Xephyr [kernel.vmlinux] [k] __schedule
1.33% irq/33-iwlwifi [kernel.vmlinux] [k] __schedule
1.17% wpa_cli [kernel.vmlinux] [k] __schedule
1.13% rcu_preempt [kernel.vmlinux] [k] __schedule
0.85% ksoftirqd/0 [kernel.vmlinux] [k] __schedule
0.77% Timer [kernel.vmlinux] [k] __scheduleIn fact, tracepoints have meaningful information in their fields but there's no way to use in 'perf report' currently. The dynamic sort keys are introduced in this patc to overcome this limitation.
The sched:sched_switch events have following fields:
# sudo cat /sys/kernel/debug/tracing/events/sched/sched_switch/format name: sched_switch ID: 268 format: field:unsigned short common_type; offset:0; size:2; signed:0; field:unsigned char common_flags; offset:2; size:1; signed:0; field:unsigned char common_preempt_count; offset:3; size:1; signed:0; field:int common_pid; offset:4; size:4; signed:1;
field:char prev_comm[16]; offset:8; size:16; signed:1; field:pid_t prev_pid; offset:24; size:4; signed:1; field:int prev_prio; offset:28; size:4; signed:1; field:long prev_state; offset:32; size:8; signed:1; field:char next_comm[16]; offset:40; size:16; signed:1; field:pid_t next_pid; offset:56; size:4; signed:1; field:int next_prio; offset:60; size:4; signed:1;
print fmt: "prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==>
next_comm=%s next_pid=%d next_prio=%d",
REC->prev_comm, REC->prev_pid, REC->prev_prio,
REC->prev_state & (2048-1) ? __print_flags(REC->prev_state & (2048-1),
"|", { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" }, { 16, "Z" }, { 32, "X" },
{ 64, "x" }, { 128, "K"}, { 256, "W" }, { 512, "P" }, { 1024, "N" }) : "R",
REC->prev_state & 2048 ? "+" : "", REC->next_comm, REC->next_pid, REC->next_prioWith dynamic sort keys, you can use <event.field> as a sort key. Those dynamic keys are checked and created on demand. For instance, below is to sort by next_pid field output on the same data file:
$ perf report -s comm,sched:sched_switch.next_pid --stdio
...
# Overhead Command next_pid
# ........ ............... ..........
#
21.23% transmission-gt 0
20.86% swapper 17773
6.62% netctl-auto 0
5.25% swapper 109
5.21% kworker/0:1H 0
1.98% Xephyr 0
1.98% swapper 6524
1.98% swapper 27478
1.37% swapper 27476
1.17% swapper 233Multiple dynamic sort keys are also supported:
$ perf report -s comm,sched:sched_switch.next_pid,sched:sched_switch.next_comm --stdio
...
# Overhead Command next_pid next_comm
# ........ ............... .......... ................
#
20.86% swapper 17773 transmission-gt
9.64% transmission-gt 0 swapper/0
9.16% transmission-gt 0 swapper/2
5.25% swapper 109 kworker/0:1H
5.21% kworker/0:1H 0 swapper/0
2.14% netctl-auto 0 swapper/2
1.98% netctl-auto 0 swapper/0
1.98% swapper 6524 Xephyr
1.98% swapper 27478 netctl-auto
1.78% transmission-gt 0 swapper/3
1.53% Xephyr 0 swapper/0
1.29% netctl-auto 0 swapper/1
1.29% swapper 27476 netctl-auto
1.21% netctl-auto 0 swapper/3
1.17% swapper 233 irq/33-iwlwifiNote that pid 0 exists for each cpu so have comm of 'swapper/N'.
--- tools/perf/util/sort.c | 213 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 213 insertions(+)
tools/perf/util/sort.c +213 -0
@@ -1531,6 +1531,216 @@ static int __sort_dimension__add_hpp_output(struct sort_dimension *sd)return 0 ; } +struct hpp_dynamic_entry { +struct perf_hpp_fmt hpp; +struct perf_evsel *evsel; +struct format_field *field; +unsigned dynamic_len; +}; + +static int hde_width (struct hpp_dynamic_entry *hde) +{ +if (!hde->hpp.len) { +int len = hde->dynamic_len; +int namelen =strlen (hde->field->name); +int fieldlen = hde->field->size; + +if (namelen > len) + len = namelen; + +if (!(hde->field->flags &FIELD_IS_STRING )) { +/* length for print hex numbers */ + fieldlen = hde->field->size *2 +2 ; + } +if (fieldlen > len) + len = fieldlen; + + hde->hpp.len = len; + } +return hde->hpp.len; +} + +static int __sort__hde_header (struct perf_hpp_fmt *fmt,struct perf_hpp *hpp, +struct perf_evsel *evsel__maybe_unused ) +{ +struct hpp_dynamic_entry *hde; +size_t len = fmt->user_len; + + hde = container_of(fmt, struct hpp_dynamic_entry, hpp); + +if (!len) + len =hde_width (hde); + +return scnprintf (hpp->buf, hpp->size,"%*.*s" , len, len, hde->field->name); +} + +static int __sort__hde_width (struct perf_hpp_fmt *fmt, +struct perf_hpp *hpp__maybe_unused , +struct perf_evsel *evsel__maybe_unused ) +{ +struct hpp_dynamic_entry *hde; +size_t len = fmt->user_len; + + hde = container_of(fmt, struct hpp_dynamic_entry, hpp); + +if (!len) + len =hde_width (hde); + +return len; +} + +static int __sort__hde_entry (struct perf_hpp_fmt *fmt,struct perf_hpp *hpp, +struct hist_entry *he) +{ +struct hpp_dynamic_entry *hde; +size_t len = fmt->user_len; +struct trace_seq seq; +int ret; + + hde = container_of(fmt, struct hpp_dynamic_entry, hpp); + +if (!len) + len =hde_width (hde); + +if (hists_to_evsel (he->hists) != hde->evsel) +return scnprintf (hpp->buf, hpp->size,"%*.*s" , len, len,"N/A" ); + +trace_seq_init (&seq); +pevent_print_field (&seq, he->raw_data, hde->field); + ret =scnprintf (hpp->buf, hpp->size,"%*.*s" , len, len, seq.buffer); +trace_seq_destroy (&seq); +return ret; +} + +static int64_t __sort__hde_cmp (struct perf_hpp_fmt *fmt, +struct hist_entry *a,struct hist_entry *b) +{ +struct hpp_dynamic_entry *hde; +struct format_field *field; +unsigned offset, size; + + hde = container_of(fmt, struct hpp_dynamic_entry, hpp); + +if (hists_to_evsel (a->hists) != hde->evsel) +return 0 ; + + field = hde->field; +if (field->flags &FIELD_IS_DYNAMIC ) { +unsigned long long dyn; + +pevent_read_number_field (field, a->raw_data, &dyn); + offset = dyn &0xffff ; + size = (dyn >>16 ) &0xffff ; + +/* record max width for output */ +if (size > hde->dynamic_len) + hde->dynamic_len = size; + }else { + offset = field->offset; + size = field->size; + } + +return memcmp (a->raw_data + offset, b->raw_data + offset, size); +} + +static struct hpp_dynamic_entry * +__alloc_dynamic_entry (struct perf_evsel *evsel,struct format_field *field) +{ +struct hpp_dynamic_entry *hde; + + hde =malloc (sizeof (*hde)); +if (hde ==NULL ) { +pr_debug ("Memory allocation failed\n" ); +return NULL ; + } + + hde->evsel = evsel; + hde->field = field; + hde->dynamic_len =0 ; + + hde->hpp.name = field->name; + hde->hpp.header = __sort__hde_header; + hde->hpp.width = __sort__hde_width; + hde->hpp.entry = __sort__hde_entry; + hde->hpp.color =NULL ; + + hde->hpp.cmp = __sort__hde_cmp; + hde->hpp.collapse = __sort__hde_cmp; + hde->hpp.sort = __sort__hde_cmp; + +INIT_LIST_HEAD (&hde->hpp.list); +INIT_LIST_HEAD (&hde->hpp.sort_list); + hde->hpp.elide = false; + hde->hpp.len =0 ; + hde->hpp.user_len =0 ; + +return hde; +} + +static int add_dynamic_entry (struct perf_evlist *evlist,const char *tok) +{ +char *str, *event_name, *field_name; +struct perf_evsel *evsel, *pos; +struct format_field *field; +struct hpp_dynamic_entry *hde; +int ret =0 ; + +if (evlist ==NULL ) +return -ENOENT ; + + str =strdup (tok); +if (str ==NULL ) +return -ENOMEM ; + + event_name = str; + field_name =strchr (str,'.' ); +if (field_name ==NULL ) { + ret = -EINVAL ; + goto out; + } + *field_name++ ='\0' ; + + evsel =NULL ; +evlist__for_each (evlist, pos) { +if (!strcmp (pos->name, event_name)) { + evsel = pos; +break ; + } + } + +if (evsel ==NULL ) { +pr_debug ("Cannot find event: %s\n" , event_name); + ret = -ENOENT ; + goto out; + } + +if (evsel->attr.type !=PERF_TYPE_TRACEPOINT ) { +pr_debug ("%s is not a tracepoint event\n" , event_name); + ret = -EINVAL ; + goto out; + } + + field =pevent_find_any_field (evsel->tp_format, field_name); +if (field ==NULL ) { +pr_debug ("Cannot find event field for %s.%s\n" , + event_name, field_name); + ret = -ENOENT ; + goto out; + } + + hde =__alloc_dynamic_entry (evsel, field); +if (hde ==NULL ) { + ret = -ENOMEM ; + goto out; + } + +perf_hpp__register_sort_field (&hde->hpp); + +out: +free (str); +return ret; +} +static int __sort_dimension__add (struct sort_dimension *sd) {if (sd->taken)
@@ -1667,6 +1877,9 @@ static int sort_dimension__add(const char *tok,return 0 ; } +if (!add_dynamic_entry (evlist, tok)) +return 0 ; +return -ESRCH ; }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 7/59 perf tools: Try to show pretty printed output for dynamic sort keys
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
Each tracepoint event has format string for print to improve readability. Try to parse the output and match the field name. If it finds one, use that for the result. If not, fallbacks to the original output.
For example, sort on kmem:kmalloc.gfp_flags looks like below:
(Note: libtraceevent plugins are not installed on my system. They might affect the output below)
Before:
# Overhead Command gfp_flags
# ........ ....... ..........
#
99.89% perf 32848
0.06% sleep 208
0.03% perf 32976
0.01% perf 208After:
# Overhead Command gfp_flags
# ........ ....... ...................
#
99.89% perf GFP_NOFS|GFP_ZERO
0.06% sleep GFP_KERNEL
0.03% perf GFP_KERNEL|GFP_ZERO
0.01% perf GFP_KERNEL--- tools/perf/util/hist.c | 1 + tools/perf/util/sort.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++--- tools/perf/util/sort.h | 1 + 3 files changed, 102 insertions(+), 5 deletions(-)
tools/perf/util/hist.c +1 -0
@@ -997,6 +997,7 @@ void hist_entry__delete(struct hist_entry *he)if (he->srcfile && he->srcfile[0 ])free (he->srcfile);free_callchain (he->callchain); +free (he->trace_output);free (he->raw_data);free (he); }
tools/perf/util/sort.c +100 -5
129 lines not on this page · raw message
tools/perf/util/sort.h +1 -0
@@ -124,6 +124,7 @@ struct hist_entry {struct mem_info *mem_info;void *raw_data;u32 raw_size; +void *trace_output;struct callchain_root callchain[0 ];/* must be last member */ };
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 8/59 perf tools: Add 'trace' sort key
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
The 'trace' sort key is to show tracepoint event output using either print fmt or plugin. For example sched_switch event (using plugin) will show output like below:
# perf record -e sched:sched_switch -a usleep 10 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.197 MB perf.data (69 samples) ] #
$ perf report -s trace --stdio
...
# Overhead Trace output
# ........ ...................................................
#
9.48% swapper/0:0 [120] R ==> transmission-gt:17773 [120]
9.48% transmission-gt:17773 [120] S ==> swapper/0:0 [120]
9.04% swapper/2:0 [120] R ==> transmission-gt:17773 [120]
8.92% transmission-gt:17773 [120] S ==> swapper/2:0 [120]
5.25% swapper/0:0 [120] R ==> kworker/0:1H:109 [100]
5.21% kworker/0:1H:109 [100] S ==> swapper/0:0 [120]
1.78% swapper/3:0 [120] R ==> transmission-gt:17773 [120]
1.78% transmission-gt:17773 [120] S ==> swapper/3:0 [120]
1.53% Xephyr:6524 [120] S ==> swapper/0:0 [120]
1.53% swapper/0:0 [120] R ==> Xephyr:6524 [120]
1.17% swapper/2:0 [120] R ==> irq/33-iwlwifi:233 [49]
1.13% irq/33-iwlwifi:233 [49] S ==> swapper/2:0 [120]Note that the 'trace' sort key works only for tracepoint events. If it's used to other type of events, just "N/A" will be printed.
--- tools/perf/util/hist.h | 1 + tools/perf/util/sort.c | 76 +++++++++++++++++++++++++++++++++++++++----------- tools/perf/util/sort.h | 1 + 3 files changed, 62 insertions(+), 16 deletions(-)
tools/perf/util/hist.h +1 -0
@@ -52,6 +52,7 @@ enum hist_column {HISTC_MEM_IADDR_SYMBOL ,HISTC_TRANSACTION ,HISTC_CYCLES , +HISTC_TRACE , HISTC_NR_COLS, /* Last entry */ };
tools/perf/util/sort.c +60 -16
94 lines not on this page · raw message
tools/perf/util/sort.h +1 -0
@@ -183,6 +183,7 @@ enum sort_type {SORT_LOCAL_WEIGHT ,SORT_GLOBAL_WEIGHT ,SORT_TRANSACTION , +SORT_TRACE ,/* branch stack specific sort keys */ __SORT_BRANCH_STACK,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 9/59 perf report/top: Add --raw-trace option
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
The --raw-trace option allows disabling pretty printing by the event's print_fmt or plugin. Besides that, each dynamic sort key now can receive a 'raw' suffix separated by '/' to ask for the raw trace of a specific field.
$ perf report -s comm,kmem:kmalloc.gfp_flags
...
# Overhead Command gfp_flags
# ........ ....... ...................
#
99.89% perf GFP_NOFS|GFP_ZERO
0.06% sleep GFP_KERNEL
0.03% perf GFP_KERNEL|GFP_ZERO
0.01% perf GFP_KERNELNow
$ perf report -s comm,kmem:kmalloc.gfp_flags --raw-trace
or
$ perf report -s comm,kmem:kmalloc.gfp_flags/raw
...
# Overhead Command gfp_flags
# ........ ....... ..........
#
99.89% perf 32848
0.06% sleep 208
0.03% perf 32976
0.01% perf 208--- tools/perf/Documentation/perf-report.txt | 3 +++ tools/perf/Documentation/perf-top.txt | 3 +++ tools/perf/builtin-report.c | 2 ++ tools/perf/builtin-top.c | 2 ++ tools/perf/util/sort.c | 32 +++++++++++++++++++++++++++++--- tools/perf/util/symbol.h | 3 ++- 6 files changed, 41 insertions(+), 4 deletions(-)
tools/perf/Documentation/perf-report.txt +3 -0
@@ -371,6 +371,9 @@ include::itrace.txt[] --socket-filter:: Only report the samples on the processor socket that match with this filter +--raw-trace:: + When displaying traceevent output, do not use print fmt or plugins. + include::callchain-overhead-calculation.txt[] SEE ALSO
tools/perf/Documentation/perf-top.txt +3 -0
@@ -230,6 +230,9 @@ Default is to monitor all CPUS. The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k Note that this feature may not be available on all processors. +--raw-trace:: + When displaying traceevent output, do not use print fmt or plugins. + INTERACTIVE PROMPTING KEYS --------------------------
tools/perf/builtin-report.c +2 -0
@@ -788,6 +788,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) "Show callgraph from reference event"),OPT_INTEGER (0 ,"socket-filter" , &report.socket_filter,"only show processor socket that match with this filter" ), +OPT_BOOLEAN (0 ,"raw-trace" , &symbol_conf.raw_trace, +"Show raw trace event output (do not use print fmt or plugins)" ),OPT_END () }; struct perf_data_file file = {
tools/perf/builtin-top.c +2 -0
@@ -1210,6 +1210,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)OPT_CALLBACK ('j' ,"branch-filter" , &opts->branch_stack,"branch filter mask" ,"branch stack filter modes" , parse_branch_stack), +OPT_BOOLEAN (0 ,"raw-trace" , &symbol_conf.raw_trace, +"Show raw trace event output (do not use print fmt or plugins)" ),OPT_END () }; const char * const top_usage[] = {
tools/perf/util/sort.c +29 -3
@@ -459,7 +459,12 @@ static char *get_trace_output(struct hist_entry *he) evsel =hists_to_evsel (he->hists);trace_seq_init (&seq); -pevent_event_info (&seq, evsel->tp_format, &rec); +if (symbol_conf.raw_trace) { +pevent_print_fields (&seq, he->raw_data, he->raw_size, + evsel->tp_format); + }else { +pevent_event_info (&seq, evsel->tp_format, &rec); + }return seq.buffer; }
@@ -1596,6 +1601,7 @@ struct hpp_dynamic_entry {struct perf_evsel *evsel;struct format_field *field;unsigned dynamic_len; +bool raw_trace; };static int hde_width (struct hpp_dynamic_entry *hde)
@@ -1628,6 +1634,9 @@ static void update_dynamic_len(struct hpp_dynamic_entry *hde,size_t namelen;bool last = false; +if (hde->raw_trace) +return ; +/* parse pretty print result and update max length */ if (!he->trace_output) he->trace_output =get_trace_output (he);
@@ -1708,8 +1717,10 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,if (hists_to_evsel (he->hists) != hde->evsel)return scnprintf (hpp->buf, hpp->size,"%*.*s" , len, len,"N/A" ); - field = hde->field; +if (hde->raw_trace) + goto raw_field; + field = hde->field; namelen =strlen (field->name); str = he->trace_output;
@@ -1738,6 +1749,7 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,if (str ==NULL ) {struct trace_seq seq; +raw_field:trace_seq_init (&seq);pevent_print_field (&seq, he->raw_data, hde->field); str = seq.buffer;
@@ -1818,10 +1830,11 @@ __alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field)static int add_dynamic_entry (struct perf_evlist *evlist,const char *tok) { -char *str, *event_name, *field_name; +char *str, *event_name, *field_name, *raw_opt;struct perf_evsel *evsel, *pos;struct format_field *field;struct hpp_dynamic_entry *hde; +bool raw_trace = symbol_conf.raw_trace;int ret =0 ;if (evlist ==NULL )
@@ -1839,6 +1852,18 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok) } *field_name++ ='\0' ; + raw_opt =strchr (field_name,'/' ); +if (raw_opt) { + *raw_opt++ ='\0' ; + +if (strcmp (raw_opt,"raw" )) { +pr_err ("Unsupported field option %s\n" , raw_opt); + ret = -EINVAL ; + goto out; + } + raw_trace = true; + } + evsel =NULL ;evlist__for_each (evlist, pos) {if (!strcmp (pos->name, event_name)) {
@@ -1872,6 +1897,7 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok) ret = -ENOMEM ; goto out; } + hde->raw_trace = raw_trace;perf_hpp__register_sort_field (&hde->hpp);
tools/perf/util/symbol.h +2 -1
@@ -109,7 +109,8 @@ struct symbol_conf { branch_callstack, has_filter, show_ref_callgraph, - hide_unresolved; + hide_unresolved, + raw_trace;const char *vmlinux_name, *kallsyms_name, *source_prefix,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 10/59 perf tools: Support shortcuts for events in dynamic sort keys
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
The dynamic sort key requires event name but specifying full event name is rather inconvenient. This patch adds more ways to identify the event in a more compact way.
1. If session has just one event, event name can be omitted.
2. Events can be accessed by index preceded by a percent sign.
3. A part of the name can be used, if it's not ambiguous. The partial name should not contain ':' in it.
4. Full system + event name is still used, it should contain ':'.
So in the below example all does same thing:
$ perf record -e sched:sched_switch -a sleep 1
$ perf report -s next_pid,next_comm $ perf report -s %1.next_pid,%1.next_comm $ perf report -s switch.next_pid,switch.next_comm $ perf report -s sched:sched_switch.next_pid,sched:sched_switch.next_comm
--- tools/perf/util/sort.c | 107 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 87 insertions(+), 20 deletions(-)
tools/perf/util/sort.c +87 -20
@@ -1828,10 +1828,90 @@ __alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field)return hde; } +static int parse_field_name (char *str,char **event,char **field,char **opt) +{ +char *event_name, *field_name, *opt_name; + + event_name = str; + field_name =strchr (str,'.' ); + +if (field_name) { + *field_name++ ='\0' ; + }else { + event_name =NULL ; + field_name = str; + } + + opt_name =strchr (field_name,'/' ); +if (opt_name) + *opt_name++ ='\0' ; + + *event = event_name; + *field = field_name; + *opt = opt_name; + +return 0 ; +} + +/* find match evsel using a given event name. The event name can be: +* 1. NULL - only valid for single event session +* 2. '%' + event index (e.g. '%1' for first event) +* 3. full event name (e.g. sched:sched_switch) +* 4. partial event name (should not contain ':') +*/ +static struct perf_evsel *find_evsel (struct perf_evlist *evlist,char *event_name) +{ +struct perf_evsel *evsel =NULL ; +struct perf_evsel *pos; +bool full_name; + +/* case 1 */ +if (event_name ==NULL ) { +if (evlist->nr_entries !=1 ) { +pr_debug ("event name should be given\n" ); +return NULL ; + } + +return perf_evlist__first (evlist); + } + +/* case 2 */ +if (event_name[0 ] =='%' ) { +int nr =strtol (event_name+1 ,NULL ,0 ); + +if (nr > evlist->nr_entries) +return NULL ; + + evsel =perf_evlist__first (evlist); +while (--nr >0 ) + evsel =perf_evsel__next (evsel); + +return evsel; + } + + full_name = !!strchr (event_name,':' ); +evlist__for_each (evlist, pos) { +/* case 3 */ +if (full_name && !strcmp (pos->name, event_name)) +return pos; +/* case 4 */ +if (!full_name &&strstr (pos->name, event_name)) { +if (evsel) { +pr_debug ("'%s' event is ambiguous: it can be %s or %s\n" , + event_name, evsel->name, pos->name); +return NULL ; + } + evsel = pos; + } + } + +return evsel; +} +static int add_dynamic_entry (struct perf_evlist *evlist,const char *tok) { -char *str, *event_name, *field_name, *raw_opt; -struct perf_evsel *evsel, *pos; +char *str, *event_name, *field_name, *opt_name; +struct perf_evsel *evsel;struct format_field *field;struct hpp_dynamic_entry *hde;bool raw_trace = symbol_conf.raw_trace;
@@ -1844,34 +1924,21 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)if (str ==NULL )return -ENOMEM ; - event_name = str; - field_name =strchr (str,'.' ); -if (field_name ==NULL ) { +if (parse_field_name (str, &event_name, &field_name, &opt_name) <0 ) { ret = -EINVAL ; goto out; } - *field_name++ ='\0' ; - raw_opt =strchr (field_name,'/' ); -if (raw_opt) { - *raw_opt++ ='\0' ; - -if (strcmp (raw_opt,"raw" )) { -pr_err ("Unsupported field option %s\n" , raw_opt); +if (opt_name) { +if (strcmp (opt_name,"raw" )) { +pr_debug ("unsupported field option %s\n" , opt_name); ret = -EINVAL ; goto out; } raw_trace = true; } - evsel =NULL ; -evlist__for_each (evlist, pos) { -if (!strcmp (pos->name, event_name)) { - evsel = pos; -break ; - } - } - + evsel =find_evsel (evlist, event_name);if (evsel ==NULL ) {pr_debug ("Cannot find event: %s\n" , event_name); ret = -ENOENT ;
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 11/59 perf tools: Support '<event>.*' dynamic sort key
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
Support '*' character for field name to add all (non-common) fields as sort keys easily.
$ perf report -s 'switch.*' --stdio
...
# Overhead prev_comm prev_pid prev_prio prev_state next_comm next_pid next_prio
# ........ ........... ......... ......... .......... ............ ........ .........
#
3.82% swapper/0 0 120 0 netctl-auto 18711 120
3.75% netctl-auto 18711 120 1 swapper/0 0 120
2.24% swapper/1 0 120 0 netctl-auto 18709 120
2.24% netctl-auto 18709 120 1 swapper/1 0 120
1.80% swapper/2 0 120 0 rcu_preempt 7 120
1.80% swapper/2 0 120 0 netctl-auto 18711 120
1.80% rcu_preempt 7 120 1 swapper/2 0 120
1.80% netctl-auto 18711 120 1 swapper/2 0 120
...--- tools/perf/util/sort.c | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-)
tools/perf/util/sort.c +34 -15
@@ -1908,12 +1908,27 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_namreturn evsel; } +static int __dynamic_dimension__add (struct perf_evsel *evsel, +struct format_field *field, +bool raw_trace) +{ +struct hpp_dynamic_entry *hde; + + hde =__alloc_dynamic_entry (evsel, field); +if (hde ==NULL ) +return -ENOMEM ; + + hde->raw_trace = raw_trace; + +perf_hpp__register_sort_field (&hde->hpp); +return 0 ; +} +static int add_dynamic_entry (struct perf_evlist *evlist,const char *tok) {char *str, *event_name, *field_name, *opt_name;struct perf_evsel *evsel;struct format_field *field; -struct hpp_dynamic_entry *hde;bool raw_trace = symbol_conf.raw_trace;int ret =0 ;
@@ -1951,22 +1966,26 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok) goto out; } - field =pevent_find_any_field (evsel->tp_format, field_name); -if (field ==NULL ) { -pr_debug ("Cannot find event field for %s.%s\n" , - event_name, field_name); - ret = -ENOENT ; - goto out; - } +if (!strcmp (field_name,"*" )) { + field = evsel->tp_format->format.fields; - hde =__alloc_dynamic_entry (evsel, field); -if (hde ==NULL ) { - ret = -ENOMEM ; - goto out; - } - hde->raw_trace = raw_trace; +while (field) { + ret =__dynamic_dimension__add (evsel, field, raw_trace); +if (ret <0 ) + goto out; -perf_hpp__register_sort_field (&hde->hpp); + field = field->next; + } + }else { + field =pevent_find_any_field (evsel->tp_format, field_name); +if (field ==NULL ) { +pr_debug ("Cannot find event field for %s.%s\n" , + event_name, field_name); +return -ENOENT ; + } + + ret =__dynamic_dimension__add (evsel, field, raw_trace); + } out:free (str);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 12/59 perf tools: Skip dynamic fields not defined for current event
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
When there are multiple events, each dynamic sort key is defined just for one event. In this case other events will always show "N/A" for those fields. But they are meaningless and consume precious screen width.
Let's skip those undefined dynamic fields.
$ perf record -e kmem:kmalloc,kmem:kfree -a sleep 1
$ perf report -s 'comm,kmalloc.*' --stdio
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 20K of event 'kmem:kmalloc'
# Event count (approx.): 20533
#
# Overhead Command call_site ptr bytes_req bytes_alloc gfp_flags
# ........ ....... .................. .................. ......... ........... ...................
#
99.89% perf ffffffffa01d4396 0xffff8803ffb79720 96 96 GFP_NOFS|GFP_ZERO
0.06% sleep ffffffff8114e1cd 0xffff8803d228a000 4096 4096 GFP_KERNEL
0.03% perf ffffffff811d6ae6 0xffff8803f7678f00 240 256 GFP_KERNEL|GFP_ZERO
0.00% perf ffffffff812263c1 0xffff880406172380 128 128 GFP_KERNEL
0.00% perf ffffffff812264b9 0xffff8803ffac1600 504 512 GFP_KERNEL
0.00% perf ffffffff81226634 0xffff880401dc5280 28 32 GFP_KERNEL
0.00% sleep ffffffff81226da9 0xffff8803ffac3a00 392 512 GFP_KERNEL # Samples: 20K of event 'kmem:kfree'
# Event count (approx.): 20597
#
# Overhead Command
# ........ ..............
#
99.63% perf
0.14% sleep
0.11% irq/36-iwlwifi
0.11% kworker/u16:0
0.01% Xorg
0.00% firefox--- tools/perf/ui/browsers/hists.c | 7 ++++--- tools/perf/ui/gtk/hists.c | 4 ++-- tools/perf/ui/hist.c | 2 +- tools/perf/ui/stdio/hist.c | 6 +++--- tools/perf/util/hist.c | 2 +- tools/perf/util/hist.h | 14 ++++++++++++-- tools/perf/util/sort.c | 20 ++++++++++++++------ 7 files changed, 37 insertions(+), 18 deletions(-)
tools/perf/ui/browsers/hists.c +4 -3
@@ -1041,7 +1041,8 @@ static int hist_browser__show_entry(struct hist_browser *browser,hist_browser__gotorc (browser, row,0 );perf_hpp__for_each_format (fmt) { -if (perf_hpp__should_skip (fmt) || column++ < browser->b.horiz_scroll) +if (perf_hpp__should_skip (fmt, entry->hists) || + column++ < browser->b.horiz_scroll)continue ;if (current_entry && browser->b.navkeypressed) {
@@ -1144,7 +1145,7 @@ static int hists_browser__scnprintf_headers(struct hist_browser *browser, char * }perf_hpp__for_each_format (fmt) { -if (perf_hpp__should_skip (fmt) || column++ < browser->b.horiz_scroll) +if (perf_hpp__should_skip (fmt, hists) || column++ < browser->b.horiz_scroll)continue ; ret = fmt->header (fmt, &dummy_hpp,hists_to_evsel (hists));
@@ -1414,7 +1415,7 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser, printed +=fprintf (fp,"%c " , folded_sign);perf_hpp__for_each_format (fmt) { -if (perf_hpp__should_skip (fmt)) +if (perf_hpp__should_skip (fmt, he->hists))continue ;if (!first) {
tools/perf/ui/gtk/hists.c +2 -2
@@ -318,7 +318,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, col_idx =0 ;perf_hpp__for_each_format (fmt) { -if (perf_hpp__should_skip (fmt)) +if (perf_hpp__should_skip (fmt, hists))continue ;/*
@@ -368,7 +368,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, col_idx =0 ;perf_hpp__for_each_format (fmt) { -if (perf_hpp__should_skip (fmt)) +if (perf_hpp__should_skip (fmt, h->hists))continue ;if (fmt->color)
tools/perf/ui/hist.c +1 -1
@@ -619,7 +619,7 @@ unsigned int hists__sort_list_width(struct hists *hists)struct perf_hpp dummy_hpp;perf_hpp__for_each_format (fmt) { -if (perf_hpp__should_skip (fmt)) +if (perf_hpp__should_skip (fmt, hists))continue ;if (first)
tools/perf/ui/stdio/hist.c +3 -3
@@ -385,7 +385,7 @@ static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)return 0 ;perf_hpp__for_each_format (fmt) { -if (perf_hpp__should_skip (fmt)) +if (perf_hpp__should_skip (fmt, he->hists))continue ;/*
@@ -464,7 +464,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,fprintf (fp,"# " );perf_hpp__for_each_format (fmt) { -if (perf_hpp__should_skip (fmt)) +if (perf_hpp__should_skip (fmt, hists))continue ;if (!first)
@@ -490,7 +490,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,perf_hpp__for_each_format (fmt) {unsigned int i; -if (perf_hpp__should_skip (fmt)) +if (perf_hpp__should_skip (fmt, hists))continue ;if (!first)
tools/perf/util/hist.c +1 -1
@@ -1112,7 +1112,7 @@ static int hist_entry__sort(struct hist_entry *a, struct hist_entry *b)int64_t cmp =0 ;perf_hpp__for_each_sort_list (fmt) { -if (perf_hpp__should_skip (fmt)) +if (perf_hpp__should_skip (fmt, a->hists))continue ; cmp = fmt->sort (fmt, a, b);
tools/perf/util/hist.h +12 -2
@@ -262,10 +262,20 @@ void perf_hpp__append_sort_keys(void);bool perf_hpp__is_sort_entry (struct perf_hpp_fmt *format);bool perf_hpp__same_sort_entry (struct perf_hpp_fmt *a,struct perf_hpp_fmt *b); +bool perf_hpp__is_dynamic_entry (struct perf_hpp_fmt *format); +bool perf_hpp__defined_dynamic_entry (struct perf_hpp_fmt *fmt,struct hists *hists); -static inline bool perf_hpp__should_skip (struct perf_hpp_fmt *format) +static inline bool perf_hpp__should_skip (struct perf_hpp_fmt *format, +struct hists *hists) { -return format->elide; +if (format->elide) +return true; + +if (perf_hpp__is_dynamic_entry (format) && + !perf_hpp__defined_dynamic_entry (format, hists)) +return true; + +return false; }void perf_hpp__reset_width (struct perf_hpp_fmt *fmt,struct hists *hists);
tools/perf/util/sort.c +14 -6
@@ -1698,6 +1698,15 @@ static int __sort__hde_width(struct perf_hpp_fmt *fmt,return len; } +bool perf_hpp__defined_dynamic_entry (struct perf_hpp_fmt *fmt,struct hists *hists) +{ +struct hpp_dynamic_entry *hde; + + hde = container_of(fmt, struct hpp_dynamic_entry, hpp); + +return hists_to_evsel (hists) == hde->evsel; +} +static int __sort__hde_entry (struct perf_hpp_fmt *fmt,struct perf_hpp *hpp,struct hist_entry *he) {
@@ -1714,9 +1723,6 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,if (!len) len =hde_width (hde); -if (hists_to_evsel (he->hists) != hde->evsel) -return scnprintf (hpp->buf, hpp->size,"%*.*s" , len, len,"N/A" ); -if (hde->raw_trace) goto raw_field;
@@ -1769,9 +1775,6 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, hde = container_of(fmt, struct hpp_dynamic_entry, hpp); -if (hists_to_evsel (a->hists) != hde->evsel) -return 0 ; - field = hde->field;if (field->flags &FIELD_IS_DYNAMIC ) {unsigned long long dyn;
@@ -1794,6 +1797,11 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,return memcmp (a->raw_data + offset, b->raw_data + offset, size); } +bool perf_hpp__is_dynamic_entry (struct perf_hpp_fmt *fmt) +{ +return fmt->cmp == __sort__hde_cmp; +} +static struct hpp_dynamic_entry *__alloc_dynamic_entry (struct perf_evsel *evsel,struct format_field *field) {
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 13/59 perf tools: Add 'trace_fields' dynamic sort key
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
The 'trace_fields' sort key is similar as 'trace' sort key, but it shows each fields separately. Each event will get different columns as their fields.
$ perf report -s trace_fields --stdio
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 20K of event 'kmem:kmalloc'
# Event count (approx.): 20533
#
# Overhead Command call_site ptr bytes_req bytes_alloc gfp_flags
# ........ ....... .................. .................. ......... ........... ...................
#
99.89% perf ffffffffa01d4396 0xffff8803ffb79720 96 96 GFP_NOFS|GFP_ZERO
0.06% sleep ffffffff8114e1cd 0xffff8803d228a000 4096 4096 GFP_KERNEL
0.03% perf ffffffff811d6ae6 0xffff8803f7678f00 240 256 GFP_KERNEL|GFP_ZERO
0.00% perf ffffffff812263c1 0xffff880406172380 128 128 GFP_KERNEL
0.00% perf ffffffff812264b9 0xffff8803ffac1600 504 512 GFP_KERNEL
0.00% perf ffffffff81226634 0xffff880401dc5280 28 32 GFP_KERNEL
0.00% sleep ffffffff81226da9 0xffff8803ffac3a00 392 512 GFP_KERNEL # Samples: 20K of event 'kmem:kfree'
# Event count (approx.): 20597
#
# Overhead call_site ptr
# ........ .................. ..................
#
99.58% ffffffffa01d85ad 0xffff8803ffb79720
0.07% ffffffff81443f5c 0xffff8803f7669400
0.02% ffffffff811d5753 0xffff8803f7678f00
0.01% ffffffff81443f5c 0xffff8803f766be00
0.01% ffffffff8114e359 0xffff8803d228a000
0.01% ffffffff81443f5c 0xffff8800d156dc00
0.01% ffffffff81443f5c 0xffff8803f7669400
0.01% ffffffff8114e359 0xffff8803d228a000
0.01% ffffffff8114e359 0xffff8803d228a000
0.01% ffffffff8114e359 0xffff8803d228a000--- tools/perf/util/sort.c | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-)
tools/perf/util/sort.c +38 -9
@@ -1932,6 +1932,38 @@ static int __dynamic_dimension__add(struct perf_evsel *evsel,return 0 ; } +static int add_evsel_fields (struct perf_evsel *evsel,bool raw_trace) +{ +int ret; +struct format_field *field; + + field = evsel->tp_format->format.fields; +while (field) { + ret =__dynamic_dimension__add (evsel, field, raw_trace); +if (ret <0 ) +return ret; + + field = field->next; + } +return 0 ; +} + +static int add_all_dynamic_fields (struct perf_evlist *evlist,bool raw_trace) +{ +int ret; +struct perf_evsel *evsel; + +evlist__for_each (evlist, evsel) { +if (evsel->attr.type !=PERF_TYPE_TRACEPOINT ) +continue ; + + ret =add_evsel_fields (evsel, raw_trace); +if (ret <0 ) +return ret; + } +return 0 ; +} +static int add_dynamic_entry (struct perf_evlist *evlist,const char *tok) {char *str, *event_name, *field_name, *opt_name;
@@ -1961,6 +1993,11 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok) raw_trace = true; } +if (!strcmp (field_name,"trace_fields" )) { + ret =add_all_dynamic_fields (evlist, raw_trace); + goto out; + } + evsel =find_evsel (evlist, event_name);if (evsel ==NULL ) {pr_debug ("Cannot find event: %s\n" , event_name);
@@ -1975,15 +2012,7 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok) }if (!strcmp (field_name,"*" )) { - field = evsel->tp_format->format.fields; - -while (field) { - ret =__dynamic_dimension__add (evsel, field, raw_trace); -if (ret <0 ) - goto out; - - field = field->next; - } + ret =add_evsel_fields (evsel, raw_trace); }else { field =pevent_find_any_field (evsel->tp_format, field_name);if (field ==NULL ) {
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 14/59 perf tools: Make 'trace' or 'trace_fields' sort key default for tracepoint events
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
When an evlist contains tracepoint events only, use 'trace' sort key as default. If --raw-trace option was given, use 'trace_fields' instead. This will make users more convenient to see trace result.
--- tools/perf/util/sort.c | 30 +++++++++++++++++++++++++----- tools/perf/util/sort.h | 1 + 2 files changed, 26 insertions(+), 5 deletions(-)
tools/perf/util/sort.c +25 -5
@@ -15,6 +15,7 @@ const char default_branch_sort_order[] = "comm,dso_from,symbol_from,symbol_to,cyconst char default_mem_sort_order[] ="local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked" ;const char default_top_sort_order[] ="dso,symbol" ;const char default_diff_sort_order[] ="dso,symbol" ; +const char default_tracepoint_sort_order[] ="trace" ;const char *sort_order;const char *field_order;regex_t ignore_callees_regex;
@@ -2171,7 +2172,7 @@ static int sort_dimension__add(const char *tok,return -ESRCH ; } -static const char *get_default_sort_order (void ) +static const char *get_default_sort_order (struct perf_evlist *evlist) {const char *default_sort_orders[] = { default_sort_order,
@@ -2179,14 +2180,33 @@ static const char *get_default_sort_order(void) default_mem_sort_order, default_top_sort_order, default_diff_sort_order, + default_tracepoint_sort_order, }; +bool use_trace = true; +struct perf_evsel *evsel;BUG_ON (sort__mode >=ARRAY_SIZE (default_sort_orders)); +if (evlist ==NULL ) + goto out_no_evlist; + +evlist__for_each (evlist, evsel) { +if (evsel->attr.type !=PERF_TYPE_TRACEPOINT ) { + use_trace = false; +break ; + } + } + +if (use_trace) { + sort__mode =SORT_MODE__TRACEPOINT ; +if (symbol_conf.raw_trace) +return "trace_fields" ; + } +out_no_evlist:return default_sort_orders[sort__mode]; } -static int setup_sort_order (void ) +static int setup_sort_order (struct perf_evlist *evlist) {char *new_sort_order;
@@ -2207,7 +2227,7 @@ static int setup_sort_order(void)* because it's checked over the rest of the code. */ if (asprintf (&new_sort_order,"%s,%s" , -get_default_sort_order (), sort_order +1 ) <0 ) { +get_default_sort_order (evlist), sort_order +1 ) <0 ) {error ("Not enough memory to set up --sort" );return -ENOMEM ; }
@@ -2222,7 +2242,7 @@ static int __setup_sorting(struct perf_evlist *evlist)const char *sort_keys;int ret =0 ; - ret =setup_sort_order (); + ret =setup_sort_order (evlist);if (ret)return ret;
@@ -2236,7 +2256,7 @@ static int __setup_sorting(struct perf_evlist *evlist)return 0 ; } - sort_keys =get_default_sort_order (); + sort_keys =get_default_sort_order (evlist); } str =strdup (sort_keys);
tools/perf/util/sort.h +1 -0
@@ -167,6 +167,7 @@ enum sort_mode {SORT_MODE__MEMORY ,SORT_MODE__TOP ,SORT_MODE__DIFF , + SORT_MODE__TRACEPOINT, }; enum sort_type {
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 15/59 tools build feature: Fix feature_check_display_code typo
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
This function is cursed.. ;-)
--- tools/build/Makefile.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/Makefile.feature +1 -1
@@ -143,7 +143,7 @@ ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)") endif feature_display_check = $(eval $(feature_check_display_code)) -define feature_display_check_code +define feature_check_display_code ifneq ($(feature-$(1)), 1) feature_display := 1 endif
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 16/59 tools build feature: Move dwarf post unwind choice output into perf
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
We decide what dwarf unwind to choose way after the Makefile.feature makefile is included. The $(dwarf-post-unwind) is not even set at that time. For the same reason it was never included in FEATURE-DUMP file.
Moving it into perf VF=1 verbose display.
$ make VF=1
BUILD: Doing 'make -j4' parallel build
Auto-detecting system features:
... dwarf: [ on ]
...
... LIBUNWIND_DIR:
... LIBDW_DIR:
... DWARF post unwind library: libunwind
...--- tools/build/Makefile.feature | 9 --------- tools/perf/config/Makefile | 4 ++++ 2 files changed, 4 insertions(+), 9 deletions(-)
tools/build/Makefile.feature +0 -9
@@ -126,10 +126,6 @@ FEATURE_DUMP_FILENAME = $(OUTPUT)FEATURE-DUMP$(FEATURE_USER) FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat)))) FEATURE_DUMP_FILE := $(shell touch $(FEATURE_DUMP_FILENAME); cat $(FEATURE_DUMP_FILENAME)) -ifeq ($(dwarf-post-unwind),1) - FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text)) -endif - # The $(feature_display) controls the default detection message # output. It's set if: # - detected features differes from stored features from
@@ -160,11 +156,6 @@ ifeq ($(feature_display),1) $(info ) $(info Auto-detecting system features:) $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),)) - - ifeq ($(dwarf-post-unwind),1) - $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) - endif - ifneq ($(feature_verbose),1) $(info ) endif
tools/perf/config/Makefile +4 -0
@@ -751,6 +751,10 @@ ifeq ($(VF),1) $(call print_var,sysconfdir) $(call print_var,LIBUNWIND_DIR) $(call print_var,LIBDW_DIR) + + ifeq ($(dwarf-post-unwind),1) + $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) + endif $(info ) endif
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 17/59 tools build feature: Introduce feature_assign macro
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
The feature_assign macro generates feature value
assignment for name, like:
$(call feature_assign,dwarf) == feature-dwarf=1
This will be used more in following patches.
--- tools/build/Makefile.feature | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tools/build/Makefile.feature +7 -1
@@ -122,8 +122,14 @@ define feature_print_text_code MSG = $(shell printf '...%30s: %s' $(1) $(2)) endef +# +# generates feature value assignment for name, like: +# $(call feature_assign,dwarf) == feature-dwarf=1 +# +feature_assign = feature-$(1)=$(feature-$(1)) + FEATURE_DUMP_FILENAME = $(OUTPUT)FEATURE-DUMP$(FEATURE_USER) -FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat)))) +FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),$(call feature_assign,$(feat))) FEATURE_DUMP_FILE := $(shell touch $(FEATURE_DUMP_FILENAME); cat $(FEATURE_DUMP_FILENAME)) # The $(feature_display) controls the default detection message
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 18/59 tools build feature: Use value assignment form for FEATURE-DUMP file
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Changing the contents of the FEATURE-DUMP file, so it looks like:
feature-backtrace=1
feature-dwarf=0
feature-fortify-source=1
feature-sync-compare-and-swap=0
This way it could get included in sub projects, so they won't be forced to redo features detection.
Also now storing the complete set of features.
--- tools/build/Makefile.feature | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
tools/build/Makefile.feature +21 -5
@@ -129,8 +129,24 @@ endef feature_assign = feature-$(1)=$(feature-$(1)) FEATURE_DUMP_FILENAME = $(OUTPUT)FEATURE-DUMP$(FEATURE_USER) -FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),$(call feature_assign,$(feat))) -FEATURE_DUMP_FILE := $(shell touch $(FEATURE_DUMP_FILENAME); cat $(FEATURE_DUMP_FILENAME)) +FEATURE_DUMP := $(shell touch $(FEATURE_DUMP_FILENAME); cat $(FEATURE_DUMP_FILENAME)) + +feature_dump_check = $(eval $(feature_dump_check_code)) +define feature_dump_check_code + ifeq ($(findstring $(1),$(FEATURE_DUMP)),) + $(2) := 1 + endif +endef + +# +# First check if any test from FEATURE_DISPLAY +# and set feature_display := 1 if it does +$(foreach feat,$(FEATURE_DISPLAY),$(call feature_dump_check,$(call feature_assign,$(feat)),feature_display)) + +# +# Now also check if any other test changed, +# so we force FEATURE-DUMP generation +$(foreach feat,$(FEATURE_TESTS),$(call feature_dump_check,$(call feature_assign,$(feat)),feature_dump_changed)) # The $(feature_display) controls the default detection message # output. It's set if:
@@ -139,9 +155,9 @@ FEATURE_DUMP_FILE := $(shell touch $(FEATURE_DUMP_FILENAME); cat $(FEATURE_DUMP_ # - one of the $(FEATURE_DISPLAY) is not detected # - VF is enabled -ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)") - $(shell echo "$(FEATURE_DUMP)" > $(FEATURE_DUMP_FILENAME)) - feature_display := 1 +ifeq ($(feature_dump_changed),1) + $(shell rm -f $(FEATURE_DUMP_FILENAME)) + $(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME))) endif feature_display_check = $(eval $(feature_check_display_code))
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 19/59 perf build: Use FEATURE-DUMP in bpf subproject
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Using FEATURE-DUMP in bpf subproject for features detection in case bpf is built via perf. Keeping the current features detection otherwise.
--- tools/lib/bpf/Makefile | 4 ++++ tools/perf/Makefile.perf | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
tools/lib/bpf/Makefile +4 -0
@@ -80,7 +80,11 @@ endif endif ifeq ($(check_feat),1) +ifeq ($(FEATURES_DUMP),) include $(srctree)/tools/build/Makefile.feature +else +include $(FEATURES_DUMP) +endif endif export prefix libdir src obj
tools/perf/Makefile.perf +1 -1
@@ -436,7 +436,7 @@ $(LIBAPI)-clean: $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null $(LIBBPF): fixdep FORCE - $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a + $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(realpath $(OUTPUT)FEATURE-DUMP) $(LIBBPF)-clean: $(call QUIET_CLEAN, libbpf)
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 20/59 perf tools: Add all matching dynamic sort keys for field name
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
When a perf.data file has multiple events, it's likely to be similar (tracepoint) events. In that case, they might have same field name so add all of them to sort keys instead of bailing out.
--- tools/perf/util/sort.c | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-)
tools/perf/util/sort.c +32 -16
@@ -1863,10 +1863,9 @@ static int parse_field_name(char *str, char **event, char **field, char **opt) }/* find match evsel using a given event name. The event name can be: -* 1. NULL - only valid for single event session -* 2. '%' + event index (e.g. '%1' for first event) -* 3. full event name (e.g. sched:sched_switch) -* 4. partial event name (should not contain ':') +* 1. '%' + event index (e.g. '%1' for first event) +* 2. full event name (e.g. sched:sched_switch) +* 3. partial event name (should not contain ':') */ static struct perf_evsel *find_evsel (struct perf_evlist *evlist,char *event_name) {
@@ -1875,16 +1874,6 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nambool full_name;/* case 1 */ -if (event_name ==NULL ) { -if (evlist->nr_entries !=1 ) { -pr_debug ("event name should be given\n" ); -return NULL ; - } - -return perf_evlist__first (evlist); - } - -/* case 2 */ if (event_name[0 ] =='%' ) {int nr =strtol (event_name+1 ,NULL ,0 );
@@ -1900,10 +1889,10 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam full_name = !!strchr (event_name,':' );evlist__for_each (evlist, pos) { -/* case 3 */ +/* case 2 */ if (full_name && !strcmp (pos->name, event_name))return pos; -/* case 4 */ +/* case 3 */ if (!full_name &&strstr (pos->name, event_name)) {if (evsel) { pr_debug("'%s' event is ambiguous: it can be %s or %s\n",
@@ -1965,6 +1954,28 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)return 0 ; } +static int add_all_matching_fields (struct perf_evlist *evlist, +char *field_name,bool raw_trace) +{ +int ret = -ESRCH ; +struct perf_evsel *evsel; +struct format_field *field; + +evlist__for_each (evlist, evsel) { +if (evsel->attr.type !=PERF_TYPE_TRACEPOINT ) +continue ; + + field =pevent_find_any_field (evsel->tp_format, field_name); +if (field ==NULL ) +continue ; + + ret =__dynamic_dimension__add (evsel, field, raw_trace); +if (ret <0 ) +break ; + } +return ret; +} +static int add_dynamic_entry (struct perf_evlist *evlist,const char *tok) {char *str, *event_name, *field_name, *opt_name;
@@ -1999,6 +2010,11 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok) goto out; } +if (event_name ==NULL ) { + ret =add_all_matching_fields (evlist, field_name, raw_trace); + goto out; + } + evsel =find_evsel (evlist, event_name);if (evsel ==NULL ) {pr_debug ("Cannot find event: %s\n" , event_name);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 21/59 perf report: Add documentation for dynamic sort keys
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
--- tools/perf/Documentation/perf-report.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
tools/perf/Documentation/perf-report.txt +24 -0
@@ -117,6 +117,30 @@ OPTIONS And default sort keys are changed to comm, dso_from, symbol_from, dso_to and symbol_to, see '--branch-stack'. + If the data file has tracepoint event(s), following (dynamic) sort keys + are also available: + trace, trace_fields, [<event>.]<field>[/raw] + + - trace: pretty printed trace output in a single column + - trace_fields: fields in tracepoints in separate columns + - <field name>: optional event and field name for a specific field + + The last form consists of event and field names. If event name is + omitted, it searches all events for matching field name. The matched + field will be shown only for the event has the field. The event name + supports substring match so user doesn't need to specify full subsystem + and event name everytime. For example, 'sched:sched_switch' event can + be shortened to 'switch' as long as it's not ambiguous. Also event can + be specified by its index (starting from 1) preceded by the '%'. + So '%1' is the first event, '%2' is the second, and so on. + + The field name can have '/raw' suffix which disables pretty printing + and shows raw field value like hex numbers. The --raw-trace option + has the same effect for all dynamic sort keys. + + The default sort keys are changed to 'trace' if all events in the data + file are tracepoint. + -F:: --fields=:: Specify output field - multiple keys can be specified in CSV format.
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 22/59 perf stat record: Keep sample_type 0 for pipe session
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
For pipe sessions we need to keep sample_type zero, because script's perf_evsel__check_attr is triggered by sample_type != 0, and the check would fail on stat session.
I was tempted to keep it zero unconditionally, but the pipe session is sufficient. In perf.data session we are guarded by HEADER_STAT feature.
--- tools/perf/builtin-stat.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/perf/builtin-stat.c +8 -1
@@ -184,11 +184,18 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)* like tracepoints. Clear it up for counting. */ attr->sample_period =0 ; +/* * But set sample_type to PERF_SAMPLE_IDENTIFIER, which should be harmless * while avoiding that older tools show confusing messages. +* +* However for pipe sessions we need to keep it zero, +* because script's perf_evsel__check_attr is triggered +* by attr->sample_type != 0, and we can't run it on +* stat sessions. */ - attr->sample_type =PERF_SAMPLE_IDENTIFIER ; +if (!(STAT_RECORD && perf_stat.file.is_pipe)) + attr->sample_type =PERF_SAMPLE_IDENTIFIER ;/* * Disabling all counters initially, they will be enabled
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 23/59 perf script: Process cpu/threads maps
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding processing of cpu/threads maps. Configuring session's evlist with these maps.
--- tools/perf/builtin-script.c | 67 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
tools/perf/builtin-script.c +67 -0
@@ -18,7 +18,11 @@#include "util/sort.h" #include "util/data.h" #include "util/auxtrace.h" +#include "util/cpumap.h" +#include "util/thread_map.h" +#include "util/stat.h" #include <linux/bitmap.h> +#include "asm/bug.h" static char const *script_name;static char const *generate_script_lang;
@@ -606,6 +610,9 @@ struct perf_script {bool show_task_events;bool show_mmap_events;bool show_switch_events; +bool allocated; +struct cpu_map *cpus; +struct thread_map *threads; }; static void process_event(struct perf_script *script __maybe_unused, union perf_event *event,
@@ -1682,6 +1689,63 @@ static void script__setup_sample_type(struct perf_script *script) } } +static int set_maps (struct perf_script *script) +{ +struct perf_evlist *evlist = script->session->evlist; + +if (!script->cpus || !script->threads) +return 0 ; + +if (WARN_ONCE (script->allocated,"stats double allocation\n" )) +return -EINVAL ; + +perf_evlist__set_maps (evlist, script->cpus, script->threads); + +if (perf_evlist__alloc_stats (evlist, true)) +return -ENOMEM ; + + script->allocated = true; +return 0 ; +} + +static +int process_thread_map_event (struct perf_tool *tool, +union perf_event *event, +struct perf_session *session__maybe_unused ) +{ + struct perf_script *script = container_of(tool, struct perf_script, tool); + +if (script->threads) { +pr_warning ("Extra thread map event, ignoring.\n" ); +return 0 ; + } + + script->threads =thread_map__new_event (&event->thread_map); +if (!script->threads) +return -ENOMEM ; + +return set_maps (script); +} + +static +int process_cpu_map_event (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_session *session__maybe_unused ) +{ + struct perf_script *script = container_of(tool, struct perf_script, tool); + +if (script->cpus) { +pr_warning ("Extra cpu map event, ignoring.\n" ); +return 0 ; + } + + script->cpus =cpu_map__new_data (&event->cpu_map.data); +if (!script->cpus) +return -ENOMEM ; + +return set_maps (script); +} +int cmd_script (int argc,const char **argv,const char *prefix__maybe_unused ) {bool show_full_info = false;
@@ -1710,6 +1774,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) .auxtrace_info = perf_event__process_auxtrace_info, .auxtrace = perf_event__process_auxtrace, .auxtrace_error = perf_event__process_auxtrace_error, + .thread_map = process_thread_map_event, + .cpu_map = process_cpu_map_event, .ordered_events = true, .ordering_requires_timestamps = true, },
@@ -2063,6 +2129,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)flush_scripting (); out_delete: +perf_evlist__free_stats (session->evlist);perf_session__delete (session);if (script_started)
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 24/59 perf script: Process stat config event
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding processing of stat config event and initialize stat_config object.
--- tools/perf/builtin-script.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
tools/perf/builtin-script.c +10 -0
@@ -36,6 +36,7 @@ static bool print_flags;static bool nanosecs;static const char *cpu_list; static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); +static struct perf_stat_config stat_config;unsigned int scripting_max_stack =PERF_MAX_STACK_DEPTH ;
@@ -1689,6 +1690,14 @@ static void script__setup_sample_type(struct perf_script *script) } } +static int process_stat_config_event (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_session *session__maybe_unused ) +{ +perf_event__read_stat_config (&stat_config, &event->stat_config); +return 0 ; +} +static int set_maps (struct perf_script *script) {struct perf_evlist *evlist = script->session->evlist;
@@ -1774,6 +1783,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) .auxtrace_info = perf_event__process_auxtrace_info, .auxtrace = perf_event__process_auxtrace, .auxtrace_error = perf_event__process_auxtrace_error, + .stat_config = process_stat_config_event, .thread_map = process_thread_map_event, .cpu_map = process_cpu_map_event, .ordered_events = true,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 25/59 perf script: Add process_stat/process_stat_interval scripting interface
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Python and perl scripting code will define those callbacks and get stat data.
--- tools/perf/util/trace-event.h | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/util/trace-event.h +4 -0
@@ -65,6 +65,7 @@ int tracing_data_put(struct tracing_data *tdata);struct addr_location ;struct perf_session ; +struct perf_stat_config ;struct scripting_ops {const char *name;
@@ -75,6 +76,9 @@ struct scripting_ops {struct perf_sample *sample, struct perf_evsel *evsel, struct addr_location *al); +void (*process_stat)(struct perf_stat_config *config, +struct perf_evsel *evsel,u64 tstamp); +void (*process_stat_interval)(u64 tstamp);int (*generate_script) (struct pevent *pevent,const char *outfile); };
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 26/59 perf script: Add stat default handlers
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Implement struct scripting_ops::(process_stat|process_stat_interval) handlers - calling scripting handlers from stat events handlers.
--- tools/perf/builtin-script.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
tools/perf/builtin-script.c +33 -0
@@ -221,6 +221,9 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,struct perf_event_attr *attr = &evsel->attr;bool allow_user_set; +if (perf_header__has_feat (&session->header,HEADER_STAT )) +return 0 ; + allow_user_set =perf_header__has_feat (&session->header,HEADER_AUXTRACE );
@@ -674,6 +677,18 @@ static void process_event(struct perf_script *script __maybe_unused, union perf_static struct scripting_ops *scripting_ops; +static void process_stat (struct perf_evsel *counter,u64 tstamp) +{ +if (scripting_ops && scripting_ops->process_stat) + scripting_ops->process_stat (&stat_config, counter, tstamp); +} + +static void process_stat_interval (u64 tstamp) +{ +if (scripting_ops && scripting_ops->process_stat_interval) + scripting_ops->process_stat_interval (tstamp); +} +static void setup_scripting (void ) {setup_perl_scripting ();
@@ -1690,6 +1705,22 @@ static void script__setup_sample_type(struct perf_script *script) } } +static int process_stat_round_event (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_session *session) +{ +struct stat_round_event *round = &event->stat_round; +struct perf_evsel *counter; + +evlist__for_each (session->evlist, counter) { +perf_stat_process_counter (&stat_config, counter); +process_stat (counter, round->time); + } + +process_stat_interval (round->time); +return 0 ; +} +static int process_stat_config_event (struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_session *session__maybe_unused )
@@ -1783,6 +1814,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) .auxtrace_info = perf_event__process_auxtrace_info, .auxtrace = perf_event__process_auxtrace, .auxtrace_error = perf_event__process_auxtrace_error, + .stat = perf_event__process_stat_event, + .stat_round = process_stat_round_event, .stat_config = process_stat_config_event, .thread_map = process_thread_map_event, .cpu_map = process_cpu_map_event,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 27/59 perf script: Add python support for stat events
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Add support to get stat events data in perf python scripts.
The python script shall implement the following new interface to process stat data:
def stat__<event_name>_[<modifier>](cpu, thread, time, val, ena, run):
- is called for every stat event for given counter, if user monitors 'cycles,instructions:u" following callbacks should be defined:
def stat__cycles(cpu, thread, time, val, ena, run):
def stat__instructions_u(cpu, thread, time, val, ena, run):
def stat__interval(time):
- is called for every interval with its time,
in non interval mode it's called after last
stat event with total measured time in ns
The rest of the current interface stays untouched..
Please check example CPI metrics script in following patch with command line examples in changelogs.
--- .../util/scripting-engines/trace-event-python.c | 115 +++++++++++++++++++-- 1 file changed, 109 insertions(+), 6 deletions(-)
tools/perf/util/scripting-engines/trace-event-python.c +109 -6
@@ -41,6 +41,9 @@#include "../thread-stack.h" #include "../trace-event.h" #include "../machine.h" +#include "thread_map.h" +#include "cpumap.h" +#include "stat.h" PyMODINIT_FUNC initperf_trace_context (void );
@@ -859,6 +862,104 @@ static void python_process_event(union perf_event *event, } } +static void get_handler_name (char *str,size_t size, +struct perf_evsel *evsel) +{ +char *p = str; + +scnprintf (str, size,"stat__%s" ,perf_evsel__name (evsel)); + +while ((p =strchr (p,':' ))) { + *p ='_' ; + p++; + } +} + +static void +process_stat (struct perf_evsel *counter,int cpu,int thread,u64 tstamp, +struct perf_counts_values *count) +{ +PyObject *handler, *t; +static char handler_name[256 ]; +int n =0 ; + + t =PyTuple_New (MAX_FIELDS ); +if (!t) +Py_FatalError ("couldn't create Python tuple" ); + +get_handler_name (handler_name,sizeof (handler_name), + counter); + + handler =get_handler (handler_name); +if (!handler) { +pr_debug ("can't find python handler %s\n" , handler_name); +return ; + } + +PyTuple_SetItem (t, n++,PyInt_FromLong (cpu)); +PyTuple_SetItem (t, n++,PyInt_FromLong (thread)); + +tuple_set_u64 (t, n++, tstamp); +tuple_set_u64 (t, n++, count->val); +tuple_set_u64 (t, n++, count->ena); +tuple_set_u64 (t, n++, count->run); + +if (_PyTuple_Resize (&t, n) ==-1 ) +Py_FatalError ("error resizing Python tuple" ); + +call_object (handler, t, handler_name); + +Py_DECREF (t); +} + +static void python_process_stat (struct perf_stat_config *config, +struct perf_evsel *counter,u64 tstamp) +{ +struct thread_map *threads = counter->threads; +struct cpu_map *cpus = counter->cpus; +int cpu, thread; + +if (config->aggr_mode ==AGGR_GLOBAL ) { +process_stat (counter,-1 ,-1 , tstamp, + &counter->counts->aggr); +return ; + } + +for (thread =0 ; thread < threads->nr; thread++) { +for (cpu =0 ; cpu < cpus->nr; cpu++) { +process_stat (counter, cpus->map[cpu], +thread_map__pid (threads, thread), tstamp, +perf_counts (counter->counts, cpu, thread)); + } + } +} + +static void python_process_stat_interval (u64 tstamp) +{ +PyObject *handler, *t; +static const char handler_name[] ="stat__interval" ; +int n =0 ; + + t =PyTuple_New (MAX_FIELDS ); +if (!t) +Py_FatalError ("couldn't create Python tuple" ); + + handler =get_handler (handler_name); +if (!handler) { +pr_debug ("can't find python handler %s\n" , handler_name); +return ; + } + +tuple_set_u64 (t, n++, tstamp); + +if (_PyTuple_Resize (&t, n) ==-1 ) +Py_FatalError ("error resizing Python tuple" ); + +call_object (handler, t, handler_name); + +Py_DECREF (t); +} +static int run_start_sub (void ) { main_module =PyImport_AddModule ("__main__" );
@@ -1201,10 +1302,12 @@ static int python_generate_script(struct pevent *pevent, const char *outfile) }struct scripting_ops python_scripting_ops = { - .name ="Python" , - .start_script = python_start_script, - .flush_script = python_flush_script, - .stop_script = python_stop_script, - .process_event = python_process_event, - .generate_script = python_generate_script, + .name ="Python" , + .start_script = python_start_script, + .flush_script = python_flush_script, + .stop_script = python_stop_script, + .process_event = python_process_event, + .process_stat = python_process_stat, + .process_stat_interval = python_process_stat_interval, + .generate_script = python_generate_script, };
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 28/59 perf cpumap: Fix cpu conversion in cpu_map__from_entries
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
We can't convert u16 cpu_map_entries::cpu[x] value directly to int, because it could hold -1, which would be converted as 65535.
Adding special treatment for -1, which is not real cpu number, to be converted to (int -1).
--- tools/perf/util/cpumap.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tools/perf/util/cpumap.c +11 -2
@@ -188,8 +188,17 @@ static struct cpu_map *cpu_map__from_entries(struct cpu_map_entries *cpus)if (map) {unsigned i; -for (i =0 ; i < cpus->nr; i++) - map->map[i] = (int )cpus->cpu[i]; +for (i =0 ; i < cpus->nr; i++) { +/* +* Special treatment for -1, which is not real cpu number, +* and we need to use (int) -1 to initialize map[i], +* otherwise it would become 65535. +*/ +if (cpus->cpu[i] == (u16) -1 ) + map->map[i] =-1 ; +else + map->map[i] = (int ) cpus->cpu[i]; + } }return map;
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 29/59 perf script: Display stat events by default
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
If no script is specified for stat data, display stat events in raw form.
$ perf stat record ls
SNIP
Performance counter stats for 'ls':
0.851585 task-clock (msec) # 0.717 CPUs utilized
0 context-switches # 0.000 K/sec
0 cpu-migrations # 0.000 K/sec
114 page-faults # 0.134 M/sec
2,620,918 cycles # 3.078 GHz
<not supported> stalled-cycles-frontend
<not supported> stalled-cycles-backend
2,714,111 instructions # 1.04 insns per cycle
542,434 branches # 636.970 M/sec
15,946 branch-misses # 2.94% of all branches0.001186954 seconds time elapsed
$ perf script CPU THREAD VAL ENA RUN TIME EVENT -1 26185 851585 851585 851585 1186954 task-clock -1 26185 0 851585 851585 1186954 context-switches -1 26185 0 851585 851585 1186954 cpu-migrations -1 26185 114 851585 851585 1186954 page-faults -1 26185 2620918 853340 853340 1186954 cycles -1 26185 0 0 0 1186954 stalled-cycles-frontend -1 26185 0 0 0 1186954 stalled-cycles-backend -1 26185 2714111 853340 853340 1186954 instructions -1 26185 542434 853340 853340 1186954 branches -1 26185 15946 853340 853340 1186954 branch-misses
--- tools/perf/builtin-script.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
tools/perf/builtin-script.c +36 -0
@@ -677,10 +677,46 @@ static void process_event(struct perf_script *script __maybe_unused, union perf_static struct scripting_ops *scripting_ops; +static void __process_stat (struct perf_evsel *counter,u64 tstamp) +{ +int nthreads =thread_map__nr (counter->threads); +int ncpus =perf_evsel__nr_cpus (counter); +int cpu, thread; +static int header_printed; + +if (counter->system_wide) + nthreads =1 ; + +if (!header_printed) { +printf ("%3s %8s %15s %15s %15s %15s %s\n" , +"CPU" ,"THREAD" ,"VAL" ,"ENA" ,"RUN" ,"TIME" ,"EVENT" ); + header_printed =1 ; + } + +for (thread =0 ; thread < nthreads; thread++) { +for (cpu =0 ; cpu < ncpus; cpu++) { +struct perf_counts_values *counts; + + counts =perf_counts (counter->counts, cpu, thread); + +printf ("%3d %8d %15" PRIu64" %15" PRIu64" %15" PRIu64" %15" PRIu64" %s\n" , + counter->cpus->map[cpu], +thread_map__pid (counter->threads, thread), + counts->val, + counts->ena, + counts->run, + tstamp, +perf_evsel__name (counter)); + } + } +} +static void process_stat (struct perf_evsel *counter,u64 tstamp) {if (scripting_ops && scripting_ops->process_stat) scripting_ops->process_stat (&stat_config, counter, tstamp); +else +__process_stat (counter, tstamp); }static void process_stat_interval (u64 tstamp)
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 30/59 perf script: Add stat-cpi.py script
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding stat-cpi.py as an example of how to do stat scripting.
It computes the CPI metrics from cycles and instructions events.
The CPI is based performance metric showing the Cycles Per Instructions ratio, which helps to identify cycles-hungry code.
Following stat record/report/script combinations could be used:
- get CPI for given workload
$ perf stat -e cycles,instructions record ls
SNIP
Performance counter stats for 'ls':
2,904,431 cycles
3,346,878 instructions # 1.15 insns per cycle
0.001782686 seconds time elapsed
$ perf script -s ./scripts/python/stat-cpi.py
0.001783: cpu -1, thread -1 -> cpi 0.867803 (2904431/3346878)
$ perf stat -e cycles,instructions record ls | perf script -s ./scripts/python/stat-cpi.py
SNIP
0.001730: cpu -1, thread -1 -> cpi 0.869026 (2928292/3369627)
- get CPI systemwide:
$ perf stat -e cycles,instructions -a -I 1000 record sleep 3
# time counts unit events
1.000158618 594,274,711 cycles (100.00%)
1.000158618 441,898,250 instructions
2.000350973 567,649,705 cycles (100.00%)
2.000350973 432,669,206 instructions
3.000559210 561,940,430 cycles (100.00%)
3.000559210 420,403,465 instructions
3.000670798 780,105 cycles (100.00%)
3.000670798 326,516 instructions $ perf script -s ./scripts/python/stat-cpi.py
1.000159: cpu -1, thread -1 -> cpi 1.344823 (594274711/441898250)
2.000351: cpu -1, thread -1 -> cpi 1.311972 (567649705/432669206)
3.000559: cpu -1, thread -1 -> cpi 1.336669 (561940430/420403465)
3.000671: cpu -1, thread -1 -> cpi 2.389178 (780105/326516) $ perf stat -e cycles,instructions -a -I 1000 record sleep 3 | perf script -s ./scripts/python/stat-cpi.py
1.000202: cpu -1, thread -1 -> cpi 1.035091 (940778881/908885530)
2.000392: cpu -1, thread -1 -> cpi 1.442600 (627493992/434974455)
3.000545: cpu -1, thread -1 -> cpi 1.353612 (741463930/547766890)
3.000622: cpu -1, thread -1 -> cpi 2.642110 (784083/296764)--- tools/perf/scripts/python/stat-cpi.py | 77 +++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 tools/perf/scripts/python/stat-cpi.py
tools/perf/scripts/python/stat-cpi.py new file +77 -0
@@ -0,0 +1,77 @@ +#!/usr/bin/env python + +data = {} +times = [] +threads = [] +cpus = [] + +def get_key(time, event, cpu, thread): + return "%d-%s-%d-%d" % (time, event, cpu, thread) + +def store_key(time, cpu, thread): + if (time not in times): + times.append(time) + + if (cpu not in cpus): + cpus.append(cpu) + + if (thread not in threads): + threads.append(thread) + +def store(time, event, cpu, thread, val, ena, run): + #print "event %s cpu %d, thread %d, time %d, val %d, ena %d, run %d" % \ + # (event, cpu, thread, time, val, ena, run) + + store_key(time, cpu, thread) + key = get_key(time, event, cpu, thread) + data[key] = [ val, ena, run] + +def get(time, event, cpu, thread): + key = get_key(time, event, cpu, thread) + return data[key][0] + +def stat__cycles_k(cpu, thread, time, val, ena, run): + store(time, "cycles", cpu, thread, val, ena, run); + +def stat__instructions_k(cpu, thread, time, val, ena, run): + store(time, "instructions", cpu, thread, val, ena, run); + +def stat__cycles_u(cpu, thread, time, val, ena, run): + store(time, "cycles", cpu, thread, val, ena, run); + +def stat__instructions_u(cpu, thread, time, val, ena, run): + store(time, "instructions", cpu, thread, val, ena, run); + +def stat__cycles(cpu, thread, time, val, ena, run): + store(time, "cycles", cpu, thread, val, ena, run); + +def stat__instructions(cpu, thread, time, val, ena, run): + store(time, "instructions", cpu, thread, val, ena, run); + +def stat__interval(time): + for cpu in cpus: + for thread in threads: + cyc = get(time, "cycles", cpu, thread) + ins = get(time, "instructions", cpu, thread) + cpi = 0 + + if ins != 0: + cpi = cyc/float(ins) + + print "%15f: cpu %d, thread %d -> cpi %f (%d/%d)" % (time/(float(1000000000)), cpu, thread, cpi, cyc, ins) + +def trace_end(): + pass +# XXX trace_end callback could be used as an alternative place +# to compute same values as in the script above: +# +# for time in times: +# for cpu in cpus: +# for thread in threads: +# cyc = get(time, "cycles", cpu, thread) +# ins = get(time, "instructions", cpu, thread) +# +# if ins != 0: +# cpi = cyc/float(ins) +# +# print "time %.9f, cpu %d, thread %d -> cpi %f" % (time/(float(1000000000)), cpu, thread, cpi)
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 31/59 perf pmu: fix alias->snapshot missing initialization bug
In reply to Arnaldo Carvalho de MeloFrom: Stephane Eranian <[email protected]>
This patch fixes a bug in __perf_pmu__new_alias() whereby the alias->snapshot field was not initialized to false. This led to random alias->snapshot value for an alias and was breaking some measurements such as:
$ perf stat -a -e uncore_imc/data_reads/ -I 1000 sleep 100
Because the event ended up being treated as snapshot mode, when it is not.
--- tools/perf/util/pmu.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/pmu.c +1 -0
@@ -220,6 +220,7 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, alias->scale =1.0 ; alias->unit[0 ] ='\0' ; alias->per_pkg = false; + alias->snapshot = false; ret =parse_events_terms (&alias->terms, val);if (ret) {
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 32/59 perf tests: No need to set attr.sample_freq in the perf time to TSC test
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We were asking for a 4kHz sample_freq, making the test fail needlessly when the system reduced /proc/sys/kernel/perf_event_max_sample_rate below that.
In this test we only look at the PERF_SAMPLE_TIME fields in PERF_RECORD_ meta events, no need to set sample_freq.
Thanks to Namhyung for suggesting that max_sample_rate could be the reason for the test failure, seeing the 'perf test -vv' output I sent.
Before:
# echo 1000 > /proc/sys/kernel/perf_event_max_sample_rate # perf test TSC 45: Test converting perf time to TSC : FAILED!
After:
# perf test TSC 45: Test converting perf time to TSC : Ok # cat /proc/sys/kernel/perf_event_max_sample_rate 1000
--- tools/perf/arch/x86/tests/perf-time-to-tsc.c | 1 - 1 file changed, 1 deletion(-)
tools/perf/arch/x86/tests/perf-time-to-tsc.c +0 -1
@@ -41,7 +41,6 @@ int test__perf_time_to_tsc(int subtest __maybe_unused) .mmap_pages = UINT_MAX, .user_freq = UINT_MAX, .user_interval = ULLONG_MAX, - .freq = 4000, .target = { .uses_mmap = true, },
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 33/59 perf evlist: Introduce perf_evlist__new_dummy constructor
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
For case where all we need is an evlist with just an "dummy" evsel, like in some 'perf test' entries.
--- tools/perf/util/evlist.c | 28 ++++++++++++++++++++++++++++ tools/perf/util/evlist.h | 3 +++ 2 files changed, 31 insertions(+)
tools/perf/util/evlist.c +28 -0
@@ -68,6 +68,18 @@ struct perf_evlist *perf_evlist__new_default(void)return evlist; } +struct perf_evlist *perf_evlist__new_dummy (void ) +{ +struct perf_evlist *evlist =perf_evlist__new (); + +if (evlist &&perf_evlist__add_dummy (evlist)) { +perf_evlist__delete (evlist); + evlist =NULL ; + } + +return evlist; +} +/** * perf_evlist__set_id_pos - set the positions of event ids. * @evlist: selected event list
@@ -248,6 +260,22 @@ error:return -ENOMEM ; } +int perf_evlist__add_dummy (struct perf_evlist *evlist) +{ +struct perf_event_attr attr = { + .type =PERF_TYPE_SOFTWARE , + .config =PERF_COUNT_SW_DUMMY , + .size =sizeof (attr),/* to capture ABI version */ + }; +struct perf_evsel *evsel =perf_evsel__new (&attr); + +if (evsel ==NULL ) +return -ENOMEM ; + +perf_evlist__add (evlist, evsel); +return 0 ; +} +static int perf_evlist__add_attrs (struct perf_evlist *evlist,struct perf_event_attr *attrs,size_t nr_attrs) {
tools/perf/util/evlist.h +3 -0
@@ -67,6 +67,7 @@ struct perf_evsel_str_handler {struct perf_evlist *perf_evlist__new (void );struct perf_evlist *perf_evlist__new_default (void ); +struct perf_evlist *perf_evlist__new_dummy (void );void perf_evlist__init (struct perf_evlist *evlist,struct cpu_map *cpus,struct thread_map *threads);void perf_evlist__exit (struct perf_evlist *evlist);
@@ -81,6 +82,8 @@ int __perf_evlist__add_default_attrs(struct perf_evlist *evlist,#define perf_evlist__add_default_attrs (evlist, array) \ __perf_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array)) +int perf_evlist__add_dummy (struct perf_evlist *evlist); +int perf_evlist__add_newtp (struct perf_evlist *evlist,const char *sys,const char *name,void *handler);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 34/59 perf test: Use "dummy" events in the PERF_RECORD_ test
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
As we're test just the !PERF_RECORD_SAMPLE records.
--- tools/perf/tests/perf-record.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/tests/perf-record.c +4 -1
@@ -45,7 +45,7 @@ int test__PERF_RECORD(int subtest __maybe_unused) };cpu_set_t cpu_mask;size_t cpu_mask_size =sizeof (cpu_mask); -struct perf_evlist *evlist =perf_evlist__new_default (); +struct perf_evlist *evlist =perf_evlist__new_dummy ();struct perf_evsel *evsel;struct perf_sample sample;const char *cmd ="sleep" ;
@@ -61,6 +61,9 @@ int test__PERF_RECORD(int subtest __maybe_unused)int total_events =0 , nr_events[PERF_RECORD_MAX ] = {0 , };char sbuf[STRERR_BUFSIZE ]; +if (evlist ==NULL )/* Fallback for kernels lacking PERF_COUNT_SW_DUMMY */ + evlist =perf_evlist__new_default (); +if (evlist ==NULL || argv ==NULL ) {pr_debug ("Not enough memory to create evlist\n" ); goto out;
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 35/59 perf test: No need for setting attr.sample_freq on the RECORD test
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We're not looking at PERF_RECORD_SAMPLE entries and now by default we use PERF_COUNT_SW_DUMMY, so just remove that setting.
--- tools/perf/tests/perf-record.c | 1 - 1 file changed, 1 deletion(-)
tools/perf/tests/perf-record.c +0 -1
@@ -40,7 +40,6 @@ int test__PERF_RECORD(int subtest __maybe_unused) .uses_mmap = true, }, .no_buffering = true, - .freq = 10, .mmap_pages = 256, };cpu_set_t cpu_mask;
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 36/59 perf python: Add missing files to binding link list
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Fixing this problem, introduced recently:
$ perf test python 16: Try 'import perf' in python, checking link problems : FAILED!
In verbose mode we find out what is missing:
$ perf test -v python
16: Try 'import perf' in python, checking link problems :
--- start ---
test child forked, pid 24894
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /tmp/build/perf/python/perf.so: undefined symbol: find_next_bit
test child finished with -1
---- end ----
Try 'import perf' in python, checking link problems: FAILED!
$--- tools/perf/util/python-ext-sources | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/python-ext-sources +2 -0
@@ -10,6 +10,8 @@ util/ctype.c util/evlist.c util/evsel.c util/cpumap.c +util/bitmap.c +../lib/util/find_next_bit.c ../lib/hweight.c util/thread_map.c util/util.c
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 37/59 perf tests: No need to set attr.sample_freq for tracking !PERF_RECORD_SAMPLE
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We were asking for a 4kHz sample_freq, making the test fail needlessly when the system reduced /proc/sys/kernel/perf_event_max_sample_rate below that.
Before:
# perf test -vv dummy
23: Test using a dummy software event to keep tracking :
--- start ---
test child forked, pid 32421
------------------------------------------------------------
perf_event_attr:
type 1
size 112
config 0x9
{ sample_period, sample_freq } 4000
sample_type IP|TID|ID|PERIOD
<SNIP>
sys_perf_event_open failed, error -22
Unable to open dummy and cycles event
test child finished with -2
---- end ----
Test using a dummy software event to keep tracking: Skip
#
[root@zoo ~]# cat /proc/sys/kernel/perf_event_max_sample_rate
1000After:
[root@zoo ~]# perf test dummy
23: Test using a dummy software event to keep tracking : Ok
--- tools/perf/tests/keep-tracking.c | 1 - 1 file changed, 1 deletion(-)
tools/perf/tests/keep-tracking.c +0 -1
@@ -55,7 +55,6 @@ int test__keep_tracking(int subtest __maybe_unused) .mmap_pages = UINT_MAX, .user_freq = UINT_MAX, .user_interval = ULLONG_MAX, - .freq = 4000, .target = { .uses_mmap = true, },
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 38/59 perf tests: Give a bit more information on the CQM test failure path
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Before:
$ perf test -v cqm 48: Test intel cqm nmi context read : --- start --- test child forked, pid 1681 parse_events failed test child finished with -2 ---- end ---- Test intel cqm nmi context read: Skip $
After:
$ perf test -v cqm 48: Test intel cqm nmi context read : --- start --- test child forked, pid 1681 parse_events failed, is "intel_cqm/llc_occupancy/" available? test child finished with -2 ---- end ---- Test intel cqm nmi context read: Skip $
--- tools/perf/arch/x86/tests/intel-cqm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/arch/x86/tests/intel-cqm.c +1 -1
@@ -54,7 +54,7 @@ int test__intel_cqm_count_nmi_context(int subtest __maybe_unused) ret =parse_events (evlist,"intel_cqm/llc_occupancy/" ,NULL );if (ret) { -pr_debug ("parse_events failed\n" ); +pr_debug ("parse_events failed, is \"intel_cqm/llc_occupancy/\" available?\n" ); err =TEST_SKIP ; goto out; }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 39/59 tools lib: Move find_next_bit.c to tools/lib/
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
The commit that introduced it should've moved it to the same place, plus the 'tools/' prefix, but instead moved it to a bogus tools/lib/util/ directory, being the only file there.
Move it to tools/lib/find_bit.c, picking the name for the file where these routines live since:
8f6f19dd5143 ("lib: move find_last_bit to lib/find_next_bit.c")
Next step is to make tools/lib/find_bit.c to differ from lib/find_bit.c just in removing what is not used by tools/.
--- tools/lib/find_bit.c | 89 ++++++++++++++++++++++++++++++++++++++ tools/lib/util/find_next_bit.c | 89 -------------------------------------- tools/perf/MANIFEST | 2 +- tools/perf/util/Build | 6 +-- tools/perf/util/python-ext-sources | 2 +- 5 files changed, 94 insertions(+), 94 deletions(-) create mode 100644 tools/lib/find_bit.c delete mode 100644 tools/lib/util/find_next_bit.c
tools/lib/find_bit.c new file +89 -0
@@ -0,0 +1,89 @@ +/* find_next_bit.c: fallback find next bit implementation +* +* Copied from lib/find_next_bit.c to tools/lib/find_bit.c +* +* Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. +* Written by David Howells ([email protected]) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#include <linux/bitops.h> +#include <asm/types.h> +#include <asm/byteorder.h> + +#define BITOP_WORD (nr) ((nr) / BITS_PER_LONG) + +#ifndef find_next_bit +/* +* Find the next set bit in a memory region. +*/ +unsigned long find_next_bit (const unsigned long *addr,unsigned long size, +unsigned long offset) +{ +const unsigned long *p = addr +BITOP_WORD (offset); +unsigned long result = offset & ~(BITS_PER_LONG -1 ); +unsigned long tmp; + +if (offset >= size) +return size; + size -= result; + offset %=BITS_PER_LONG ; +if (offset) { + tmp = *(p++); + tmp &= (~0UL << offset); +if (size <BITS_PER_LONG ) + goto found_first; +if (tmp) + goto found_middle; + size -=BITS_PER_LONG ; + result +=BITS_PER_LONG ; + } +while (size & ~(BITS_PER_LONG -1 )) { +if ((tmp = *(p++))) + goto found_middle; + result +=BITS_PER_LONG ; + size -=BITS_PER_LONG ; + } +if (!size) +return result; + tmp = *p; + +found_first: + tmp &= (~0UL >> (BITS_PER_LONG - size)); +if (tmp ==0UL )/* Are any bits set? */ +return result + size;/* Nope. */ +found_middle: +return result +__ffs (tmp); +} +#endif + +#ifndef find_first_bit +/* +* Find the first set bit in a memory region. +*/ +unsigned long find_first_bit (const unsigned long *addr,unsigned long size) +{ +const unsigned long *p = addr; +unsigned long result =0 ; +unsigned long tmp; + +while (size & ~(BITS_PER_LONG -1 )) { +if ((tmp = *(p++))) + goto found; + result +=BITS_PER_LONG ; + size -=BITS_PER_LONG ; + } +if (!size) +return result; + + tmp = (*p) & (~0UL >> (BITS_PER_LONG - size)); +if (tmp ==0UL )/* Are any bits set? */ +return result + size;/* Nope. */ +found: +return result +__ffs (tmp); +} +#endif
tools/lib/util/find_next_bit.c deleted +0 -89
89 lines not on this page · raw message
tools/perf/MANIFEST +1 -1
@@ -26,7 +26,7 @@ tools/lib/rbtree.c tools/lib/string.c tools/lib/symbol/kallsyms.c tools/lib/symbol/kallsyms.h -tools/lib/util/find_next_bit.c +tools/lib/find_bit.c tools/include/asm/atomic.h tools/include/asm/barrier.h tools/include/asm/bug.h
tools/perf/util/Build +3 -3
@@ -9,7 +9,7 @@ libperf-y += env.o libperf-y += event.o libperf-y += evlist.o libperf-y += evsel.o -libperf-y += find_next_bit.o +libperf-y += find_bit.o libperf-y += kallsyms.o libperf-y += levenshtein.o libperf-y += llvm-utils.o
@@ -132,7 +132,7 @@ CFLAGS_pmu-bison.o += -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c -CFLAGS_find_next_bit.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" +CFLAGS_find_bit.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" CFLAGS_rbtree.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" CFLAGS_libstring.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" CFLAGS_hweight.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
@@ -142,7 +142,7 @@ $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c) -$(OUTPUT)util/find_next_bit.o: ../lib/util/find_next_bit.c FORCE +$(OUTPUT)util/find_bit.o: ../lib/find_bit.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c)
tools/perf/util/python-ext-sources +1 -1
@@ -11,7 +11,7 @@ util/evlist.c util/evsel.c util/cpumap.c util/bitmap.c -../lib/util/find_next_bit.c +../lib/find_bit.c ../lib/hweight.c util/thread_map.c util/util.c
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 40/59 tools lib: Sync tools/lib/find_bit.c with the kernel
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Need to move the bitmap.[ch] things from tools/perf/ to tools/lib, will be done in the next patches.
--- tools/lib/find_bit.c | 103 ++++++++++++++++----------------- tools/perf/util/include/linux/bitmap.h | 2 + 2 files changed, 51 insertions(+), 54 deletions(-)
tools/lib/find_bit.c +49 -54
@@ -1,10 +1,17 @@ -/* find_next_bit.c: fallback find next bit implementation +/* bit search implementation * -* Copied from lib/find_next_bit.c to tools/lib/find_bit.c +* Copied from lib/find_bit.c to tools/lib/find_bit.c * * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. * Written by David Howells ([email protected]) * +* Copyright (C) 2008 IBM Corporation +* 'find_last_bit' is written by Rusty Russell <[email protected]> +* (Inspired by David Howell's find_next_bit implementation) +* +* Rewritten by Yury Norov <[email protected]> to decrease +* size and improve performance, 2015. +* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version
@@ -12,52 +19,50 @@*/ #include <linux/bitops.h> -#include <asm/types.h> -#include <asm/byteorder.h> +#include <linux/bitmap.h> +#include <linux/kernel.h> -#define BITOP_WORD (nr) ((nr) / BITS_PER_LONG) +#if !defined(find_next_bit) -#ifndef find_next_bit/* -* Find the next set bit in a memory region. +* This is a common helper function for find_next_bit and +* find_next_zero_bit. The difference is the "invert" argument, which +* is XORed with each fetched word before searching it for one bits. */ -unsigned long find_next_bit (const unsigned long *addr,unsigned long size, -unsigned long offset) +static unsigned long _find_next_bit (const unsigned long *addr, +unsigned long nbits,unsigned long start,unsigned long invert) { -const unsigned long *p = addr +BITOP_WORD (offset); -unsigned long result = offset & ~(BITS_PER_LONG -1 );unsigned long tmp; -if (offset >= size) -return size; - size -= result; - offset %=BITS_PER_LONG ; -if (offset) { - tmp = *(p++); - tmp &= (~0UL << offset); -if (size <BITS_PER_LONG ) - goto found_first; -if (tmp) - goto found_middle; - size -=BITS_PER_LONG ; - result +=BITS_PER_LONG ; - } -while (size & ~(BITS_PER_LONG -1 )) { -if ((tmp = *(p++))) - goto found_middle; - result +=BITS_PER_LONG ; - size -=BITS_PER_LONG ; +if (!nbits || start >= nbits) +return nbits; + + tmp = addr[start /BITS_PER_LONG ] ^ invert; + +/* Handle 1st word. */ + tmp &=BITMAP_FIRST_WORD_MASK (start); + start =round_down (start,BITS_PER_LONG ); + +while (!tmp) { + start +=BITS_PER_LONG ; +if (start >= nbits) +return nbits; + + tmp = addr[start /BITS_PER_LONG ] ^ invert; } -if (!size) -return result; - tmp = *p; -found_first: - tmp &= (~0UL >> (BITS_PER_LONG - size)); -if (tmp ==0UL )/* Are any bits set? */ -return result + size;/* Nope. */ -found_middle: -return result +__ffs (tmp); +return min (start +__ffs (tmp), nbits); +} +#endif + +#ifndef find_next_bit +/* +* Find the next set bit in a memory region. +*/ +unsigned long find_next_bit (const unsigned long *addr,unsigned long size, +unsigned long offset) +{ +return _find_next_bit (addr, size, offset,0UL ); }#endif
@@ -67,23 +72,13 @@ found_middle:*/ unsigned long find_first_bit (const unsigned long *addr,unsigned long size) { -const unsigned long *p = addr; -unsigned long result =0 ; -unsigned long tmp; +unsigned long idx; -while (size & ~(BITS_PER_LONG -1 )) { -if ((tmp = *(p++))) - goto found; - result +=BITS_PER_LONG ; - size -=BITS_PER_LONG ; +for (idx =0 ; idx *BITS_PER_LONG < size; idx++) { +if (addr[idx]) +return min (idx *BITS_PER_LONG +__ffs (addr[idx]), size); } -if (!size) -return result; - tmp = (*p) & (~0UL >> (BITS_PER_LONG - size)); -if (tmp ==0UL )/* Are any bits set? */ -return result + size;/* Nope. */ -found: -return result +__ffs (tmp); +return size; }#endif
tools/perf/util/include/linux/bitmap.h +2 -0
@@ -11,6 +11,8 @@ int __bitmap_weight(const unsigned long *bitmap, int bits);void __bitmap_or (unsigned long *dst,const unsigned long *bitmap1,const unsigned long *bitmap2,int bits); +#define BITMAP_FIRST_WORD_MASK (start) (~0UL << ((start) & (BITS_PER_LONG - 1))) +#define BITMAP_LAST_WORD_MASK (nbits) \ ( \ ((nbits) % BITS_PER_LONG) ? \
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 41/59 tools lib: Move bitmap.[ch] from tools/perf/ to tools/{lib,include}/
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
So that lib/find_bit.c doesn't requires anything inside tools/perf/
--- tools/include/linux/bitmap.h | 68 ++++++++++++++++++++++++++++++++++ tools/lib/bitmap.c | 31 ++++++++++++++++ tools/perf/util/Build | 5 +++ tools/perf/util/bitmap.c | 31 ---------------- tools/perf/util/include/linux/bitmap.h | 68 ---------------------------------- tools/perf/util/python-ext-sources | 2 +- 6 files changed, 105 insertions(+), 100 deletions(-) create mode 100644 tools/include/linux/bitmap.h create mode 100644 tools/lib/bitmap.c delete mode 100644 tools/perf/util/bitmap.c delete mode 100644 tools/perf/util/include/linux/bitmap.h
tools/include/linux/bitmap.h new file +68 -0
@@ -0,0 +1,68 @@ +#ifndef _PERF_BITOPS_H +#define _PERF_BITOPS_H + +#include <string.h> +#include <linux/bitops.h> + +#define DECLARE_BITMAP (name,bits) \ + unsigned long name[BITS_TO_LONGS(bits)] + +int __bitmap_weight (const unsigned long *bitmap,int bits); +void __bitmap_or (unsigned long *dst,const unsigned long *bitmap1, +const unsigned long *bitmap2,int bits); + +#define BITMAP_FIRST_WORD_MASK (start) (~0UL << ((start) & (BITS_PER_LONG - 1))) + +#define BITMAP_LAST_WORD_MASK (nbits) \ +( \ + ((nbits) % BITS_PER_LONG) ? \ + (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ +) + +#define small_const_nbits (nbits) \ + (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) + +static inline void bitmap_zero (unsigned long *dst,int nbits) +{ +if (small_const_nbits (nbits)) + *dst =0UL ; +else { +int len =BITS_TO_LONGS (nbits) *sizeof (unsigned long ); +memset (dst,0 , len); + } +} + +static inline int bitmap_weight (const unsigned long *src,int nbits) +{ +if (small_const_nbits (nbits)) +return hweight_long (*src &BITMAP_LAST_WORD_MASK (nbits)); +return __bitmap_weight (src, nbits); +} + +static inline void bitmap_or (unsigned long *dst,const unsigned long *src1, +const unsigned long *src2,int nbits) +{ +if (small_const_nbits (nbits)) + *dst = *src1 | *src2; +else +__bitmap_or (dst, src1, src2, nbits); +} + +/** +* test_and_set_bit - Set a bit and return its old value +* @nr: Bit to set +* @addr: Address to count from +*/ +static inline int test_and_set_bit (int nr,unsigned long *addr) +{ +unsigned long mask =BIT_MASK (nr); +unsigned long *p = ((unsigned long *)addr) +BIT_WORD (nr); +unsigned long old; + + old = *p; + *p = old | mask; + +return (old & mask) !=0 ; +} + +#endif /* _PERF_BITOPS_H */
tools/lib/bitmap.c new file +31 -0
@@ -0,0 +1,31 @@ +/* +* From lib/bitmap.c +* Helper functions for bitmap.h. +* +* This source code is licensed under the GNU General Public License, +* Version 2. See the file COPYING for more details. +*/ +#include <linux/bitmap.h> + +int __bitmap_weight (const unsigned long *bitmap,int bits) +{ +int k, w =0 , lim = bits/BITS_PER_LONG ; + +for (k =0 ; k < lim; k++) + w +=hweight_long (bitmap[k]); + +if (bits %BITS_PER_LONG ) + w +=hweight_long (bitmap[k] &BITMAP_LAST_WORD_MASK (bits)); + +return w; +} + +void __bitmap_or (unsigned long *dst,const unsigned long *bitmap1, +const unsigned long *bitmap2,int bits) +{ +int k; +int nr =BITS_TO_LONGS (bits); + +for (k =0 ; k < nr; k++) + dst[k] = bitmap1[k] | bitmap2[k]; +}
tools/perf/util/Build +5 -0
@@ -132,6 +132,7 @@ CFLAGS_pmu-bison.o += -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c +CFLAGS_bitmap.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" CFLAGS_find_bit.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" CFLAGS_rbtree.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" CFLAGS_libstring.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
@@ -142,6 +143,10 @@ $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c) +$(OUTPUT)util/bitmap.o: ../lib/bitmap.c FORCE + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c) + $(OUTPUT)util/find_bit.o: ../lib/find_bit.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c)
tools/perf/util/bitmap.c deleted +0 -31
@@ -1,31 +0,0 @@ -/* -* From lib/bitmap.c -* Helper functions for bitmap.h. -* -* This source code is licensed under the GNU General Public License, -* Version 2. See the file COPYING for more details. -*/ -#include <linux/bitmap.h> - -int __bitmap_weight (const unsigned long *bitmap,int bits) -{ -int k, w =0 , lim = bits/BITS_PER_LONG ; - -for (k =0 ; k < lim; k++) - w +=hweight_long (bitmap[k]); - -if (bits %BITS_PER_LONG ) - w +=hweight_long (bitmap[k] &BITMAP_LAST_WORD_MASK (bits)); - -return w; -} - -void __bitmap_or (unsigned long *dst,const unsigned long *bitmap1, -const unsigned long *bitmap2,int bits) -{ -int k; -int nr =BITS_TO_LONGS (bits); - -for (k =0 ; k < nr; k++) - dst[k] = bitmap1[k] | bitmap2[k]; -}
tools/perf/util/include/linux/bitmap.h deleted +0 -68
68 lines not on this page · raw message
tools/perf/util/python-ext-sources +1 -1
@@ -10,7 +10,7 @@ util/ctype.c util/evlist.c util/evsel.c util/cpumap.c -util/bitmap.c +../lib/bitmap.c ../lib/find_bit.c ../lib/hweight.c util/thread_map.c
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 42/59 perf top: Decay periods in callchains
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
It missed to decay periods in callchains when decaying hist entries. This resulted in more than 100 percent overhead in callchains in the fractal style output.
--- tools/perf/util/callchain.c | 28 ++++++++++++++++++++++++++++ tools/perf/util/callchain.h | 1 + tools/perf/util/hist.c | 1 + 3 files changed, 30 insertions(+)
tools/perf/util/callchain.c +28 -0
@@ -925,6 +925,34 @@ void free_callchain(struct callchain_root *root)free_callchain_node (&root->node); } +static u64 decay_callchain_node (struct callchain_node *node) +{ +struct callchain_node *child; +struct rb_node *n; +u64 child_hits =0 ; + + n =rb_first (&node->rb_root_in); +while (n) { + child = container_of(n, struct callchain_node, rb_node_in); + + child_hits +=decay_callchain_node (child); + n =rb_next (n); + } + + node->hit = (node->hit *7 ) /8 ; + node->children_hit = child_hits; + +return node->hit; +} + +void decay_callchain (struct callchain_root *root) +{ +if (!symbol_conf.use_callchain) +return ; + +decay_callchain_node (&root->node); +} +int callchain_node__make_parent_list (struct callchain_node *node) {struct callchain_node *parent = node->parent;
tools/perf/util/callchain.h +1 -0
@@ -253,6 +253,7 @@ int callchain_node__fprintf_value(struct callchain_node *node, FILE *fp, u64 total);void free_callchain (struct callchain_root *root); +void decay_callchain (struct callchain_root *root);int callchain_node__make_parent_list (struct callchain_node *node);#endif /* __PERF_CALLCHAIN_H */
tools/perf/util/hist.c +1 -0
@@ -254,6 +254,7 @@ static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)he_stat__decay (&he->stat);if (symbol_conf.cumulate_callchain)he_stat__decay (he->stat_acc); +decay_callchain (he->callchain); diff = prev_period - he->stat.period;
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 43/59 perf report: Change default to use event group view
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
The event group view feature is to see related events together. To use the group view, events should be recorded as a group with a dedicated syntax of surrounding events by braces (-e '{ evt1, evt2, ... }').
Also 'perf report' also requires the --group option to enable it. However it's almost always beneficial to use the group view to see the group events as it's more expressive. And I think it's more natural to see events together if they are recorded as a group.
Thus this patch changes the default value to enable it. If users don't want to see like it and keep the original behavior, they can set the report.group config variable to false and/or use --no-group option in the 'perf report' command line.
--- tools/perf/util/symbol.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/symbol.c +1 -0
@@ -39,6 +39,7 @@ struct symbol_conf symbol_conf = { .cumulate_callchain = true, .show_hist_headers = true, .symfs = "", + .event_group = true, };static enum dso_binary_type binary_type_symtab[] = {
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 44/59 perf tools: Do not show trace command if it's not compiled in
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
The trace command still appears in help message when you run simple 'perf' command.
It's because the generate-cmdlist.sh does not care about the HAVE_LIBAUDIT_SUPPORT dependency of trace command and puts it into generated common_cmds array.
Wrapping trace command under HAVE_LIBAUDIT_SUPPORT dependency, which will exclude it from common_cmds array if HAVE_LIBAUDIT_SUPPORT is not set.
--- tools/perf/command-list.txt | 2 +- tools/perf/util/generate-cmdlist.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
tools/perf/command-list.txt +1 -1
@@ -26,4 +26,4 @@ perf-stat mainporcelain common perf-test mainporcelain common perf-timechart mainporcelain common perf-top mainporcelain common -perf-trace mainporcelain common +perf-trace mainporcelain audit
tools/perf/util/generate-cmdlist.sh +15 -0
@@ -36,4 +36,19 @@ do }' "Documentation/perf-$cmd.txt" done echo "#endif /* HAVE_LIBELF_SUPPORT */" + +echo "#ifdef HAVE_LIBAUDIT_SUPPORT" +sed -n -e 's/^perf-\([^ ]*\)[ ].* audit*/\1/p' command-list.txt | +sort | +while read cmd +do + sed -n ' + /^NAME/,/perf-'"$cmd"'/H + ${ + x + s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/ + p + }' "Documentation/perf-$cmd.txt" +done +echo "#endif /* HAVE_LIBELF_SUPPORT */" echo "};"
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 45/59 perf tools: Add missing headers in perf's MANIFEST
In reply to Arnaldo Carvalho de MeloFrom: Wang Nan <[email protected]>
These lost headers are found in arm64 cross buildings, failing to build perf using tarballs generated using:
$ make perf-targz-src-pkg
--- tools/perf/MANIFEST | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/MANIFEST +2 -0
@@ -1,6 +1,7 @@ tools/perf tools/arch/alpha/include/asm/barrier.h tools/arch/arm/include/asm/barrier.h +tools/arch/arm64/include/asm/barrier.h tools/arch/ia64/include/asm/barrier.h tools/arch/mips/include/asm/barrier.h tools/arch/powerpc/include/asm/barrier.h
@@ -30,6 +31,7 @@ tools/lib/find_bit.c tools/include/asm/atomic.h tools/include/asm/barrier.h tools/include/asm/bug.h +tools/include/asm-generic/atomic-gcc.h tools/include/asm-generic/barrier.h tools/include/asm-generic/bitops/arch_hweight.h tools/include/asm-generic/bitops/atomic.h
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 46/59 perf script: Align event name properly
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding code to align event names, so we get aligned output in case of multiple events with different names.
Before:
$ perf script :13757 13757 163918.230829: cpu/mem-snp-none/P: ffff88085f20d010 :13757 13757 163918.230832: cpu/mem-loads,ldlat=30/P: 7f5a5f719f00 :13757 13757 163918.230835: cpu/mem-loads,ldlat=30/P: 7f5a5f719f00 :13758 13758 163918.230838: cpu/mem-snp-none/P: ffff88085f4ad810 :13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28 :13757 13757 163918.155264: cpu/mem-snp-hitm/P: 601080 ...
After:
$ perf script :13757 13757 163918.228831: cpu/mem-snp-none/P: ffffffff81a841c0 :13757 13757 163918.228834: cpu/mem-loads,ldlat=30/P: 7f5a5f719f08 :13757 13757 163918.228837: cpu/mem-loads,ldlat=30/P: 7f5a5f719f08 :13758 13758 163918.228837: cpu/mem-snp-none/P: ffff88085f4ad800 :13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28 :13757 13757 163918.155264: cpu/mem-snp-hitm/P: 601080 ...
--- tools/perf/builtin-script.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
tools/perf/builtin-script.c +22 -2
@@ -617,9 +617,24 @@ struct perf_script {bool allocated;struct cpu_map *cpus;struct thread_map *threads; +int name_width; }; -static void process_event (struct perf_script *script__maybe_unused ,union perf_event *event, +static int perf_evlist__max_name_len (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel; +int max =0 ; + +evlist__for_each (evlist, evsel) { +int len =strlen (perf_evsel__name (evsel)); + + max =MAX (len, max); + } + +return max; +} + +static void process_event (struct perf_script *script,union perf_event *event,struct perf_sample *sample,struct perf_evsel *evsel,struct addr_location *al) {
@@ -636,7 +651,12 @@ static void process_event(struct perf_script *script __maybe_unused, union perf_if (PRINT_FIELD (EVNAME )) {const char *evname =perf_evsel__name (evsel); -printf ("%s: " , evname ? evname :"[unknown]" ); + +if (!script->name_width) + script->name_width =perf_evlist__max_name_len (script->session->evlist); + +printf ("%*s: " , script->name_width, + evname ? evname :"[unknown]" ); }if (print_flags)
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 47/59 perf tools: Include all tools/lib directory for tags/cscope/TAGS targets
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Besides lockdep we use all the 'tools/lib' code in perf, so include it completely in tags.
--- tools/perf/Makefile.perf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
@@ -488,7 +488,7 @@ INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html $(DOC_TARGETS): $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:doc=all) -TAG_FOLDERS= . ../lib/traceevent ../lib/api ../lib/symbol ../include ../lib/bpf +TAG_FOLDERS= . ../lib ../include TAG_FILES= ../../include/uapi/linux/perf_event.h TAGS:
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 48/59 perf tools: Remove list entry from struct sort_entry
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
It's no longer needed.
--- tools/perf/util/sort.h | 2 -- 1 file changed, 2 deletions(-)
tools/perf/util/sort.h +0 -2
@@ -214,8 +214,6 @@ enum sort_type {*/ struct sort_entry { -struct list_head list; -const char *se_header;int64_t (*se_cmp)(struct hist_entry *,struct hist_entry *);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 49/59 perf tools: Add overhead/overhead_children keys defaults via string
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
We currently set 'overhead' and 'overhead_children' as default sort keys within perf_hpp__init function by directly adding into the sort list.
This patch adds 'overhead' and 'overhead_children' in text form into sort_keys and let them be added by standard sort dimension interface.
We need to eliminate dirrect sort_list additions to be able to add support for hists specific sort keys.
--- tools/perf/ui/hist.c | 12 ------------ tools/perf/util/sort.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 12 deletions(-)
tools/perf/ui/hist.c +0 -12
@@ -443,7 +443,6 @@ LIST_HEAD(perf_hpp__sort_list);void perf_hpp__init (void ) { -struct list_head *list;int i;for (i =0 ; i <PERF_HPP__MAX_INDEX ; i++) {
@@ -484,17 +483,6 @@ void perf_hpp__init(void)if (symbol_conf.show_total_period)hpp_dimension__add_output (PERF_HPP__PERIOD ); - -/* prepend overhead field for backward compatiblity. */ - list = &perf_hpp__format[PERF_HPP__OVERHEAD ].sort_list; -if (list_empty (list)) -list_add (list, &perf_hpp__sort_list); - -if (symbol_conf.cumulate_callchain) { - list = &perf_hpp__format[PERF_HPP__OVERHEAD_ACC ].sort_list; -if (list_empty (list)) -list_add (list, &perf_hpp__sort_list); - } }void perf_hpp__column_register (struct perf_hpp_fmt *format)
tools/perf/util/sort.c +39 -0
@@ -2252,6 +2252,34 @@ static int setup_sort_order(struct perf_evlist *evlist)return 0 ; } +/* +* Adds 'pre,' prefix into 'str' is 'pre' is +* not already part of 'str'. +*/ +static char *prefix_if_not_in (const char *pre,char *str) +{ +char *n; + +if (!str ||strstr (str, pre)) +return str; + +if (asprintf (&n,"%s,%s" , pre, str) <0 ) +return NULL ; + +free (str); +return n; +} + +static char *setup_overhead (char *keys) +{ + keys =prefix_if_not_in ("overhead" , keys); + +if (symbol_conf.cumulate_callchain) + keys =prefix_if_not_in ("overhead_children" , keys); + +return keys; +} +static int __setup_sorting (struct perf_evlist *evlist) {char *tmp, *tok, *str;
@@ -2281,6 +2309,17 @@ static int __setup_sorting(struct perf_evlist *evlist)return -ENOMEM ; } +/* +* Prepend overhead fields for backward compatibility. +*/ +if (!is_strict_order (field_order)) { + str =setup_overhead (str); +if (str ==NULL ) { +error ("Not enough memory to setup overhead keys" ); +return -ENOMEM ; + } + } +for (tok =strtok_r (str,", " , &tmp); tok; tok =strtok_r (NULL ,", " , &tmp)) { ret =sort_dimension__add (tok, evlist);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 50/59 perf diff: Use perf_hpp__register_sort_field interface
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Using perf_hpp__register_sort_field interface instead of directly adding the entry.
--- tools/perf/builtin-diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-diff.c +1 -1
@@ -1207,7 +1207,7 @@ static int ui_init(void)BUG_ON (1 ); } -list_add (&fmt->sort_list, &perf_hpp__sort_list); +perf_hpp__register_sort_field (fmt);return 0 ; }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 51/59 perf hists: Export a couple of hist functions
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
These are necessary for multi threaded sample processing:
- hists__get__get_rotate_entries_in()
- hists__collapse_insert_entry()
- __hists__init()
--- tools/perf/util/hist.c | 19 ++++++++++++------- tools/perf/util/hist.h | 5 +++++ 2 files changed, 17 insertions(+), 7 deletions(-)
tools/perf/util/hist.c +12 -7
@@ -1007,9 +1007,8 @@ void hist_entry__delete(struct hist_entry *he)* collapse the histogram */ -static bool hists__collapse_insert_entry (struct hists *hists__maybe_unused , -struct rb_root *root, -struct hist_entry *he) +bool hists__collapse_insert_entry (struct hists *hists__maybe_unused , +struct rb_root *root,struct hist_entry *he) {struct rb_node **p = &root->rb_node;struct rb_node *parent =NULL ;
@@ -1049,7 +1048,7 @@ static bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,return true; } -static struct rb_root *hists__get_rotate_entries_in (struct hists *hists) +struct rb_root *hists__get_rotate_entries_in (struct hists *hists) {struct rb_root *root;
@@ -1584,10 +1583,8 @@ int perf_hist_config(const char *var, const char *value)return 0 ; } -static int hists_evsel__init (struct perf_evsel *evsel) +int __hists__init (struct hists *hists) { -struct hists *hists =evsel__hists (evsel); -memset (hists,0 ,sizeof (*hists)); hists->entries_in_array[0 ] = hists->entries_in_array[1 ] =RB_ROOT ; hists->entries_in = &hists->entries_in_array[0 ];
@@ -1627,6 +1624,14 @@ static void hists_evsel__exit(struct perf_evsel *evsel)hists__delete_all_entries (hists); } +static int hists_evsel__init (struct perf_evsel *evsel) +{ +struct hists *hists =evsel__hists (evsel); + +__hists__init (hists); +return 0 ; +} +/* * XXX We probably need a hists_evsel__exit() to free the hist_entries * stored in the rbtree...
tools/perf/util/hist.h +5 -0
@@ -185,6 +185,11 @@ static inline struct hists *evsel__hists(struct perf_evsel *evsel) }int hists__init (void ); +int __hists__init (struct hists *hists); + +struct rb_root *hists__get_rotate_entries_in (struct hists *hists); +bool hists__collapse_insert_entry (struct hists *hists__maybe_unused , +struct rb_root *root,struct hist_entry *he);struct perf_hpp {char *buf;
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 52/59 perf report: Show random usage tip on the help line
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
Currently perf report only shows a help message "For a higher level overview, try: perf report --sort comm,dso" unconditionally (even if the sort keys were used). Add more help tips and show randomly.
Load tips from ${prefix}/share/doc/perf-tip/tips.txt file.
$ perf report | tail
0.10% swapper [kernel.vmlinux] [k] irq_exit
0.09% swapper [kernel.vmlinux] [k] flush_smp_call_function_queue
0.08% swapper [kernel.vmlinux] [k] native_write_msr_safe
0.03% swapper [kernel.vmlinux] [k] group_sched_in
0.01% perf [kernel.vmlinux] [k] native_write_msr_safe #
# (Tip: Search options using a keyword: perf report -h <keyword>) #
--- tools/perf/Build | 1 + tools/perf/Documentation/tips.txt | 14 ++++++++++++++ tools/perf/Makefile.perf | 3 +++ tools/perf/builtin-report.c | 2 +- tools/perf/config/Makefile | 6 ++++++ tools/perf/perf.c | 4 ++++ tools/perf/util/util.c | 27 +++++++++++++++++++++++++++ tools/perf/util/util.h | 2 ++ 8 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tools/perf/Documentation/tips.txt
tools/perf/Build +1 -0
@@ -41,6 +41,7 @@ CFLAGS_perf.o += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))" \ -DPREFIX="BUILD_STR($(prefix_SQ))" \ -include $(OUTPUT)PERF-VERSION-FILE CFLAGS_builtin-trace.o += -DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))" +CFLAGS_builtin-report.o += -DTIPDIR="BUILD_STR($(tipdir_SQ))" libperf-y += util/ libperf-y += arch/
tools/perf/Documentation/tips.txt new file +14 -0
@@ -0,0 +1,14 @@ +For a higher level overview, try: perf report --sort comm,dso +Sample related events with: perf record -e '{cycles,instructions}:S' +Compare performance results with: perf diff [<old file> <new file>] +Boolean options have negative forms, e.g.: perf report --no-children +Customize output of perf script with: perf script -F event,ip,sym +Generate a script for your data: perf script -g <lang> +Save output of perf stat using: perf stat record <target workload> +Create an archive with symtabs to analyse on other machine: perf archive +Search options using a keyword: perf report -h <keyword> +Use parent filter to see specific call path: perf report -p <regex> +List events using substring match: perf list <keyword> +To see list of saved events and attributes: perf evlist -v +Use --symfs <dir> if your symbol files are in non-standard locations +To see callchains in a more compact form: perf report -g folded
tools/perf/Makefile.perf +3 -0
@@ -567,6 +567,9 @@ endif $(call QUIET_INSTALL, perf_completion-script) \ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \ $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf' + $(call QUIET_INSTALL, perf-tip) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \ + $(INSTALL) Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)' install-tests: all install-gtk $(call QUIET_INSTALL, tests) \
tools/perf/builtin-report.c +1 -1
@@ -433,7 +433,7 @@ static int report__browse_hists(struct report *rep)int ret;struct perf_session *session = rep->session;struct perf_evlist *evlist = session->evlist; -const char *help ="For a higher level overview, try: perf report --sort comm,dso" ; +const char *help =perf_tip (TIPDIR );switch (use_browser) {case 1 :
tools/perf/config/Makefile +6 -0
@@ -691,6 +691,7 @@ sharedir = $(prefix)/share template_dir = share/perf-core/templates STRACE_GROUPS_DIR = share/perf-core/strace/groups htmldir = share/doc/perf-doc +tipdir = share/doc/perf-tip ifeq ($(prefix),/usr) sysconfdir = /etc ETC_PERFCONFIG = $(sysconfdir)/perfconfig
@@ -717,6 +718,7 @@ infodir_SQ = $(subst ','\'',$(infodir)) perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) template_dir_SQ = $(subst ','\'',$(template_dir)) htmldir_SQ = $(subst ','\'',$(htmldir)) +tipdir_SQ = $(subst ','\'',$(tipdir)) prefix_SQ = $(subst ','\'',$(prefix)) sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) libdir_SQ = $(subst ','\'',$(libdir))
@@ -724,12 +726,15 @@ libdir_SQ = $(subst ','\'',$(libdir)) ifneq ($(filter /%,$(firstword $(perfexecdir))),) perfexec_instdir = $(perfexecdir) STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR) +tip_instdir = $(tipdir) else perfexec_instdir = $(prefix)/$(perfexecdir) STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR) +tip_instdir = $(prefix)/$(tipdir) endif perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR)) +tip_instdir_SQ = $(subst ','\'',$(tip_instdir)) # If we install to $(HOME) we keep the traceevent default: # $(HOME)/.traceevent/plugins
@@ -770,6 +775,7 @@ $(call detected_var,ETC_PERFCONFIG_SQ) $(call detected_var,STRACE_GROUPS_DIR_SQ) $(call detected_var,prefix_SQ) $(call detected_var,perfexecdir_SQ) +$(call detected_var,tipdir_SQ) $(call detected_var,LIBDIR) $(call detected_var,GTK_CFLAGS) $(call detected_var,PERL_EMBED_CCOPTS)
tools/perf/perf.c +4 -0
@@ -19,6 +19,8 @@#include "util/debug.h" #include <api/fs/tracing_path.h> #include <pthread.h> +#include <stdlib.h> +#include <time.h> const char perf_usage_string[] ="perf [--version] [--help] [OPTIONS] COMMAND [ARGS]" ;
@@ -542,6 +544,8 @@ int main(int argc, const char **argv)if (!cmd) cmd ="perf-help" ; +srandom (time (NULL )); +/* get debugfs/tracefs mount point from /proc/mounts */ tracing_path_mount ();
tools/perf/util/util.c +27 -0
@@ -16,6 +16,8 @@#include <linux/kernel.h> #include <unistd.h> #include "callchain.h" +#include "strlist.h" +#include <subcmd/exec-cmd.h> struct callchain_param callchain_param = { .mode =CHAIN_GRAPH_ABS ,
@@ -663,3 +665,28 @@ fetch_kernel_version(unsigned int *puint, char *str, *puint = (version <<16 ) + (patchlevel <<8 ) + sublevel;return 0 ; } + +const char *perf_tip (const char *dirpath) +{ +struct strlist *tips; +struct str_node *node; +char *tip =NULL ; +struct strlist_config conf = { + .dirname =system_path (dirpath) , + }; + + tips =strlist__new ("tips.txt" , &conf); +if (tips ==NULL ||strlist__nr_entries (tips) ==1 ) { + tip = (char *)"Cannot find tips.txt file" ; + goto out; + } + + node =strlist__entry (tips,random () %strlist__nr_entries (tips)); +if (asprintf (&tip,"Tip: %s" , node->s) <0 ) + tip = (char *)"Tip: get more memory! ;-)" ; + +out: +strlist__delete (tips); + +return tip; +}
tools/perf/util/util.h +2 -0
@@ -342,4 +342,6 @@ int fetch_kernel_version(unsigned int *puint,#define KVER_FMT "%d.%d.%d"#define KVER_PARAM (x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) +const char *perf_tip (const char *dirpath); +#endif /* GIT_COMPAT_UTIL_H */
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 53/59 perf evlist: Make perf_evlist__open() open evsels with their cpus and threads (like perf record does)
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
'perf record' uses perf_evsel__open() to open events and passes the evsel->cpus and evsel->threads. Many tests and some tools instead use perf_evlist__open() which passes instead evlist->cpus and evlist->threads.
Make perf_evlist__open() follow the 'perf record' behaviour so that a consistent approach is taken.
--- tools/perf/util/evlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evlist.c +1 -1
@@ -1498,7 +1498,7 @@ int perf_evlist__open(struct perf_evlist *evlist)perf_evlist__update_id_pos (evlist);evlist__for_each (evlist, evsel) { - err =perf_evsel__open (evsel, evlist->cpus, evlist->threads); + err =perf_evsel__open (evsel, evsel->cpus, evsel->threads);if (err <0 ) goto out_err; }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 54/59 perf evlist: Remove perf_evlist__(enable|disable)_event functions
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Replacing them with perf_evsel__(enable|disable).
--- tools/perf/arch/x86/util/intel-bts.c | 4 ++-- tools/perf/arch/x86/util/intel-pt.c | 4 ++-- tools/perf/tests/keep-tracking.c | 2 +- tools/perf/tests/switch-tracking.c | 6 +++--- tools/perf/util/evlist.c | 42 ------------------------------------ tools/perf/util/evlist.h | 4 ---- 6 files changed, 8 insertions(+), 54 deletions(-)
tools/perf/arch/x86/util/intel-bts.c +2 -2
@@ -327,7 +327,7 @@ static int intel_bts_snapshot_start(struct auxtrace_record *itr)evlist__for_each (btsr->evlist, evsel) {if (evsel->attr.type == btsr->intel_bts_pmu->type) -return perf_evlist__disable_event (btsr->evlist, evsel); +return perf_evsel__disable (evsel); }return -EINVAL ; }
@@ -340,7 +340,7 @@ static int intel_bts_snapshot_finish(struct auxtrace_record *itr)evlist__for_each (btsr->evlist, evsel) {if (evsel->attr.type == btsr->intel_bts_pmu->type) -return perf_evlist__enable_event (btsr->evlist, evsel); +return perf_evsel__enable (evsel); }return -EINVAL ; }
tools/perf/arch/x86/util/intel-pt.c +2 -2
@@ -725,7 +725,7 @@ static int intel_pt_snapshot_start(struct auxtrace_record *itr)evlist__for_each (ptr->evlist, evsel) {if (evsel->attr.type == ptr->intel_pt_pmu->type) -return perf_evlist__disable_event (ptr->evlist, evsel); +return perf_evsel__disable (evsel); }return -EINVAL ; }
@@ -738,7 +738,7 @@ static int intel_pt_snapshot_finish(struct auxtrace_record *itr)evlist__for_each (ptr->evlist, evsel) {if (evsel->attr.type == ptr->intel_pt_pmu->type) -return perf_evlist__enable_event (ptr->evlist, evsel); +return perf_evsel__enable (evsel); }return -EINVAL ; }
tools/perf/tests/keep-tracking.c +1 -1
@@ -123,7 +123,7 @@ int test__keep_tracking(int subtest __maybe_unused) evsel =perf_evlist__last (evlist); -CHECK__ (perf_evlist__disable_event (evlist, evsel)); +CHECK__ (perf_evsel__disable (evsel)); comm ="Test COMM 2" ;CHECK__ (prctl (PR_SET_NAME , (unsigned long )comm,0 ,0 ,0 ));
tools/perf/tests/switch-tracking.c +3 -3
@@ -455,7 +455,7 @@ int test__switch_tracking(int subtest __maybe_unused)perf_evlist__enable (evlist); - err =perf_evlist__disable_event (evlist, cpu_clocks_evsel); + err =perf_evsel__disable (cpu_clocks_evsel);if (err) {pr_debug ("perf_evlist__disable_event failed!\n" ); goto out_err;
@@ -474,7 +474,7 @@ int test__switch_tracking(int subtest __maybe_unused) goto out_err; } - err =perf_evlist__disable_event (evlist, cycles_evsel); + err =perf_evsel__disable (cycles_evsel);if (err) {pr_debug ("perf_evlist__disable_event failed!\n" ); goto out_err;
@@ -500,7 +500,7 @@ int test__switch_tracking(int subtest __maybe_unused) goto out_err; } - err =perf_evlist__enable_event (evlist, cycles_evsel); + err =perf_evsel__enable (cycles_evsel);if (err) {pr_debug ("perf_evlist__disable_event failed!\n" ); goto out_err;
tools/perf/util/evlist.c +0 -42
48 lines not on this page · raw message
tools/perf/util/evlist.h +0 -4
@@ -155,10 +155,6 @@ void perf_evlist__disable(struct perf_evlist *evlist);void perf_evlist__enable (struct perf_evlist *evlist);void perf_evlist__toggle_enable (struct perf_evlist *evlist); -int perf_evlist__disable_event (struct perf_evlist *evlist, -struct perf_evsel *evsel); -int perf_evlist__enable_event (struct perf_evlist *evlist, -struct perf_evsel *evsel);int perf_evlist__enable_event_idx (struct perf_evlist *evlist,struct perf_evsel *evsel,int idx);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 55/59 perf unwind: Use find_map function in access_dso_mem
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
The find_map helper is already there, so let's use it.
Also we're going to introduce wider search in following patch, so it'll be easier to make this change on single place.
--- tools/perf/util/unwind-libunwind.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
tools/perf/util/unwind-libunwind.c +5 -6
@@ -416,20 +416,19 @@ get_proc_name(unw_addr_space_t __maybe_unused as,static int access_dso_mem (struct unwind_info *ui,unw_word_t addr,unw_word_t *data) { -struct addr_location al; +struct map *map;ssize_t size; -thread__find_addr_map (ui->thread,PERF_RECORD_MISC_USER , -MAP__FUNCTION , addr, &al); -if (!al.map) { + map =find_map (addr, ui); +if (!map) {pr_debug ("unwind: no map for %lx\n" , (unsigned long )addr);return -1 ; } -if (!al.map->dso) +if (!map->dso)return -1 ; - size =dso__data_read_addr (al.map->dso, al.map, ui->machine, + size =dso__data_read_addr (map->dso, map, ui->machine, addr, (u8 *) data,sizeof (*data));return !(size ==sizeof (*data));
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 56/59 perf unwind: Check for mmaps also in MAP__VARIABLE tree
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
We've seen cases (softice) where DWARF unwinder went through non executable mmaps, which we need to lookup in MAP__VARIABLE tree.
--- tools/perf/util/unwind-libunwind.c | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/perf/util/unwind-libunwind.c +9 -0
@@ -319,6 +319,15 @@ static struct map *find_map(unw_word_t ip, struct unwind_info *ui)thread__find_addr_map (ui->thread,PERF_RECORD_MISC_USER ,MAP__FUNCTION , ip, &al); +if (!al.map) { +/* +* We've seen cases (softice) where DWARF unwinder went +* through non executable mmaps, which we need to lookup +* in MAP__VARIABLE tree. +*/ +thread__find_addr_map (ui->thread,PERF_RECORD_MISC_USER , +MAP__VARIABLE , ip, &al); + }return al.map; }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 57/59 perf libdw: Check for mmaps also in MAP__VARIABLE tree
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
We've seen cases (softice) where DWARF unwinder went through non executable mmaps, which we need to lookup in MAP__VARIABLE tree.
--- tools/perf/util/unwind-libdw.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
tools/perf/util/unwind-libdw.c +10 -0
@@ -96,6 +96,16 @@ static int access_dso_mem(struct unwind_info *ui, Dwarf_Addr addr,thread__find_addr_map (ui->thread,PERF_RECORD_MISC_USER ,MAP__FUNCTION , addr, &al);if (!al.map) { +/* +* We've seen cases (softice) where DWARF unwinder went +* through non executable mmaps, which we need to lookup +* in MAP__VARIABLE tree. +*/ +thread__find_addr_map (ui->thread,PERF_RECORD_MISC_USER , +MAP__VARIABLE , addr, &al); + } + +if (!al.map) {pr_debug ("unwind: no map for %lx\n" , (unsigned long )addr);return -1 ; }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 58/59 perf record: Store data mmaps for dwarf unwind
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Currently we don't synthesize data mmap by default. It depends on -d option, that enables data address sampling.
But we've seen cases (softice) where DWARF unwinder went through non executable mmaps, which we need to lookup in MAP__VARIABLE tree.
Making data mmaps to be synthesized for dwarf unwind as well.
--- tools/perf/builtin-record.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/builtin-record.c +5 -1
@@ -815,8 +815,12 @@ int record_parse_callchain_opt(const struct option *opt, } ret =parse_callchain_record_opt (arg, &callchain_param); -if (!ret) +if (!ret) { +/* Enable data address sampling for DWARF unwind. */ +if (callchain_param.record_mode ==CALLCHAIN_DWARF ) + record->sample_address = true;callchain_debug (); + }return ret; }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 59/59 perf evlist: Add --trace-fields option to show trace fields
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
To use dynamic sort keys, it might be good to add an option to see the list of field names.
$ perf evlist -i perf.data.sched sched:sched_switch sched:sched_stat_wait sched:sched_stat_sleep sched:sched_stat_iowait sched:sched_stat_runtime sched:sched_process_fork sched:sched_wakeup sched:sched_wakeup_new sched:sched_migrate_task # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
$ perf evlist -i perf.data.sched --trace-fields sched:sched_switch: trace_fields: prev_comm,prev_pid,prev_prio,prev_state,next_comm,next_pid,next_prio sched:sched_stat_wait: trace_fields: comm,pid,delay sched:sched_stat_sleep: trace_fields: comm,pid,delay sched:sched_stat_iowait: trace_fields: comm,pid,delay sched:sched_stat_runtime: trace_fields: comm,pid,runtime,vruntime sched:sched_process_fork: trace_fields: parent_comm,parent_pid,child_comm,child_pid sched:sched_wakeup: trace_fields: comm,pid,prio,success,target_cpu sched:sched_wakeup_new: trace_fields: comm,pid,prio,success,target_cpu sched:sched_migrate_task: trace_fields: comm,pid,prio,orig_cpu,dest_cpu
Committer notes:
For another file, in verbose mode:
# perf evlist -v --trace-fields
sched:sched_switch: type: 2, size: 112, config: 0x10b, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1, inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, trace_fields: prev_comm,prev_pid,prev_prio,prev_state,next_comm,next_pid,next_prio
#--- tools/perf/Documentation/perf-evlist.txt | 3 +++ tools/perf/builtin-evlist.c | 11 ++++++++++- tools/perf/util/evsel.c | 23 +++++++++++++++++++++++ tools/perf/util/evsel.h | 1 + 4 files changed, 37 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-evlist.txt +3 -0
@@ -32,6 +32,9 @@ OPTIONS --group:: Show event group information. +--trace-fields:: + Show tracepoint field names. + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-list[1],
tools/perf/builtin-evlist.c +10 -1
@@ -26,14 +26,22 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details .mode = PERF_DATA_MODE_READ, .force = details->force, }; +bool has_tracepoint = false; session =perf_session__new (&file,0 ,NULL );if (session ==NULL )return -1 ; -evlist__for_each (session->evlist, pos) +evlist__for_each (session->evlist, pos) {perf_evsel__fprintf (pos, details, stdout); +if (pos->attr.type ==PERF_TYPE_TRACEPOINT ) + has_tracepoint = true; + } + +if (has_tracepoint && !details->trace_fields) +printf ("# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events\n" ); +perf_session__delete (session);return 0 ; }
@@ -49,6 +57,7 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)OPT_BOOLEAN ('g' ,"group" , &details.event_group,"Show event group information" ),OPT_BOOLEAN ('f' ,"force" , &details.force,"don't complain, do it" ), +OPT_BOOLEAN (0 ,"trace-fields" , &details.trace_fields,"Show tracepoint fields" ),OPT_END () }; const char * const evlist_usage[] = {
tools/perf/util/evsel.c +23 -0
@@ -2298,6 +2298,29 @@ int perf_evsel__fprintf(struct perf_evsel *evsel, printed +=comma_fprintf (fp, &first," %s=%" PRIu64, term, (u64 )evsel->attr.sample_freq); } + +if (details->trace_fields) { +struct format_field *field; + +if (evsel->attr.type !=PERF_TYPE_TRACEPOINT ) { + printed +=comma_fprintf (fp, &first," (not a tracepoint)" ); + goto out; + } + + field = evsel->tp_format->format.fields; +if (field ==NULL ) { + printed +=comma_fprintf (fp, &first," (no trace field)" ); + goto out; + } + + printed +=comma_fprintf (fp, &first," trace_fields: %s" , field->name); + + field = field->next; +while (field) { + printed +=comma_fprintf (fp, &first,"%s" , field->name); + field = field->next; + } + } out:fputc ('\n' , fp);return ++printed;
tools/perf/util/evsel.h +1 -0
@@ -369,6 +369,7 @@ struct perf_attr_details {bool verbose;bool event_group;bool force; +bool trace_fields; }; int perf_evsel__fprintf(struct perf_evsel *evsel,
Signature · 1 line
2.1.0
Quoted 235 lines · Arnaldo Carvalho de Melo
Hi Ingo,
Please consider pulling, more to come, bpf, make build-test and
hopefully Stephane's JIT stuff, etc.Best Regards,
- Arnaldo
The following changes since commit
9cc2617de5b9222abb39cd02e90d57dfea99c6d7:perf/x86/amd: Remove l1-dcache-stores event for AMD (2016-01-06 11:15:39 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingofor you to fetch changes up to
775d8a1b0d75211cc6123915c6b5b688f2002478:perf evlist: Add --trace-fields option to show trace fields (2016-01-08 14:23:02 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:New features:
- Allow using trace events fields as sort order keys, making 'perf evlist --trace_fields' show those, and then the user can select a subset and use like:
perf top -e sched:sched_switch -s prev_comm,next_comm
That works as well in 'perf report' when handling files containing tracepoints.
The default when just tracepoint events are found in a perf.data file is to format it like ftrace, using the libtraceevent formatters, plugins, etc (Namhyung Kim)
- Add support in 'perf script' to process 'perf stat record' generated files, culminating in a python perf script that calculates CPI (Cycles per Instruction) (Jiri Olsa)
- Show random perf tool tips in the 'perf report' bottom line (Namhyung Kim)
- perf report now defaults to --group if the perf.data file has grouped events, try it with:
# perf record -e '{cycles,instructions}' -a sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 1.093 MB perf.data (1247 samples) ] # perf report # Samples: 1K of event 'anon group { cycles, instructions }' # Event count (approx.): 1955219195 # # Overhead Command Shared Object Symbol2.86% 0.22% swapper [kernel.kallsyms] [k] intel_idle 1.05% 0.33% firefox libxul.so [.] js::SetObjectElement 1.05% 0.00% kworker/0:3 [kernel.kallsyms] [k] gen6_ring_get_seqno 0.88% 0.17% chrome chrome [.] 0x0000000000ee27ab 0.65% 0.86% firefox libxul.so [.] js::ValueToId<(js::AllowGC)1> 0.64% 0.23% JS Helper libxul.so [.] js::SplayTree<js::jit::LiveRange*, js::jit::LiveRange>::splay 0.62% 1.27% firefox libxul.so [.] js::GetIterator 0.61% 1.74% firefox libxul.so [.] js::NativeSetProperty 0.61% 0.31% firefox libxul.so [.] js::SetPropertyByDefiningUser visible fixes:
- Coect data mmaps so that the DWARF unwinder can handle usecases needing them, like softice (Jiri Olsa)
- Decay callchains in fractal mode, fixing up cases where 'perf top -g' would show entries with more than 100% (Namhyung Kim)
Infrastructure:
- Sync
tools/libwith thelib/in the kernel sources forfind_bit.cand move bitmap.[ch] fromtools/perf/util/totools/lib/(Arnaldo Carvalho de Melo)- No need to set attr.sample_freq in some 'perf test' entries that only want to deal with
PERF_RECORD_meta-events, improve a bit error output for CQM test (Arnaldo Carvalho de Melo)- Fix python binding build, adding some missing object files now required due to cpumap using
find_bitstuff (Arnaldo Carvalho de Melo)-
tools/buildimprovemnts (Jiri Olsa)- Add more files to cscope/ctags databases (Jiri Olsa)
- Do not show 'trace' in 'perf help' if it is not compiled in (Jiri Olsa)
- Make
perf_evlist__open()open evsels with their cpus and threads, like perf record does, making them consistent (Adrian Hunter)- Fix pmu snapshot initialization bug (Stephane Eranian)
- Add missing headers in perf's MANIFEST (Wang Nan)
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Adrian Hunter (1):
perf evlist: Makeperf_evlist__open()open evsels with their cpus and threads (like perf record does)Arnaldo Carvalho de Melo (10):
perf tests: No need to set attr.sample_freq in the perf time to TSC test perf evlist: Introduceperf_evlist__new_dummyconstructor
perf test: Use "dummy" events in thePERF_RECORD_test
perf test: No need for setting attr.sample_freq on the RECORD test perf python: Add missing files to binding link list
perf tests: No need to set attr.sample_freq for tracking !PERF_RECORD_SAMPLE perf tests: Give a bit more information on the CQM test failure path tools lib: Movefind_next_bit.ctotools/lib/
tools lib: Synctools/lib/find_bit.cwith the kernel
tools lib: Move bitmap.[ch] fromtools/perf/totools/{lib,include}/Jiri Olsa (25):
tools build feature: Fixfeature_check_display_codetypo tools build feature: Move dwarf post unwind choice output into perf tools build feature: Introducefeature_assignmacro
tools build feature: Use value assignment form for FEATURE-DUMP file perf build: Use FEATURE-DUMP in bpf subproject
perf stat record: Keepsample_type0 for pipe session
perf script: Process cpu/threads maps
perf script: Process stat config event
perf script: Add process_stat/process_stat_interval scripting interface perf script: Add stat default handlers
perf script: Add python support for stat events
perf cpumap: Fix cpu conversion incpu_map__from_entriesperf script: Display stat events by default
perf script: Addstat-cpi.pyscript
perf tools: Do not show trace command if it's not compiled in perf script: Align event name properly
perf tools: Include alltools/libdirectory for tags/cscope/TAGS targets perf tools: Remove list entry from structsort_entry
perf tools: Add overhead/overhead_children keys defaults via string perf diff: Useperf_hpp__register_sort_fieldinterface
perf evlist: Remove perf_evlist__(enable|disable)_event functions perf unwind: Usefind_mapfunction inaccess_dso_mem
perf unwind: Check for mmaps also inMAP__VARIABLEtree perf libdw: Check for mmaps also inMAP__VARIABLEtree
perf record: Store data mmaps for dwarf unwindNamhyung Kim (21):
perf hist: Pass struct sample to__hists__add_entry()
perf hist: Save raw_data/size for tracepoint events
tools lib traceevent: Factor out and export print_event_field[s]() perf top: Create the evlist sooner
perf tools: Pass evlist tosetup_sorting()
perf tools: Add dynamic sort key for tracepoint events
perf tools: Try to show pretty printed output for dynamic sort keys perf tools: Add 'trace' sort key
perf report/top: Add --raw-trace option
perf tools: Support shortcuts for events in dynamic sort keys
perf tools: Support '<event>.*' dynamic sort key
perf tools: Skip dynamic fields not defined for current event
perf tools: Add 'trace_fields' dynamic sort key
perf tools: Make 'trace' or 'trace_fields' sort key default for tracepoint events perf tools: Add all matching dynamic sort keys for field name
perf report: Add documentation for dynamic sort keys
perf top: Decay periods in callchains
perf report: Change default to use event group view
perf hists: Export a couple of hist functions
perf report: Show random usage tip on the help line
perf evlist: Add --trace-fields option to show trace fieldsStephane Eranian (1):
perf pmu: fix alias->snapshot missing initialization bugWang Nan (1):
perf tools: Add missing headers in perf's MANIFESTtools/build/Makefile.feature | 41 +- tools/{perf/util => }/include/linux/bitmap.h | 2 + tools/{perf/util => lib}/bitmap.c | 0 tools/lib/bpf/Makefile | 4 + tools/lib/find_bit.c | 84 +++ tools/lib/traceevent/event-parse.c | 129 ++--- tools/lib/traceevent/event-parse.h | 4 + tools/lib/util/find_next_bit.c | 89 --- tools/perf/Build | 1 + tools/perf/Documentation/perf-evlist.txt | 3 + tools/perf/Documentation/perf-report.txt | 27 + tools/perf/Documentation/perf-top.txt | 3 + tools/perf/Documentation/tips.txt | 14 + tools/perf/MANIFEST | 4 +- tools/perf/Makefile.perf | 7 +- tools/perf/arch/x86/tests/intel-cqm.c | 2 +- tools/perf/arch/x86/tests/perf-time-to-tsc.c | 1 - tools/perf/arch/x86/util/intel-bts.c | 4 +- tools/perf/arch/x86/util/intel-pt.c | 4 +- tools/perf/builtin-annotate.c | 9 +- tools/perf/builtin-diff.c | 15 +- tools/perf/builtin-evlist.c | 11 +- tools/perf/builtin-record.c | 6 +- tools/perf/builtin-report.c | 6 +- tools/perf/builtin-script.c | 170 +++++- tools/perf/builtin-stat.c | 9 +- tools/perf/builtin-top.c | 16 +- tools/perf/command-list.txt | 2 +- tools/perf/config/Makefile | 10 + tools/perf/perf.c | 4 + tools/perf/scripts/python/stat-cpi.py | 77 +++ tools/perf/tests/hists_cumulate.c | 8 +- tools/perf/tests/hists_filter.c | 2 +- tools/perf/tests/hists_link.c | 8 +- tools/perf/tests/hists_output.c | 10 +- tools/perf/tests/keep-tracking.c | 3 +- tools/perf/tests/perf-record.c | 6 +- tools/perf/tests/switch-tracking.c | 6 +- tools/perf/ui/browsers/hists.c | 7 +- tools/perf/ui/gtk/hists.c | 4 +- tools/perf/ui/hist.c | 14 +- tools/perf/ui/stdio/hist.c | 6 +- tools/perf/util/Build | 11 +- tools/perf/util/callchain.c | 28 + tools/perf/util/callchain.h | 1 + tools/perf/util/cpumap.c | 13 +- tools/perf/util/evlist.c | 72 +-- tools/perf/util/evlist.h | 7 +- tools/perf/util/evsel.c | 23 + tools/perf/util/evsel.h | 1 + tools/perf/util/generate-cmdlist.sh | 15 + tools/perf/util/hist.c | 78 ++- tools/perf/util/hist.h | 24 +- tools/perf/util/pmu.c | 1 + tools/perf/util/python-ext-sources | 2 + .../util/scripting-engines/trace-event-python.c | 115 +++- tools/perf/util/sort.c | 601 ++++++++++++++++++++- tools/perf/util/sort.h | 12 +- tools/perf/util/symbol.c | 1 + tools/perf/util/symbol.h | 3 +- tools/perf/util/trace-event.h | 4 + tools/perf/util/unwind-libdw.c | 10 + tools/perf/util/unwind-libunwind.c | 20 +- tools/perf/util/util.c | 27 +
Quoted 8 lines
tools/perf/util/util.h | 2 +
65 files changed, 1556 insertions(+), 347 deletions(-)
rename tools/{perf/util => }/include/linux/bitmap.h (95%)
rename tools/{perf/util => lib}/bitmap.c (100%)
create mode 100644 tools/lib/find_bit.c
delete mode 100644 tools/lib/util/find_next_bit.c
create mode 100644 tools/perf/Documentation/tips.txt
create mode 100644 tools/perf/scripts/python/stat-cpi.pyPulled, thanks a lot Arnaldo!
Ingo