perf/core improvements and fixes
Subsystems (2)
Arnaldo Carvalho de Melo
maintainerHi Ingo,
Please consider pulling, this is on top of the outstanding
perf-core-for-mingo-20160229 signed tag.
- Arnaldo
The following changes since commit 1d6c9407d45dd622b277ca9f725da3cc9e95b5de:
perf trace: Print content of bpf-output event (2016-02-26 19:57:07 -0300)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-20160302
for you to fetch changes up to 575197b405c45959ca2f71da8c65b6f8d9693140:
perf stat: Check for frontend stalled for metrics (2016-03-02 11:27:00 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
User visible:
- Implement CSV metrics output in 'perf stat' (Andi Kleen)
- Support metrics in 'perf stat' --per-core/socket mode (Andi Kleen)
- Check for frontend stalled for metrics (Andi Kleen)
- Fix segfault in 'perf test' hists related entries (Arnaldo Carvalho de Melo)
- Fix output of %llu for 64 bit values read on 32 bit machines in libtraceevent (Steven Rostedt)
- Fix time stamp rounding issue in libtraceevent (Chaos.Chen)
Infrastructure:
- Fix double free on 'command_line' in a error path in 'perf script' (Colin Ian King)
- Initialize struct sigaction 'sa_flags' field in a 'perf test' entri (Colin Ian King)
- Fix various build warnings in turbostat, detected with gcc6 (Colin Ian King)
- Use .s extension for preprocessed assembler code (Masahiro Yamada)
----------------------------------------------------------------
The following changes since commit 575a02e00b11eecbbabcb1eb22eab4c68e91ae77:
perf record: Ensure return non-zero rc when mmap fail (2016-02-29 12:44:15 -0300)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-20160302
for you to fetch changes up to 575197b405c45959ca2f71da8c65b6f8d9693140:
perf stat: Check for frontend stalled for metrics (2016-03-02 11:27:00 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
User visible:
- Implement CSV metrics output in 'perf stat' (Andi Kleen)
- Support metrics in 'perf stat' --per-core/socket mode (Andi Kleen)
- Check for frontend stalled for metrics (Andi Kleen)
- Fix segfault in 'perf test' hists related entries (Arnaldo Carvalho de Melo)
- Fix output of %llu for 64 bit values read on 32 bit machines in libtraceevent (Steven Rostedt)
- Fix time stamp rounding issue in libtraceevent (Chaos.Chen)
Infrastructure:
- Fix double free on 'command_line' in a error path in 'perf script' (Colin Ian King)
- Initialize struct sigaction 'sa_flags' field in a 'perf test' entri (Colin Ian King)
- Fix various build warnings in turbostat, detected with gcc6 (Colin Ian King)
- Use .s extension for preprocessed assembler code (Masahiro Yamada)
----------------------------------------------------------------
Andi Kleen (3):
perf stat: Implement CSV metrics output perf stat: Support metrics in --per-core/socket mode perf stat: Check for frontend stalled for metrics
Arnaldo Carvalho de Melo (1):
perf test: Fix hists related entries
Chaos.Chen (1):
tools lib traceevent: Fix time stamp rounding issue
Colin Ian King (3):
perf script: Fix double free on command_line perf tests: Initialize sa.sa_flags tools/power turbostat: fix various build warnings
Masahiro Yamada (1):
tools build: Use .s extension for preprocessed assembler code
Steven Rostedt (Red Hat) (2):
tools lib traceevent: Set int_array fields to NULL if freeing from error tools lib traceevent: Fix output of %llu for 64 bit values read on 32 bit machines
tools/build/Makefile.build | 2 +- tools/lib/traceevent/event-parse.c | 10 +- tools/perf/arch/x86/tests/rdpmc.c | 1 + tools/perf/builtin-stat.c | 136 +++++++++++++++++++-- .../util/scripting-engines/trace-event-python.c | 4 +- tools/perf/util/sort.c | 37 +++--- tools/perf/util/stat-shadow.c | 18 ++- tools/perf/util/stat.h | 1 + tools/power/x86/turbostat/turbostat.c | 8 +- 9 files changed, 181 insertions(+), 36 deletions(-)
Arnaldo Carvalho de Melo
maintainerPATCH 1/11 perf stat: Implement CSV metrics output
From: Andi Kleen <[email protected]>
Now support CSV output for metrics. With the new output callbacks this is relatively straight forward by creating new callbacks.
This allows to easily plot metrics from CSV files.
The new line callback needs to know the number of fields to skip them correctly
Example output before:
% perf stat -x, true 0.200687,,task-clock,200687,100.00 0,,context-switches,200687,100.00 0,,cpu-migrations,200687,100.00 40,,page-faults,200687,100.00 730871,,cycles,203601,100.00 551056,,stalled-cycles-frontend,203601,100.00 <not supported>,,stalled-cycles-backend,0,100.00 385523,,instructions,203601,100.00 78028,,branches,203601,100.00 3946,,branch-misses,203601,100.00
After:
% perf stat -x, true .502457,,task-clock,502457,100.00,0.485,CPUs utilized 0,,context-switches,502457,100.00,0.000,K/sec 0,,cpu-migrations,502457,100.00,0.000,K/sec 45,,page-faults,502457,100.00,0.090,M/sec 644692,,cycles,509102,100.00,1.283,GHz 423470,,stalled-cycles-frontend,509102,100.00,65.69,frontend cycles idle <not supported>,,stalled-cycles-backend,0,100.00,,,, 492701,,instructions,509102,100.00,0.76,insn per cycle ,,,,,0.86,stalled cycles per insn 97767,,branches,509102,100.00,194.578,M/sec 4788,,branch-misses,509102,100.00,4.90,of all branches
or easier readable
$ perf stat -x, -o x.csv true
$ column -s, -t x.csv
0.490635 task-clock 490635 100.00 0.489 CPUs utilized
0 context-switches 490635 100.00 0.000 K/sec
0 cpu-migrations 490635 100.00 0.000 K/sec
45 page-faults 490635 100.00 0.092 M/sec
629080 cycles 497698 100.00 1.282 GHz
409498 stalled-cycles-frontend 497698 100.00 65.09 frontend cycles idle
<not supported> stalled-cycles-backend 0 100.00
491424 instructions 497698 100.00 0.78 insn per cycle
0.83 stalled cycles per insn
97278 branches 497698 100.00 198.270 M/sec
4569 branch-misses 497698 100.00 4.70 of all branchesTwo new fields are added: metric value and metric name.
v2: Split out function argument changes
v3: Reenable metrics for real.
v4: Fix wrong hunk from refactoring.
v5: Remove extra "noise" printing (Jiri), but add it to the not counted case. Print empty metrics for not counted.
v6: Avoid outputting metric on empty format.
v7: Print metric at the end
v8: Remove extra run, ena fields
v9: Avoid extra new line for unsupported counters
--- tools/perf/builtin-stat.c | 73 ++++++++++++++++++++++++++++++++++++++++--- tools/perf/util/stat-shadow.c | 2 +- 2 files changed, 70 insertions(+), 5 deletions(-)
tools/perf/builtin-stat.c +69 -4
@@ -739,6 +739,7 @@ struct outstate {FILE *fh;bool newline;const char *prefix; +int nfields; };#define METRIC_LEN 35
@@ -789,6 +790,43 @@ static void print_metric_std(void *ctx, const char *color, const char *fmt,fprintf (out," %-*s" ,METRIC_LEN - n -1 , unit); } +static void new_line_csv (void *ctx) +{ +struct outstate *os = ctx; +int i; + +fputc ('\n' , os->fh); +if (os->prefix) +fprintf (os->fh,"%s%s" , os->prefix, csv_sep); +for (i =0 ; i < os->nfields; i++) +fputs (csv_sep, os->fh); +} + +static void print_metric_csv (void *ctx, +const char *color__maybe_unused , +const char *fmt,const char *unit,double val) +{ +struct outstate *os = ctx; +FILE *out = os->fh; +char buf[64 ], *vals, *ends; + +if (unit ==NULL || fmt ==NULL ) { +fprintf (out,"%s%s%s%s" , csv_sep, csv_sep, csv_sep, csv_sep); +return ; + } +snprintf (buf,sizeof (buf), fmt, val); + vals = buf; +while (isspace (*vals)) + vals++; + ends = vals; +while (isdigit (*ends) || *ends =='.' ) + ends++; + *ends =0 ; +while (isspace (*unit)) + unit++; +fprintf (out,"%s%s%s%s" , csv_sep, vals, csv_sep, unit); +} +static void nsec_printout (int id,int nr,struct perf_evsel *evsel,double avg) {FILE *output = stat_config.output;
@@ -860,6 +898,22 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval, nl = new_line_std; +if (csv_output) { +static int aggr_fields[] = { + [AGGR_GLOBAL ] =0 , + [AGGR_THREAD ] =1 , + [AGGR_NONE ] =1 , + [AGGR_SOCKET ] =2 , + [AGGR_CORE ] =2 , + }; + + pm = print_metric_csv; + nl = new_line_csv; + os.nfields =3 ; + os.nfields += aggr_fields[stat_config.aggr_mode]; +if (counter->cgrp) + os.nfields++; + }if (run ==0 || ena ==0 || counter->counts->scaled ==-1 ) {aggr_printout (counter, id, nr);
@@ -880,7 +934,12 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval,fprintf (stat_config.output,"%s%s" , csv_sep, counter->cgrp->name); +if (!csv_output) +pm (&os,NULL ,NULL ,"" ,0 ); +print_noise (counter, noise);print_running (run, ena); +if (csv_output) +pm (&os,NULL ,NULL ,"" ,0 );return ; }
@@ -893,14 +952,20 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval, out.new_line = nl; out.ctx = &os; -if (!csv_output) -perf_stat__print_shadow_stats (counter, uval, +if (csv_output) { +print_noise (counter, noise); +print_running (run, ena); + } + +perf_stat__print_shadow_stats (counter, uval, stat_config.aggr_mode ==AGGR_GLOBAL ?0 :cpu_map__id_to_cpu (id), &out); -print_noise (counter, noise); -print_running (run, ena); +if (!csv_output) { +print_noise (counter, noise); +print_running (run, ena); + } }static void print_aggr (char *prefix)
tools/perf/util/stat-shadow.c +1 -1
@@ -310,8 +310,8 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, total =avg_stats (&runtime_stalled_cycles_front_stats[ctx][cpu]); total =max (total,avg_stats (&runtime_stalled_cycles_back_stats[ctx][cpu])); - out->new_line (ctxp);if (total && avg) { + out->new_line (ctxp); ratio = total / avg; print_metric(ctxp, NULL, "%7.2f ", "stalled cycles per insn",
Signature · 1 line
2.5.0
Arnaldo Carvalho de Melo
maintainerPATCH 2/11 perf stat: Support metrics in --per-core/socket mode
In reply to Arnaldo Carvalho de MeloFrom: Andi Kleen <[email protected]>
Enable metrics printing in --per-core / --per-socket mode. We need to save the shadow metrics in a unique place. Always use the first CPU in the aggregation. Then use the same CPU to retrieve the shadow value later.
Example output:
% perf stat --per-core -a ./BC1s
Performance counter stats for 'system wide':
S0-C0 2 2966.020381 task-clock (msec) # 2.004 CPUs utilized (100.00%) S0-C0 2 49 context-switches # 0.017 K/sec (100.00%) S0-C0 2 4 cpu-migrations # 0.001 K/sec (100.00%) S0-C0 2 467 page-faults # 0.157 K/sec S0-C0 2 4,599,061,773 cycles # 1.551 GHz (100.00%) S0-C0 2 9,755,886,883 instructions # 2.12 insn per cycle (100.00%) S0-C0 2 1,906,272,125 branches # 642.704 M/sec (100.00%) S0-C0 2 81,180,867 branch-misses # 4.26% of all branches S0-C1 2 2965.995373 task-clock (msec) # 2.003 CPUs utilized (100.00%) S0-C1 2 62 context-switches # 0.021 K/sec (100.00%) S0-C1 2 8 cpu-migrations # 0.003 K/sec (100.00%) S0-C1 2 281 page-faults # 0.095 K/sec S0-C1 2 6,347,290 cycles # 0.002 GHz (100.00%) S0-C1 2 4,654,156 instructions # 0.73 insn per cycle (100.00%) S0-C1 2 947,121 branches # 0.319 M/sec (100.00%) S0-C1 2 37,322 branch-misses # 3.94% of all branches
1.480409747 seconds time elapsed
v2: Rebase to older patches
v3: Document shadow cpus. Fix aggr_get_id argument. Fix -A shadows (Jiri)
--- tools/perf/builtin-stat.c | 64 +++++++++++++++++++++++++++++++++++++------ tools/perf/util/stat-shadow.c | 7 +++++ 2 files changed, 63 insertions(+), 8 deletions(-)
tools/perf/builtin-stat.c +56 -8
@@ -740,6 +740,8 @@ struct outstate {bool newline;const char *prefix;int nfields; +int id, nr; +struct perf_evsel *evsel; };#define METRIC_LEN 35
@@ -755,12 +757,9 @@ static void do_new_line_std(struct outstate *os) {fputc ('\n' , os->fh);fputs (os->prefix, os->fh); +aggr_printout (os->evsel, os->id, os->nr);if (stat_config.aggr_mode ==AGGR_NONE )fprintf (os->fh," " ); -if (stat_config.aggr_mode ==AGGR_CORE ) -fprintf (os->fh," " ); -if (stat_config.aggr_mode ==AGGR_SOCKET ) -fprintf (os->fh," " );fprintf (os->fh," " ); }
@@ -798,6 +797,7 @@ static void new_line_csv(void *ctx)fputc ('\n' , os->fh);if (os->prefix)fprintf (os->fh,"%s%s" , os->prefix, csv_sep); +aggr_printout (os->evsel, os->id, os->nr);for (i =0 ; i < os->nfields; i++)fputs (csv_sep, os->fh); }
@@ -855,6 +855,28 @@ static void nsec_printout(int id, int nr, struct perf_evsel *evsel, double avg)fprintf (output,"%s%s" , csv_sep, evsel->cgrp->name); } +static int first_shadow_cpu (struct perf_evsel *evsel,int id) +{ +int i; + +if (!aggr_get_id) +return 0 ; + +if (stat_config.aggr_mode ==AGGR_NONE ) +return id; + +if (stat_config.aggr_mode ==AGGR_GLOBAL ) +return 0 ; + +for (i =0 ; i <perf_evsel__nr_cpus (evsel); i++) { +int cpu2 =perf_evsel__cpus (evsel)->map[i]; + +if (aggr_get_id (evsel_list->cpus, cpu2) == id) +return cpu2; + } +return 0 ; +} +static void abs_printout (int id,int nr,struct perf_evsel *evsel,double avg) {FILE *output = stat_config.output;
@@ -891,7 +913,10 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval,struct perf_stat_output_ctx out;struct outstate os = { .fh = stat_config.output, - .prefix = prefix ? prefix :"" + .prefix = prefix ? prefix :"" , + .id = id, + .nr = nr, + .evsel = counter, };print_metric_t pm = print_metric_std;void (*nl)(void *);
@@ -958,16 +983,37 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval, }perf_stat__print_shadow_stats (counter, uval, - stat_config.aggr_mode ==AGGR_GLOBAL ?0 : -cpu_map__id_to_cpu (id), +first_shadow_cpu (counter, id), &out); -if (!csv_output) {print_noise (counter, noise);print_running (run, ena); } } +static void aggr_update_shadow (void ) +{ +int cpu, s2, id, s; +u64 val; +struct perf_evsel *counter; + +for (s =0 ; s < aggr_map->nr; s++) { + id = aggr_map->map[s]; +evlist__for_each (evsel_list, counter) { + val =0 ; +for (cpu =0 ; cpu <perf_evsel__nr_cpus (counter); cpu++) { + s2 =aggr_get_id (evsel_list->cpus, cpu); +if (s2 != id) +continue ; + val +=perf_counts (counter->counts, cpu,0 )->val; + } + val = val * counter->scale; +perf_stat__update_shadow_stats (counter, &val, +first_shadow_cpu (counter, id)); + } + } +} +static void print_aggr (char *prefix) {FILE *output = stat_config.output;
@@ -979,6 +1025,8 @@ static void print_aggr(char *prefix)if (!(aggr_map || aggr_get_id))return ; +aggr_update_shadow (); +for (s =0 ; s < aggr_map->nr; s++) { id = aggr_map->map[s];evlist__for_each (evsel_list, counter) {
tools/perf/util/stat-shadow.c +7 -0
@@ -14,6 +14,13 @@ enum {#define NUM_CTX CTX_BIT_MAX +/* +* AGGR_GLOBAL: Use CPU 0 +* AGGR_SOCKET: Use first CPU of socket +* AGGR_CORE: Use first CPU of core +* AGGR_NONE: Use matching CPU +* AGGR_THREAD: Not supported? +*/ static struct stats runtime_nsecs_stats[MAX_NR_CPUS ];static struct stats runtime_cycles_stats[NUM_CTX ][MAX_NR_CPUS ];static struct stats runtime_stalled_cycles_front_stats[NUM_CTX ][MAX_NR_CPUS ];
Signature · 1 line
2.5.0
Arnaldo Carvalho de Melo
maintainerPATCH 3/11 tools build: Use .s extension for preprocessed assembler code
In reply to Arnaldo Carvalho de MeloFrom: Masahiro Yamada <[email protected]>
The "man gcc" says .i extension represents the file is C source code that should not be preprocessed. Here, .s should be used.
For clarification,
.c ---(preprocess)---> .i .S ---(preprocess)---> .s
--- tools/build/Makefile.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/Makefile.build +1 -1
@@ -85,7 +85,7 @@ $(OUTPUT)%.i: %.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_i_c) -$(OUTPUT)%.i: %.S FORCE +$(OUTPUT)%.s: %.S FORCE $(call rule_mkdir) $(call if_changed_dep,cc_i_c)
Signature · 1 line
2.5.0
Arnaldo Carvalho de Melo
maintainerPATCH 4/11 perf script: Fix double free on command_line
In reply to Arnaldo Carvalho de MeloFrom: Colin Ian King <[email protected]>
The 'command_line' variable is free'd twice if db_export__branch_types() fails. To avoid this, defer the free'ing of 'command_line' to after this call so that the error return path will just free 'command_line' once.
--- tools/perf/util/scripting-engines/trace-event-python.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/scripting-engines/trace-event-python.c +2 -2
@@ -1094,8 +1094,6 @@ static int python_start_script(const char *script, int argc, const char **argv) goto error; } -free (command_line); -set_table_handlers (tables);if (tables->db_export_mode) {
@@ -1104,6 +1102,8 @@ static int python_start_script(const char *script, int argc, const char **argv) goto error; } +free (command_line); +return err; error:Py_Finalize ();
Signature · 1 line
2.5.0
Arnaldo Carvalho de Melo
maintainerPATCH 5/11 tools lib traceevent: Fix time stamp rounding issue
In reply to Arnaldo Carvalho de MeloFrom: "Chaos.Chen" <[email protected]>
When rounding to microseconds, if the timestamp subsecond is between .999999500 and .999999999, it is rounded to .1000000, when it should instead increment the second counter due to the overflow.
For example, if the timestamp is 1234.999999501 instead of seeing:
1235.000000
we see:
1234.1000000
--- tools/lib/traceevent/event-parse.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/lib/traceevent/event-parse.c +5 -0
@@ -5429,6 +5429,11 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, p =9 ; }else { usecs = (nsecs +500 ) /NSECS_PER_USEC ; +/* To avoid usecs larger than 1 sec */ +if (usecs >=1000000 ) { + usecs -=1000000 ; + secs++; + } p =6 ; }
Signature · 1 line
2.5.0
Arnaldo Carvalho de Melo
maintainerPATCH 6/11 tools lib traceevent: Set int_array fields to NULL if freeing from error
In reply to Arnaldo Carvalho de MeloFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Had a bug where on error of parsing __print_array() where the fields are freed after they were allocated, but since they were not set to NULL, the freeing of the arg also tried to free the already freed fields causing a double free.
Fix process_hex() while at it.
--- tools/lib/traceevent/event-parse.c | 3 +++ 1 file changed, 3 insertions(+)
tools/lib/traceevent/event-parse.c +3 -0
@@ -2635,6 +2635,7 @@ process_hex(struct event_format *event, struct print_arg *arg, char **tok) free_field:free_arg (arg->hex.field); + arg->hex.field =NULL ; out: *tok =NULL ;return EVENT_ERROR ;
@@ -2659,8 +2660,10 @@ process_int_array(struct event_format *event, struct print_arg *arg, char **tok) free_size:free_arg (arg->int_array.count); + arg->int_array.count =NULL ; free_field:free_arg (arg->int_array.field); + arg->int_array.field =NULL ; out: *tok =NULL ;return EVENT_ERROR ;
Signature · 1 line
2.5.0
Arnaldo Carvalho de Melo
maintainerPATCH 7/11 tools lib traceevent: Fix output of %llu for 64 bit values read on 32 bit machines
In reply to Arnaldo Carvalho de MeloFrom: "Steven Rostedt (Red Hat)" <[email protected]>
When a long value is read on 32 bit machines for 64 bit output, the parsing needs to change "%lu" into "%llu", as the value is read natively.
Unfortunately, if "%llu" is already there, the code will add another "l" to it and fail to parse it properly.
--- tools/lib/traceevent/event-parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +1 -1
@@ -4978,7 +4978,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct eventbreak ; } } -if (pevent->long_size ==8 && ls && +if (pevent->long_size ==8 && ls ==1 &&sizeof (long ) !=8 ) {char *p;
Signature · 1 line
2.5.0
Arnaldo Carvalho de Melo
maintainerPATCH 8/11 perf test: Fix hists related entries
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
That got broken by d3a72fd8187b ("perf report: Fix indentation of dynamic entries in hierarchy"), by using the evlist in setup_sorting() without checking if it is NULL, as done in some 'perf test' entries:
$ find tools/ -name "*.c" | xargs grep 'setup_sorting(NULL);' tools/perf/tests/hists_output.c: setup_sorting(NULL); tools/perf/tests/hists_output.c: setup_sorting(NULL); tools/perf/tests/hists_output.c: setup_sorting(NULL); tools/perf/tests/hists_output.c: setup_sorting(NULL); tools/perf/tests/hists_output.c: setup_sorting(NULL); tools/perf/tests/hists_cumulate.c: setup_sorting(NULL); tools/perf/tests/hists_cumulate.c: setup_sorting(NULL); tools/perf/tests/hists_cumulate.c: setup_sorting(NULL); tools/perf/tests/hists_cumulate.c: setup_sorting(NULL); $
Fix it.
Before:
[root@jouet ~]# perf test
<SNIP>
15: Test matching and linking multiple hists : FAILED! 16: Try 'import perf' in python, checking link problems : Ok 17: Test breakpoint overflow signal handler : Ok 18: Test breakpoint overflow sampling : Ok 19: Test number of exit event of a simple workload : Ok 20: Test software clock events have valid period values : Ok 21: Test object code reading : Ok 22: Test sample parsing : Ok 23: Test using a dummy software event to keep tracking : Ok 24: Test parsing with no sample_id_all bit set : Ok 25: Test filtering hist entries : FAILED! 26: Test mmap thread lookup : Ok 27: Test thread mg sharing : Ok 28: Test output sorting of hist entries : FAILED! 29: Test cumulation of child hist entries : FAILED!
<SNIP>
After the patch the above failed tests complete successfully.
--- tools/perf/util/sort.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
tools/perf/util/sort.c +22 -15
@@ -2635,25 +2635,14 @@ out:return ret; } -int setup_sorting (struct perf_evlist *evlist) +static void evlist__set_hists_nr_sort_keys (struct perf_evlist *evlist) { -int err; -struct hists *hists;struct perf_evsel *evsel; -struct perf_hpp_fmt *fmt; - - err =__setup_sorting (evlist); -if (err <0 ) -return err; - -if (parent_pattern != default_parent_pattern) { - err =sort_dimension__add ("parent" , evlist); -if (err <0 ) -return err; - }evlist__for_each (evlist, evsel) { - hists =evsel__hists (evsel); +struct perf_hpp_fmt *fmt; +struct hists *hists =evsel__hists (evsel); + hists->nr_sort_keys = perf_hpp_list.nr_sort_keys;/*
@@ -2667,6 +2656,24 @@ int setup_sorting(struct perf_evlist *evlist) hists->nr_sort_keys--; } } +} + +int setup_sorting (struct perf_evlist *evlist) +{ +int err; + + err =__setup_sorting (evlist); +if (err <0 ) +return err; + +if (parent_pattern != default_parent_pattern) { + err =sort_dimension__add ("parent" , evlist); +if (err <0 ) +return err; + } + +if (evlist !=NULL ) +evlist__set_hists_nr_sort_keys (evlist);reset_dimensions ();
Signature · 1 line
2.5.0
Arnaldo Carvalho de Melo
maintainerPATCH 9/11 perf tests: Initialize sa.sa_flags
In reply to Arnaldo Carvalho de MeloFrom: Colin Ian King <[email protected]>
The sa_flags field is not being initialized, so a garbage value is being passed to sigaction. Initialize it to zero.
--- tools/perf/arch/x86/tests/rdpmc.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/arch/x86/tests/rdpmc.c +1 -0
@@ -103,6 +103,7 @@ static int __test__rdpmc(void)sigfillset (&sa.sa_mask); sa.sa_sigaction = segfault_handler; + sa.sa_flags =0 ;sigaction (SIGSEGV , &sa,NULL ); fd = sys_perf_event_open(&attr, 0, -1, -1,
Signature · 1 line
2.5.0
Arnaldo Carvalho de Melo
maintainerPATCH 10/11 tools/power turbostat: fix various build warnings
In reply to Arnaldo Carvalho de MeloFrom: Colin Ian King <[email protected]>
When building with gcc 6 we're getting various build warnings that just require some trivial function declaration and call fixes:
turbostat.c: In function ‘dump_cstate_pstate_config_info’:
turbostat.c:1973:1: warning: type of ‘family’ defaults to ‘int’
dump_cstate_pstate_config_info(family, model)
turbostat.c:1973:1: warning: type of ‘model’ defaults to ‘int’ turbostat.c: In function ‘get_tdp’:
turbostat.c:2145:8: warning: type of ‘model’ defaults to ‘int’
double get_tdp(model)
turbostat.c: In function ‘perf_limit_reasons_probe’:
turbostat.c:2259:6: warning: type of ‘family’ defaults to ‘int’
void perf_limit_reasons_probe(family, model)
turbostat.c:2259:6: warning: type of ‘model’ defaults to ‘int’
--- tools/power/x86/turbostat/turbostat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/power/x86/turbostat/turbostat.c +4 -4
@@ -1970,7 +1970,7 @@ int has_config_tdp(unsigned int family, unsigned int model) }static void -dump_cstate_pstate_config_info (family ,model ) +dump_cstate_pstate_config_info (unsigned int family,unsigned int model) {if (!do_nhm_platform_info)return ;
@@ -2142,7 +2142,7 @@ int print_perf_limit(struct thread_data *t, struct core_data *c, struct pkg_data#define RAPL_POWER_GRANULARITY 0x7FFF/* 15 bit power granularity */ #define RAPL_TIME_GRANULARITY 0x3F/* 6 bit time granularity */ -double get_tdp (model ) +double get_tdp (unsigned int model) {unsigned long long msr;
@@ -2256,7 +2256,7 @@ void rapl_probe(unsigned int family, unsigned int model)return ; } -void perf_limit_reasons_probe (family ,model ) +void perf_limit_reasons_probe (unsigned int family,unsigned int model) {if (!genuine_intel)return ;
@@ -2792,7 +2792,7 @@ void process_cpuid()perf_limit_reasons_probe (family, model);if (debug) -dump_cstate_pstate_config_info (); +dump_cstate_pstate_config_info (family, model);if (has_skl_msrs (family, model))calculate_tsc_tweak ();
Signature · 1 line
2.5.0
Arnaldo Carvalho de Melo
maintainerPATCH 11/11 perf stat: Check for frontend stalled for metrics
In reply to Arnaldo Carvalho de MeloFrom: Andi Kleen <[email protected]>
Add an extra check for frontend stalled in the metrics. This avoids an extra column for the --metric-only case when the CPU does not support frontend stalled.
v2: Add separate init function
--- tools/perf/builtin-stat.c | 1 + tools/perf/util/stat-shadow.c | 9 ++++++++- tools/perf/util/stat.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-)
tools/perf/builtin-stat.c +1 -0
@@ -1966,6 +1966,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) argc =parse_options_subcommand (argc, argv, stat_options, stat_subcommands, (const char **) stat_usage,PARSE_OPT_STOP_AT_NON_OPTION ); +perf_stat__init_shadow_stats ();if (csv_sep) { csv_output = true;
tools/perf/util/stat-shadow.c +8 -1
@@ -2,6 +2,7 @@#include "evsel.h" #include "stat.h" #include "color.h" +#include "pmu.h" enum {CTX_BIT_USER =1 <<0 ,
@@ -35,9 +36,15 @@ static struct stats runtime_dtlb_cache_stats[NUM_CTX][MAX_NR_CPUS];static struct stats runtime_cycles_in_tx_stats[NUM_CTX ][MAX_NR_CPUS ];static struct stats runtime_transaction_stats[NUM_CTX ][MAX_NR_CPUS ];static struct stats runtime_elision_stats[NUM_CTX ][MAX_NR_CPUS ]; +static bool have_frontend_stalled;struct stats walltime_nsecs_stats; +void perf_stat__init_shadow_stats (void ) +{ + have_frontend_stalled =pmu_have_event ("cpu" ,"stalled-cycles-frontend" ); +} +static int evsel_context (struct perf_evsel *evsel) {int ctx =0 ;
@@ -323,7 +330,7 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,print_metric (ctxp,NULL ,"%7.2f " ,"stalled cycles per insn" , ratio); - }else { + }else if (have_frontend_stalled) {print_metric (ctxp,NULL ,NULL ,"stalled cycles per insn" ,0 ); }
tools/perf/util/stat.h +1 -0
@@ -72,6 +72,7 @@ typedef void (*print_metric_t)(void *ctx, const char *color, const char *unit, const char *fmt, double val);typedef void (*new_line_t )(void *ctx); +void perf_stat__init_shadow_stats (void );void perf_stat__reset_shadow_stats (void );void perf_stat__update_shadow_stats (struct perf_evsel *counter,u64 *count,int cpu);
Signature · 1 line
2.5.0