perf c2c report: Change default HITM sort/display
Jiri Olsa
reviewercover perf c2c report: Change default HITM sort/display
hi,
sending the c2c default HITM sort/display fix (patch 4,5) plus few other small fixes.
Also available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixes
thanks,
jirka
---
Jiri Olsa (6):
perf tools: Show event fd in debug output perf c2c report: Setup browser after opening perf.data perf c2c report: Add -f/--force option
perf c2c report: Add struct c2c_stats::tot_hitm field perf c2c report: Display total HITMs on default perf c2c: Support cascading options
tools/perf/Documentation/perf-c2c.txt | 8 ++++++++ tools/perf/builtin-c2c.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------- tools/perf/util/evsel.c | 6 ++++-- tools/perf/util/mem-events.c | 12 ++++++++++-- tools/perf/util/mem-events.h | 1 + 5 files changed, 76 insertions(+), 31 deletions(-)
Jiri Olsa
reviewerPATCH 1/6 perf tools: Show event fd in debug output
It was useful for debug to see file descriptors for each event.
Before:
$ perf stat -vvv -e cycles,cache-misses ls ... sys_perf_event_open: pid 12146 cpu -1 group_fd -1 flags 0x8 ... sys_perf_event_open: pid 12146 cpu -1 group_fd 3 flags 0x8 sys_perf_event_open failed, error -13
Now:
$ perf stat -vvv -e cycles,cache-misses ls ... sys_perf_event_open: pid 12858 cpu -1 group_fd -1 flags 0x8 = 3 ... sys_perf_event_open: pid 12858 cpu -1 group_fd 3 flags 0x8 sys_perf_event_open failed, error -13
--- tools/perf/util/evsel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/evsel.c +4 -2
@@ -1481,7 +1481,7 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, group_fd =get_group_fd (evsel, cpu, thread); retry_open: -pr_debug2 ("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx\n" , +pr_debug2 ("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx" , pid, cpus->map[cpu], group_fd, flags); FD(evsel, cpu, thread) = sys_perf_event_open(&evsel->attr,
@@ -1490,11 +1490,13 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, group_fd, flags);if (FD (evsel, cpu, thread) <0 ) { err = -errno; -pr_debug2 ("sys_perf_event_open failed, error %d\n" , +pr_debug2 ("\nsys_perf_event_open failed, error %d\n" , err); goto try_fallback; } +pr_debug2 (" = %d\n" ,FD (evsel, cpu, thread)); +if (evsel->bpf_fd >=0 ) {int evt_fd =FD (evsel, cpu, thread);int bpf_fd = evsel->bpf_fd;
Signature · 1 line
2.7.4
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Show event fd in debug output
perf tools: Show event fd in debug output
Commit-ID: 7b4b82bced0755aecc026d8c14c2608aa0f9e89b Gitweb: http://git.kernel.org/tip/7b4b82bced0755aecc026d8c14c2608aa0f9e89b Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 21 Nov 2016 22:33:26 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 23 Nov 2016 10:44:03 -0300
perf tools: Show event fd in debug output
It is useful for debug to see file descriptors for each event.
Before:
$ perf stat -vvv -e cycles,cache-misses ls ... sys_perf_event_open: pid 12146 cpu -1 group_fd -1 flags 0x8 ... sys_perf_event_open: pid 12146 cpu -1 group_fd 3 flags 0x8 sys_perf_event_open failed, error -13
Now:
$ perf stat -vvv -e cycles,cache-misses ls ... sys_perf_event_open: pid 12858 cpu -1 group_fd -1 flags 0x8 = 3 ... sys_perf_event_open: pid 12858 cpu -1 group_fd 3 flags 0x8 sys_perf_event_open failed, error -13
--- tools/perf/util/evsel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/evsel.c +4 -2
@@ -1481,7 +1481,7 @@ retry_sample_id: group_fd =get_group_fd (evsel, cpu, thread); retry_open: -pr_debug2 ("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx\n" , +pr_debug2 ("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx" , pid, cpus->map[cpu], group_fd, flags); FD(evsel, cpu, thread) = sys_perf_event_open(&evsel->attr,
@@ -1490,11 +1490,13 @@ retry_open: group_fd, flags);if (FD (evsel, cpu, thread) <0 ) { err = -errno; -pr_debug2 ("sys_perf_event_open failed, error %d\n" , +pr_debug2 ("\nsys_perf_event_open failed, error %d\n" , err); goto try_fallback; } +pr_debug2 (" = %d\n" ,FD (evsel, cpu, thread)); +if (evsel->bpf_fd >=0 ) {int evt_fd =FD (evsel, cpu, thread);int bpf_fd = evsel->bpf_fd;
Jiri Olsa
reviewerPATCH 2/6 perf c2c report: Setup browser after opening perf.data
In reply to Jiri OlsaBecause of the early browser switch we won't get possible error messages, like for:
$ sudo perf c2c report -d lcl File perf.data not owned by current user or root (use -f to override)
--- tools/perf/builtin-c2c.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
tools/perf/builtin-c2c.c +8 -7
@@ -2535,13 +2535,6 @@ static int perf_c2c__report(int argc, const char **argv)if (c2c.stats_only) c2c.use_stdio = true; -if (c2c.use_stdio) - use_browser =0 ; -else - use_browser =1 ; - -setup_browser (false); -if (!input_name || !strlen (input_name)) input_name ="perf.data" ;
@@ -2568,6 +2561,7 @@ static int perf_c2c__report(int argc, const char **argv)pr_debug ("No memory for session\n" ); goto out; } + err =setup_nodes (session);if (err) {pr_err ("Failed setup nodes\n" );
@@ -2587,6 +2581,13 @@ static int perf_c2c__report(int argc, const char **argv) goto out_session; } +if (c2c.use_stdio) + use_browser =0 ; +else + use_browser =1 ; + +setup_browser (false); + err =perf_session__process_events (session);if (err) {pr_err ("failed to process sample\n" );
Signature · 1 line
2.7.4
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf c2c report: Setup browser after opening perf.data
perf c2c report: Setup browser after opening perf.data
Commit-ID: e8c5fe101e55e4c45a2859cea2b4c374595f8867 Gitweb: http://git.kernel.org/tip/e8c5fe101e55e4c45a2859cea2b4c374595f8867 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 21 Nov 2016 22:33:27 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 23 Nov 2016 10:44:04 -0300
perf c2c report: Setup browser after opening perf.data
Because of the early browser switch we won't get possible error messages, as it will clear the screen right after showing the message, e.g.:
Before:
$ sudo perf c2c report -d lcl $
After:
$ sudo perf c2c report -d lcl File perf.data not owned by current user or root (use -f to override) $ $ ls -la perf.data -rw-------. 1 acme acme 26648 Nov 22 15:11 perf.data $
--- tools/perf/builtin-c2c.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
tools/perf/builtin-c2c.c +8 -7
@@ -2535,13 +2535,6 @@ static int perf_c2c__report(int argc, const char **argv)if (c2c.stats_only) c2c.use_stdio = true; -if (c2c.use_stdio) - use_browser =0 ; -else - use_browser =1 ; - -setup_browser (false); -if (!input_name || !strlen (input_name)) input_name ="perf.data" ;
@@ -2568,6 +2561,7 @@ static int perf_c2c__report(int argc, const char **argv)pr_debug ("No memory for session\n" ); goto out; } + err =setup_nodes (session);if (err) {pr_err ("Failed setup nodes\n" );
@@ -2587,6 +2581,13 @@ static int perf_c2c__report(int argc, const char **argv) goto out_session; } +if (c2c.use_stdio) + use_browser =0 ; +else + use_browser =1 ; + +setup_browser (false); + err =perf_session__process_events (session);if (err) {pr_err ("failed to process sample\n" );
Jiri Olsa
reviewerPATCH 3/6 perf c2c report: Add -f/--force option
In reply to Jiri OlsaAdding -f/--force option to go through ownership validation:
$ sudo perf c2c report File perf.data not owned by current user or root (use -f to override)
$ sudo perf c2c report -f
--- tools/perf/Documentation/perf-c2c.txt | 4 ++++ tools/perf/builtin-c2c.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-c2c.txt +4 -0
@@ -100,6 +100,10 @@ REPORT OPTIONS --show-all:: Show all captured HITM lines, with no regard to HITM % 0.0005 limit. +-f:: +--force:: + Don't do ownership validation. + C2C RECORD ---------- The perf c2c record command setup options related to HITM cacheline analysis
tools/perf/builtin-c2c.c +3 -1
@@ -2523,6 +2523,7 @@ static int perf_c2c__report(int argc, const char **argv)OPT_STRING ('d' ,"display" , &display,NULL ,"lcl,rmt" ),OPT_STRING ('c' ,"coalesce" , &coalesce,"coalesce fields" ,"coalesce fields: pid,tid,iaddr,dso" ), +OPT_BOOLEAN ('f' ,"force" , &symbol_conf.force,"don't complain, do it" ), OPT_END() };int err =0 ;
@@ -2538,7 +2539,8 @@ static int perf_c2c__report(int argc, const char **argv)if (!input_name || !strlen (input_name)) input_name ="perf.data" ; - file.path = input_name; + file.path = input_name; + file.force = symbol_conf.force; err =setup_display (display);if (err)
Signature · 1 line
2.7.4
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf c2c report: Add -f/--force option
perf c2c report: Add -f/--force option
Commit-ID: b7ac4f9f3b2532b4e3dcd3d402c405c46a8ec811 Gitweb: http://git.kernel.org/tip/b7ac4f9f3b2532b4e3dcd3d402c405c46a8ec811 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 21 Nov 2016 22:33:28 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 23 Nov 2016 10:44:04 -0300
perf c2c report: Add -f/--force option
Adding -f/--force option to go through ownership validation:
$ sudo perf c2c report File perf.data not owned by current user or root (use -f to override) $ $ sudo perf c2c report -f < c2c report output > $
--- tools/perf/Documentation/perf-c2c.txt | 4 ++++ tools/perf/builtin-c2c.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-c2c.txt +4 -0
@@ -100,6 +100,10 @@ REPORT OPTIONS --show-all:: Show all captured HITM lines, with no regard to HITM % 0.0005 limit. +-f:: +--force:: + Don't do ownership validation. + C2C RECORD ---------- The perf c2c record command setup options related to HITM cacheline analysis
tools/perf/builtin-c2c.c +3 -1
@@ -2523,6 +2523,7 @@ static int perf_c2c__report(int argc, const char **argv)OPT_STRING ('d' ,"display" , &display,NULL ,"lcl,rmt" ),OPT_STRING ('c' ,"coalesce" , &coalesce,"coalesce fields" ,"coalesce fields: pid,tid,iaddr,dso" ), +OPT_BOOLEAN ('f' ,"force" , &symbol_conf.force,"don't complain, do it" ), OPT_END() };int err =0 ;
@@ -2538,7 +2539,8 @@ static int perf_c2c__report(int argc, const char **argv)if (!input_name || !strlen (input_name)) input_name ="perf.data" ; - file.path = input_name; + file.path = input_name; + file.force = symbol_conf.force; err =setup_display (display);if (err)
Jiri Olsa
reviewerPATCH 4/6 perf c2c report: Add struct c2c_stats::tot_hitm field
In reply to Jiri OlsaCounting total HITMs in special field. This will ease up addition of total HITM sorting into c2c report in following patch.
--- tools/perf/util/mem-events.c | 12 ++++++++++-- tools/perf/util/mem-events.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-)
tools/perf/util/mem-events.c +10 -2
@@ -280,6 +280,12 @@ int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi)u64 lock = data_src->mem_lock;int err =0 ; +#define HITM_INC (__f) \ +do { \ + stats->__f++; \ + stats->tot_hitm++; \ +} while (0) +#define P (a, b) PERF_MEM_##a##_##b stats->nr_entries++;
@@ -303,7 +309,7 @@ int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi)if (lvl &P (LVL ,L2 )) stats->ld_l2hit++;if (lvl &P (LVL ,L3 )) {if (snoop &P (SNOOP ,HITM )) - stats->lcl_hitm++; +HITM_INC (lcl_hitm);else stats->ld_llchit++; }
@@ -331,7 +337,7 @@ int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi)if (snoop &P (SNOOP ,HIT )) stats->rmt_hit++;else if (snoop &P (SNOOP ,HITM )) - stats->rmt_hitm++; +HITM_INC (rmt_hitm); }if ((lvl &P (LVL ,MISS )))
@@ -364,6 +370,7 @@ int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi) }#undef P +#undef HITM_INCreturn err; }
@@ -390,6 +397,7 @@ void c2c_add_stats(struct c2c_stats *stats, struct c2c_stats *add) stats->ld_llchit += add->ld_llchit; stats->lcl_hitm += add->lcl_hitm; stats->rmt_hitm += add->rmt_hitm; + stats->tot_hitm += add->tot_hitm; stats->rmt_hit += add->rmt_hit; stats->lcl_dram += add->lcl_dram; stats->rmt_dram += add->rmt_dram;
tools/perf/util/mem-events.h +1 -0
@@ -59,6 +59,7 @@ struct c2c_stats {u32 ld_llchit;/* count of loads that hit LLC */ u32 lcl_hitm;/* count of loads with local HITM */ u32 rmt_hitm;/* count of loads with remote HITM */ +u32 tot_hitm;/* count of loads with local and remote HITM */ u32 rmt_hit;/* count of loads with remote hit clean; */ u32 lcl_dram;/* count of loads miss to local DRAM */ u32 rmt_dram;/* count of loads miss to remote DRAM */
Signature · 1 line
2.7.4
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf c2c report: Add struct c2c_stats::tot_hitm field
perf c2c report: Add struct c2c_stats::tot_hitm field
Commit-ID: dba8ab93792a3a864ff741efe435b2ecbdfb66b1 Gitweb: http://git.kernel.org/tip/dba8ab93792a3a864ff741efe435b2ecbdfb66b1 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 21 Nov 2016 22:33:29 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 23 Nov 2016 10:44:05 -0300
perf c2c report: Add struct c2c_stats::tot_hitm field
Count total number of HITMs in a special field. This will ease up addition of total HITM sorting into c2c report in the following patch.
--- tools/perf/util/mem-events.c | 12 ++++++++++-- tools/perf/util/mem-events.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-)
tools/perf/util/mem-events.c +10 -2
@@ -280,6 +280,12 @@ int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi)u64 lock = data_src->mem_lock;int err =0 ; +#define HITM_INC (__f) \ +do { \ + stats->__f++; \ + stats->tot_hitm++; \ +} while (0) +#define P (a, b) PERF_MEM_##a##_##b stats->nr_entries++;
@@ -303,7 +309,7 @@ int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi)if (lvl &P (LVL ,L2 )) stats->ld_l2hit++;if (lvl &P (LVL ,L3 )) {if (snoop &P (SNOOP ,HITM )) - stats->lcl_hitm++; +HITM_INC (lcl_hitm);else stats->ld_llchit++; }
@@ -331,7 +337,7 @@ int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi)if (snoop &P (SNOOP ,HIT )) stats->rmt_hit++;else if (snoop &P (SNOOP ,HITM )) - stats->rmt_hitm++; +HITM_INC (rmt_hitm); }if ((lvl &P (LVL ,MISS )))
@@ -364,6 +370,7 @@ int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi) }#undef P +#undef HITM_INCreturn err; }
@@ -390,6 +397,7 @@ void c2c_add_stats(struct c2c_stats *stats, struct c2c_stats *add) stats->ld_llchit += add->ld_llchit; stats->lcl_hitm += add->lcl_hitm; stats->rmt_hitm += add->rmt_hitm; + stats->tot_hitm += add->tot_hitm; stats->rmt_hit += add->rmt_hit; stats->lcl_dram += add->lcl_dram; stats->rmt_dram += add->rmt_dram;
tools/perf/util/mem-events.h +1 -0
@@ -59,6 +59,7 @@ struct c2c_stats {u32 ld_llchit;/* count of loads that hit LLC */ u32 lcl_hitm;/* count of loads with local HITM */ u32 rmt_hitm;/* count of loads with remote HITM */ +u32 tot_hitm;/* count of loads with local and remote HITM */ u32 rmt_hit;/* count of loads with remote hit clean; */ u32 lcl_dram;/* count of loads miss to local DRAM */ u32 rmt_dram;/* count of loads miss to remote DRAM */
Jiri Olsa
reviewerPATCH 5/6 perf c2c report: Display total HITMs on default
In reply to Jiri OlsaCurrently we display cacheline list sorted on remote HITMs by default.
The problem is that they might not be always counted and 'perf c2c report' displays empty output. Thus it's more convenient to display and sort cacheline list based on total HITMs and have the best change to see data in default report run.
--- tools/perf/Documentation/perf-c2c.txt | 4 ++++ tools/perf/builtin-c2c.c | 39 ++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 7 deletions(-)
tools/perf/Documentation/perf-c2c.txt +4 -0
@@ -104,6 +104,10 @@ REPORT OPTIONS --force:: Don't do ownership validation. +-d:: +--display:: + Siwtch to HITM type (rmt, lcl) to display and sort on. Total HITMs as default. + C2C RECORD ---------- The perf c2c record command setup options related to HITM cacheline analysis
tools/perf/builtin-c2c.c +32 -7
@@ -91,6 +91,14 @@ struct perf_c2c {enum {DISPLAY_LCL ,DISPLAY_RMT , +DISPLAY_TOT , +DISPLAY_MAX , +}; + +static const char *display_str[DISPLAY_MAX ] = { + [DISPLAY_LCL ] ="Local" , + [DISPLAY_RMT ] ="Remote" , + [DISPLAY_TOT ] ="Total" , };static struct perf_c2c c2c;
@@ -745,6 +753,10 @@ static double percent_hitm(struct c2c_hist_entry *c2c_he)case DISPLAY_LCL : st = stats->lcl_hitm; tot = total->lcl_hitm; +break ; +case DISPLAY_TOT : + st = stats->tot_hitm; + tot = total->tot_hitm;default :break ; }
@@ -1044,6 +1056,9 @@ node_entry(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp *hpp,break ;case DISPLAY_LCL :DISPLAY_HITM (lcl_hitm); +break ; +case DISPLAY_TOT : +DISPLAY_HITM (tot_hitm);default :break ; }
@@ -1351,6 +1366,7 @@ static struct c2c_dimension dim_tot_loads = {static struct c2c_header percent_hitm_header[] = { [DISPLAY_LCL ] =HEADER_BOTH ("Lcl" ,"Hitm" ), [DISPLAY_RMT ] =HEADER_BOTH ("Rmt" ,"Hitm" ), + [DISPLAY_TOT ] =HEADER_BOTH ("Tot" ,"Hitm" ), };static struct c2c_dimension dim_percent_hitm = {
@@ -1794,6 +1810,9 @@ static bool he__display(struct hist_entry *he, struct c2c_stats *stats)break ;case DISPLAY_RMT :FILTER_HITM (rmt_hitm); +break ; +case DISPLAY_TOT : +FILTER_HITM (tot_hitm);default :break ; };
@@ -1809,8 +1828,9 @@ static inline int valid_hitm_or_store(struct hist_entry *he)bool has_hitm; c2c_he = container_of(he, struct c2c_hist_entry, he); - has_hitm = c2c.display ==DISPLAY_LCL ? - c2c_he->stats.lcl_hitm : c2c_he->stats.rmt_hitm; + has_hitm = c2c.display ==DISPLAY_TOT ? c2c_he->stats.tot_hitm : + c2c.display ==DISPLAY_LCL ? c2c_he->stats.lcl_hitm : + c2c_he->stats.rmt_hitm;return has_hitm || c2c_he->stats.store; }
@@ -2095,7 +2115,7 @@ static void print_c2c_info(FILE *out, struct perf_session *session) first = false; }fprintf (out," Cachelines sort on : %s HITMs\n" , - c2c.display ==DISPLAY_LCL ?"Local" :"Remote" ); + display_str[c2c.display]);fprintf (out," Cacheline data grouping : %s\n" , c2c.cl_sort); }
@@ -2250,7 +2270,7 @@ static int perf_c2c_browser__title(struct hist_browser *browser,"Shared Data Cache Line Table " "(%lu entries, sorted on %s HITMs)" , browser->nr_non_filtered_entries, - c2c.display == DISPLAY_LCL ? "local" : "remote"); + display_str[c2c.display]);return 0 ; }
@@ -2387,9 +2407,11 @@ static int setup_callchain(struct perf_evlist *evlist)static int setup_display (const char *str) { -const char *display = str ?:"rmt" ; +const char *display = str ?:"tot" ; -if (!strcmp (display,"rmt" )) +if (!strcmp (display,"tot" )) + c2c.display =DISPLAY_TOT ; +else if (!strcmp (display,"rmt" )) c2c.display =DISPLAY_RMT ;else if (!strcmp (display,"lcl" )) c2c.display =DISPLAY_LCL ;
@@ -2474,6 +2496,8 @@ static int setup_coalesce(const char *coalesce, bool no_source)return -1 ;if (asprintf (&c2c.cl_resort,"offset,%s" , + c2c.display ==DISPLAY_TOT ? +"tot_hitm" : c2c.display ==DISPLAY_RMT ?"rmt_hitm,lcl_hitm" :"lcl_hitm,rmt_hitm" ) <0 )
@@ -2520,7 +2544,7 @@ static int perf_c2c__report(int argc, const char **argv) "print_type,threshold[,print_limit],order,sort_key[,branch],value", callchain_help, &parse_callchain_opt, callchain_default_opt), -OPT_STRING ('d' ,"display" , &display,NULL ,"lcl,rmt" ), +OPT_STRING ('d' ,"display" , &display,"Switch HITM output type" ,"lcl,rmt" ),OPT_STRING ('c' ,"coalesce" , &coalesce,"coalesce fields" ,"coalesce fields: pid,tid,iaddr,dso" ), OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
@@ -2608,6 +2632,7 @@ static int perf_c2c__report(int argc, const char **argv)"tot_loads," "ld_fbhit,ld_l1hit,ld_l2hit," "ld_lclhit,ld_rmthit" , + c2c.display ==DISPLAY_TOT ?"tot_hitm" : c2c.display ==DISPLAY_LCL ?"lcl_hitm" :"rmt_hitm" );
Signature · 1 line
2.7.4
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf c2c report: Display total HITMs on default
perf c2c report: Display total HITMs on default
Commit-ID: d940baccc990c29f0343843db7cf669bb8e91a6f Gitweb: http://git.kernel.org/tip/d940baccc990c29f0343843db7cf669bb8e91a6f Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 21 Nov 2016 22:33:30 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 23 Nov 2016 10:44:05 -0300
perf c2c report: Display total HITMs on default
Currently we display the cacheline list sorted on remote HITMs by default.
The problem is that they might not be always counted and 'perf c2c report' displays an empty output. Thus it's more convenient to display and sort the cacheline list based on the total of HITMs and have the best change to see data in the default report run.
--- tools/perf/Documentation/perf-c2c.txt | 4 ++++ tools/perf/builtin-c2c.c | 39 ++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 7 deletions(-)
tools/perf/Documentation/perf-c2c.txt +4 -0
@@ -104,6 +104,10 @@ REPORT OPTIONS --force:: Don't do ownership validation. +-d:: +--display:: + Siwtch to HITM type (rmt, lcl) to display and sort on. Total HITMs as default. + C2C RECORD ---------- The perf c2c record command setup options related to HITM cacheline analysis
tools/perf/builtin-c2c.c +32 -7
@@ -91,6 +91,14 @@ struct perf_c2c {enum {DISPLAY_LCL ,DISPLAY_RMT , +DISPLAY_TOT , +DISPLAY_MAX , +}; + +static const char *display_str[DISPLAY_MAX ] = { + [DISPLAY_LCL ] ="Local" , + [DISPLAY_RMT ] ="Remote" , + [DISPLAY_TOT ] ="Total" , };static struct perf_c2c c2c;
@@ -745,6 +753,10 @@ static double percent_hitm(struct c2c_hist_entry *c2c_he)case DISPLAY_LCL : st = stats->lcl_hitm; tot = total->lcl_hitm; +break ; +case DISPLAY_TOT : + st = stats->tot_hitm; + tot = total->tot_hitm;default :break ; }
@@ -1044,6 +1056,9 @@ node_entry(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp *hpp,break ;case DISPLAY_LCL :DISPLAY_HITM (lcl_hitm); +break ; +case DISPLAY_TOT : +DISPLAY_HITM (tot_hitm);default :break ; }
@@ -1351,6 +1366,7 @@ static struct c2c_dimension dim_tot_loads = {static struct c2c_header percent_hitm_header[] = { [DISPLAY_LCL ] =HEADER_BOTH ("Lcl" ,"Hitm" ), [DISPLAY_RMT ] =HEADER_BOTH ("Rmt" ,"Hitm" ), + [DISPLAY_TOT ] =HEADER_BOTH ("Tot" ,"Hitm" ), };static struct c2c_dimension dim_percent_hitm = {
@@ -1794,6 +1810,9 @@ static bool he__display(struct hist_entry *he, struct c2c_stats *stats)break ;case DISPLAY_RMT :FILTER_HITM (rmt_hitm); +break ; +case DISPLAY_TOT : +FILTER_HITM (tot_hitm);default :break ; };
@@ -1809,8 +1828,9 @@ static inline int valid_hitm_or_store(struct hist_entry *he)bool has_hitm; c2c_he = container_of(he, struct c2c_hist_entry, he); - has_hitm = c2c.display ==DISPLAY_LCL ? - c2c_he->stats.lcl_hitm : c2c_he->stats.rmt_hitm; + has_hitm = c2c.display ==DISPLAY_TOT ? c2c_he->stats.tot_hitm : + c2c.display ==DISPLAY_LCL ? c2c_he->stats.lcl_hitm : + c2c_he->stats.rmt_hitm;return has_hitm || c2c_he->stats.store; }
@@ -2095,7 +2115,7 @@ static void print_c2c_info(FILE *out, struct perf_session *session) first = false; }fprintf (out," Cachelines sort on : %s HITMs\n" , - c2c.display ==DISPLAY_LCL ?"Local" :"Remote" ); + display_str[c2c.display]);fprintf (out," Cacheline data grouping : %s\n" , c2c.cl_sort); }
@@ -2250,7 +2270,7 @@ static int perf_c2c_browser__title(struct hist_browser *browser,"Shared Data Cache Line Table " "(%lu entries, sorted on %s HITMs)" , browser->nr_non_filtered_entries, - c2c.display == DISPLAY_LCL ? "local" : "remote"); + display_str[c2c.display]);return 0 ; }
@@ -2387,9 +2407,11 @@ static int setup_callchain(struct perf_evlist *evlist)static int setup_display (const char *str) { -const char *display = str ?:"rmt" ; +const char *display = str ?:"tot" ; -if (!strcmp (display,"rmt" )) +if (!strcmp (display,"tot" )) + c2c.display =DISPLAY_TOT ; +else if (!strcmp (display,"rmt" )) c2c.display =DISPLAY_RMT ;else if (!strcmp (display,"lcl" )) c2c.display =DISPLAY_LCL ;
@@ -2474,6 +2496,8 @@ static int setup_coalesce(const char *coalesce, bool no_source)return -1 ;if (asprintf (&c2c.cl_resort,"offset,%s" , + c2c.display ==DISPLAY_TOT ? +"tot_hitm" : c2c.display ==DISPLAY_RMT ?"rmt_hitm,lcl_hitm" :"lcl_hitm,rmt_hitm" ) <0 )
@@ -2520,7 +2544,7 @@ static int perf_c2c__report(int argc, const char **argv) "print_type,threshold[,print_limit],order,sort_key[,branch],value", callchain_help, &parse_callchain_opt, callchain_default_opt), -OPT_STRING ('d' ,"display" , &display,NULL ,"lcl,rmt" ), +OPT_STRING ('d' ,"display" , &display,"Switch HITM output type" ,"lcl,rmt" ),OPT_STRING ('c' ,"coalesce" , &coalesce,"coalesce fields" ,"coalesce fields: pid,tid,iaddr,dso" ), OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
@@ -2608,6 +2632,7 @@ static int perf_c2c__report(int argc, const char **argv)"tot_loads," "ld_fbhit,ld_l1hit,ld_l2hit," "ld_lclhit,ld_rmthit" , + c2c.display ==DISPLAY_TOT ?"tot_hitm" : c2c.display ==DISPLAY_LCL ?"lcl_hitm" :"rmt_hitm" );
Jiri Olsa
reviewerPATCH 6/6 perf c2c: Support cascading options
In reply to Jiri OlsaAdding support for cascading options added by Namhyung in:
commit 369a2478973a ("tools lib subcmd: Support cascading options")
This way the report and record command share options with with c2c command and can save some option duplicates. For now it's the 'v' option.
--- tools/perf/builtin-c2c.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
tools/perf/builtin-c2c.c +10 -12
@@ -101,6 +101,11 @@ static const char *display_str[DISPLAY_MAX] = { [DISPLAY_TOT] = "Total", }; +static const struct option c2c_options[] = { +OPT_INCR ('v' ,"verbose" , &verbose,"be more verbose (show counter open errors, etc)" ), +OPT_END () +}; +static struct perf_c2c c2c;static void *c2c_he_zalloc (size_t size)
@@ -2520,11 +2525,9 @@ static int perf_c2c__report(int argc, const char **argv)const char *display =NULL ;const char *coalesce =NULL ;bool no_source = false; -const struct option c2c_options[] = { +const struct option options[] = {OPT_STRING ('k' ,"vmlinux" , &symbol_conf.vmlinux_name,"file" ,"vmlinux pathname" ), -OPT_INCR ('v' ,"verbose" , &verbose, -"be more verbose (show counter open errors, etc)" ),OPT_STRING ('i' ,"input" , &input_name,"file" ,"the input file to process" ), OPT_INCR('N', "node-info", &c2c.node_info,
@@ -2548,14 +2551,15 @@ static int perf_c2c__report(int argc, const char **argv)OPT_STRING ('c' ,"coalesce" , &coalesce,"coalesce fields" ,"coalesce fields: pid,tid,iaddr,dso" ),OPT_BOOLEAN ('f' ,"force" , &symbol_conf.force,"don't complain, do it" ), +OPT_PARENT (c2c_options), OPT_END() };int err =0 ; - argc =parse_options (argc, argv, c2c_options, report_c2c_usage, + argc =parse_options (argc, argv, options, report_c2c_usage,PARSE_OPT_STOP_AT_NON_OPTION );if (argc) -usage_with_options (report_c2c_usage, c2c_options); +usage_with_options (report_c2c_usage, options);if (c2c.stats_only) c2c.use_stdio = true;
@@ -2683,11 +2687,10 @@ static int perf_c2c__record(int argc, const char **argv)OPT_CALLBACK ('e' ,"event" , &event_set,"event" ,"event selector. Use 'perf mem record -e list' to list available events" , parse_record_events), -OPT_INCR ('v' ,"verbose" , &verbose, -"be more verbose (show counter open errors, etc)" ),OPT_BOOLEAN ('u' ,"all-user" , &all_user,"collect only user level data" ),OPT_BOOLEAN ('k' ,"all-kernel" , &all_kernel,"collect only kernel level data" ),OPT_UINTEGER ('l' ,"ldlat" , &perf_mem_events__loads_ldlat,"setup mem-loads latency" ), +OPT_PARENT (c2c_options), OPT_END() };
@@ -2759,11 +2762,6 @@ static int perf_c2c__record(int argc, const char **argv)int cmd_c2c (int argc,const char **argv,const char *prefix__maybe_unused ) { -const struct option c2c_options[] = { -OPT_INCR ('v' ,"verbose" , &verbose,"be more verbose" ), -OPT_END () - }; - argc =parse_options (argc, argv, c2c_options, c2c_usage,PARSE_OPT_STOP_AT_NON_OPTION );
Signature · 1 line
2.7.4
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf c2c: Support cascading options
perf c2c: Support cascading options
Commit-ID: 3a5bfab60e59d9407b69f447702c4cd14326c825 Gitweb: http://git.kernel.org/tip/3a5bfab60e59d9407b69f447702c4cd14326c825 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 21 Nov 2016 22:33:31 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 23 Nov 2016 10:44:06 -0300
perf c2c: Support cascading options
Adding support for cascading options added by Namhyung in:
commit 369a2478973a ("tools lib subcmd: Support cascading options")
This way the report and record command share options with with c2c command and can save some option duplicates. For now it's the 'v' option.
--- tools/perf/builtin-c2c.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
tools/perf/builtin-c2c.c +10 -12
@@ -101,6 +101,11 @@ static const char *display_str[DISPLAY_MAX] = { [DISPLAY_TOT] = "Total", }; +static const struct option c2c_options[] = { +OPT_INCR ('v' ,"verbose" , &verbose,"be more verbose (show counter open errors, etc)" ), +OPT_END () +}; +static struct perf_c2c c2c;static void *c2c_he_zalloc (size_t size)
@@ -2520,11 +2525,9 @@ static int perf_c2c__report(int argc, const char **argv)const char *display =NULL ;const char *coalesce =NULL ;bool no_source = false; -const struct option c2c_options[] = { +const struct option options[] = {OPT_STRING ('k' ,"vmlinux" , &symbol_conf.vmlinux_name,"file" ,"vmlinux pathname" ), -OPT_INCR ('v' ,"verbose" , &verbose, -"be more verbose (show counter open errors, etc)" ),OPT_STRING ('i' ,"input" , &input_name,"file" ,"the input file to process" ), OPT_INCR('N', "node-info", &c2c.node_info,
@@ -2548,14 +2551,15 @@ static int perf_c2c__report(int argc, const char **argv)OPT_STRING ('c' ,"coalesce" , &coalesce,"coalesce fields" ,"coalesce fields: pid,tid,iaddr,dso" ),OPT_BOOLEAN ('f' ,"force" , &symbol_conf.force,"don't complain, do it" ), +OPT_PARENT (c2c_options), OPT_END() };int err =0 ; - argc =parse_options (argc, argv, c2c_options, report_c2c_usage, + argc =parse_options (argc, argv, options, report_c2c_usage,PARSE_OPT_STOP_AT_NON_OPTION );if (argc) -usage_with_options (report_c2c_usage, c2c_options); +usage_with_options (report_c2c_usage, options);if (c2c.stats_only) c2c.use_stdio = true;
@@ -2683,11 +2687,10 @@ static int perf_c2c__record(int argc, const char **argv)OPT_CALLBACK ('e' ,"event" , &event_set,"event" ,"event selector. Use 'perf mem record -e list' to list available events" , parse_record_events), -OPT_INCR ('v' ,"verbose" , &verbose, -"be more verbose (show counter open errors, etc)" ),OPT_BOOLEAN ('u' ,"all-user" , &all_user,"collect only user level data" ),OPT_BOOLEAN ('k' ,"all-kernel" , &all_kernel,"collect only kernel level data" ),OPT_UINTEGER ('l' ,"ldlat" , &perf_mem_events__loads_ldlat,"setup mem-loads latency" ), +OPT_PARENT (c2c_options), OPT_END() };
@@ -2759,11 +2762,6 @@ static int perf_c2c__record(int argc, const char **argv)int cmd_c2c (int argc,const char **argv,const char *prefix__maybe_unused ) { -const struct option c2c_options[] = { -OPT_INCR ('v' ,"verbose" , &verbose,"be more verbose" ), -OPT_END () - }; - argc =parse_options (argc, argv, c2c_options, c2c_usage,PARSE_OPT_STOP_AT_NON_OPTION );