perf tools: Header and c2c fixes
Subsystems (2)
Jiri Olsa
reviewercover perf tools: Header and c2c fixes
hi,
sending few perf.data header fixes and adding
two new c2c report options.
Also available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixes
thanks,
jirka
---
Jiri Olsa (6):
perf report: Move captured info to generic header info perf header: Display missing features
perf header: Display feature name on write failure perf header: Set nr_numa_nodes only when we parsed all the data perf c2c report: Add --no-source option
perf c2c report: Add --show-all option
tools/perf/Documentation/perf-c2c.txt | 6 ++++++ tools/perf/builtin-c2c.c | 20 +++++++++++++------- tools/perf/util/header.c | 21 +++++++++++++++++++-- tools/perf/util/session.c | 10 ---------- 4 files changed, 38 insertions(+), 19 deletions(-)
Jiri Olsa
reviewerPATCH 1/6 perf report: Move captured info to generic header info
It's not displayed in TUI now, putting it into generic part.
--- tools/perf/util/header.c | 9 +++++++++ tools/perf/util/session.c | 10 ---------- 2 files changed, 9 insertions(+), 10 deletions(-)
tools/perf/util/header.c +9 -0
@@ -2250,9 +2250,18 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)struct header_print_data hd;struct perf_header *header = &session->header;int fd =perf_data_file__fd (session->file); +struct stat st; +int ret; + hd.fp = fp; hd.full = full; + ret =fstat (fd, &st); +if (ret ==-1 ) +return -1 ; + +fprintf (fp,"# captured on: %s" ,ctime (&st.st_ctime)); +perf_header__process_sections (header, fd, &hd, perf_file_section__fprintf_info);return 0 ;
tools/perf/util/session.c +0 -10
@@ -2025,20 +2025,10 @@ out_delete_map:void perf_session__fprintf_info (struct perf_session *session,FILE *fp,bool full) { -struct stat st; -int fd, ret; -if (session ==NULL || fp ==NULL )return ; - fd =perf_data_file__fd (session->file); - - ret =fstat (fd, &st); -if (ret ==-1 ) -return ; -fprintf (fp,"# ========\n" ); -fprintf (fp,"# captured on: %s" ,ctime (&st.st_ctime));perf_header__fprintf_info (session, fp, full);fprintf (fp,"# ========\n#\n" ); }
Signature · 1 line
2.7.4
Jiri Olsa
reviewerPATCH 2/6 perf header: Display missing features
In reply to Jiri OlsaDisplay missing features in header info, like:
$ perf report --header-only # ======== # captured on: Mon Oct 10 09:39:47 2016 ... # missing features: HEADER_TRACING_DATA HEADER_CPU_TOPOLOGY ...
--- tools/perf/util/header.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
tools/perf/util/header.c +9 -1
@@ -2251,7 +2251,7 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)struct perf_header *header = &session->header;int fd =perf_data_file__fd (session->file);struct stat st; -int ret; +int ret, bit; hd.fp = fp; hd.full = full;
@@ -2264,6 +2264,14 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)perf_header__process_sections (header, fd, &hd, perf_file_section__fprintf_info); + +fprintf (fp,"# missing features: " ); +for_each_clear_bit (bit, header->adds_features,HEADER_LAST_FEATURE ) { +if (bit) +fprintf (fp,"%s " , feat_ops[bit].name); + } + +fprintf (fp,"\n" );return 0 ; }
Signature · 1 line
2.7.4
Jiri Olsa
reviewerPATCH 3/6 perf header: Display feature name on write failure
In reply to Jiri OlsaDisplay name of feature instead of just the number during recording data.
Before:
failed to write feature 13
Now:
failed to write feature HEADER_CPU_TOPOLOGY
--- tools/perf/util/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/header.c +1 -1
@@ -2290,7 +2290,7 @@ static int do_write_feat(int fd, struct perf_header *h, int type, err = feat_ops[type].write (fd, h, evlist);if (err <0 ) { -pr_debug ("failed to write feature %d\n" , type); +pr_debug ("failed to write feature %s\n" , feat_ops[type].name);/* undo anything written */ lseek (fd, (*p)->offset,SEEK_SET );
Signature · 1 line
2.7.4
Jiri Olsa
reviewerPATCH 4/6 perf header: Set nr_numa_nodes only when we parsed all the data
In reply to Jiri OlsaSukadev reported segfault on releasing perf env's numa data. It's due to nr_numa_nodes being set no matter if the numa data gets parsed properly. The perf_env__exit crash the on releasing non existed data.
Setting nr_numa_nodes only when data are parsed out properly.
--- tools/perf/util/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/header.c +1 -1
@@ -1895,7 +1895,6 @@ static int process_numa_topology(struct perf_file_section *section __maybe_unuseif (ph->needs_swap) nr =bswap_32 (nr); - ph->env.nr_numa_nodes = nr; nodes =zalloc (sizeof (*nodes) * nr);if (!nodes)return -ENOMEM ;
@@ -1932,6 +1931,7 @@ static int process_numa_topology(struct perf_file_section *section __maybe_unusefree (str); } + ph->env.nr_numa_nodes = nr; ph->env.numa_nodes = nodes;return 0 ;
Signature · 1 line
2.7.4
Jiri Olsa
reviewerPATCH 5/6 perf c2c report: Add --no-source option
In reply to Jiri OlsaAdd a possibility to disable source line column with new --no-source option. It source line data could take lot of time to retrieve, so it could be a performance burden for big data.
--- tools/perf/Documentation/perf-c2c.txt | 3 +++ tools/perf/builtin-c2c.c | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-)
tools/perf/Documentation/perf-c2c.txt +3 -0
@@ -94,6 +94,9 @@ REPORT OPTIONS --full-symbols:: Display full length of symbols. +--no-source:: + Do not display Source:Line column. + C2C RECORD ---------- The perf c2c record command setup options related to HITM cacheline analysis
tools/perf/builtin-c2c.c +8 -5
@@ -2404,7 +2404,7 @@ static int setup_display(const char *str)for (__tok =strtok_r (__buf, __sep, &__tmp); __tok; \ __tok =strtok_r (NULL , __sep, &__tmp)) -static int build_cl_output(char *cl_sort) +static int build_cl_output(char *cl_sort, bool no_source) {char *tok, *tmp, *buf =strdup (cl_sort);bool add_pid = false;
@@ -2426,7 +2426,7 @@ static int build_cl_output(char *cl_sort) add_iaddr = true; add_sym = true; add_dso = true; - add_src = true; + add_src = no_source ? false : true; }else if (!strcmp (tok,"dso" )) { add_dso = true; }else if (strcmp (tok,"offset" )) {
@@ -2462,14 +2462,14 @@ static int build_cl_output(char *cl_sort)return 0 ; } -static int setup_coalesce (const char *coalesce) +static int setup_coalesce (const char *coalesce,bool no_source) {const char *c = coalesce ?: coalesce_default;if (asprintf (&c2c.cl_sort,"offset,%s" , c) <0 )return -ENOMEM ; -if (build_cl_output (c2c.cl_sort)) +if (build_cl_output (c2c.cl_sort, no_source))return -1 ; if (asprintf(&c2c.cl_resort, "offset,%s",
@@ -2494,6 +2494,7 @@ static int perf_c2c__report(int argc, const char **argv)char callchain_default_opt[] =CALLCHAIN_DEFAULT_OPT ;const char *display =NULL ;const char *coalesce =NULL ; +bool no_source = false;const struct option c2c_options[] = {OPT_STRING ('k' ,"vmlinux" , &symbol_conf.vmlinux_name,"file" ,"vmlinux pathname" ),
@@ -2510,6 +2511,8 @@ static int perf_c2c__report(int argc, const char **argv) "Use the stdio interface"),OPT_BOOLEAN (0 ,"full-symbols" , &c2c.symbol_full,"Display full length of symbols" ), +OPT_BOOLEAN (0 ,"no-source" , &no_source, +"Do not display Source Line column" ), OPT_CALLBACK_DEFAULT('g', "call-graph", &callchain_param, "print_type,threshold[,print_limit],order,sort_key[,branch],value", callchain_help, &parse_callchain_opt,
@@ -2545,7 +2548,7 @@ static int perf_c2c__report(int argc, const char **argv)if (err) goto out; - err =setup_coalesce (coalesce); + err =setup_coalesce (coalesce, no_source);if (err) {pr_debug ("Failed to initialize hists\n" ); goto out;
Signature · 1 line
2.7.4
Jiri Olsa
reviewerPATCH 6/6 perf c2c report: Add --show-all option
In reply to Jiri OlsaNormally we limit the main list to contain only entries with HITM % value > 0.0005, but it might be useful to display all captured entries. Adding --show-all option for that.
--- tools/perf/Documentation/perf-c2c.txt | 3 +++ tools/perf/builtin-c2c.c | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-c2c.txt +3 -0
@@ -97,6 +97,9 @@ REPORT OPTIONS --no-source:: Do not display Source:Line column. +--show-all:: + Show all captured HITM lines, with no regard to HITM % 0.0005 limit. + C2C RECORD ---------- The perf c2c record command setup options related to HITM cacheline analysis
tools/perf/builtin-c2c.c +5 -2
@@ -71,6 +71,7 @@ struct perf_c2c {int node_info;bool show_src; +bool show_all;bool use_stdio;bool stats_only;bool symbol_full;
@@ -1773,8 +1774,8 @@ static bool he__display(struct hist_entry *he, struct c2c_stats *stats)struct c2c_hist_entry *c2c_he;double ld_dist; -/* XXX Disabled for now, till we get a command line switch to control this */ -return true; +if (c2c.show_all) +return true; c2c_he = container_of(he, struct c2c_hist_entry, he);
@@ -2513,6 +2514,8 @@ static int perf_c2c__report(int argc, const char **argv) "Display full length of symbols"),OPT_BOOLEAN (0 ,"no-source" , &no_source,"Do not display Source Line column" ), +OPT_BOOLEAN (0 ,"show-all" , &c2c.show_all, +"Show all captured HITM lines." ), OPT_CALLBACK_DEFAULT('g', "call-graph", &callchain_param, "print_type,threshold[,print_limit],order,sort_key[,branch],value", callchain_help, &parse_callchain_opt,
Signature · 1 line
2.7.4
cover tools lib: Add for_each_clear_bit macro
In reply to Jiri OlsaQuoted 11 lines · Jiri Olsa
hi,
sending few perf.data header fixes and adding
two new c2c report options.Also available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixesthanks,
jirka
Quoted 9 lines
---
Jiri Olsa (6):
perf report: Move captured info to generic header info perf header: Display missing features
perf header: Display feature name on write failure perf header: Setnr_numa_nodesonly when we parsed all the data perf c2c report: Add --no-source option
perf c2c report: Add --show-all option
oops, forgot to send the initial patch.. it's part of the branch
jirka
---
Adding for_each_clear_bit macro plus all its the necessary backbone functions. Taken from related kernel code. It will be used in following patch.
--- tools/include/asm-generic/bitops.h | 1 + tools/include/asm-generic/bitops/__ffz.h | 12 ++++++++++++ tools/include/asm-generic/bitops/find.h | 28 ++++++++++++++++++++++++++++ tools/include/linux/bitops.h | 5 +++++ tools/lib/find_bit.c | 25 +++++++++++++++++++++++++ tools/perf/MANIFEST | 1 + 6 files changed, 72 insertions(+) create mode 100644 tools/include/asm-generic/bitops/__ffz.h
tools/include/asm-generic/bitops.h +1 -0
@@ -13,6 +13,7 @@*/ #include <asm-generic/bitops/__ffs.h> +#include <asm-generic/bitops/__ffz.h> #include <asm-generic/bitops/fls.h> #include <asm-generic/bitops/__fls.h> #include <asm-generic/bitops/fls64.h>
tools/include/asm-generic/bitops/__ffz.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef _ASM_GENERIC_BITOPS_FFZ_H_ +#define _ASM_GENERIC_BITOPS_FFZ_H_ + +/* +* ffz - find first zero in word. +* @word: The word to search +* +* Undefined if no zero exists, so code should check against ~0UL first. +*/ +#define ffz (x) __ffs(~(x)) + +#endif /* _ASM_GENERIC_BITOPS_FFZ_H_ */
tools/include/asm-generic/bitops/find.h +28 -0
@@ -15,6 +15,21 @@ extern unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset);#endif +#ifndef find_next_zero_bit + +/** +* find_next_zero_bit - find the next cleared bit in a memory region +* @addr: The address to base the search on +* @offset: The bitnumber to start searching at +* @size: The bitmap size in bits +* +* Returns the bit number of the next zero bit +* If no bits are zero, returns @size. +*/ +unsigned long find_next_zero_bit (const unsigned long *addr,unsigned long size, +unsigned long offset); +#endif +#ifndef find_first_bit/**
@@ -30,4 +45,17 @@ extern unsigned long find_first_bit(const unsigned long *addr,#endif /* find_first_bit */ +#ifndef find_first_zero_bit + +/** +* find_first_zero_bit - find the first cleared bit in a memory region +* @addr: The address to start the search at +* @size: The maximum number of bits to search +* +* Returns the bit number of the first cleared bit. +* If no bits are zero, returns @size. +*/ +unsigned long find_first_zero_bit (const unsigned long *addr,unsigned long size); +#endif +#endif /*_TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_ */
tools/include/linux/bitops.h +5 -0
@@ -39,6 +39,11 @@ extern unsigned long __sw_hweight64(__u64 w); (bit) < (size); \ (bit) = find_next_bit((addr), (size), (bit) + 1)) +#define for_each_clear_bit (bit, addr, size) \ + for ((bit) = find_first_zero_bit((addr), (size)); \ + (bit) < (size); \ + (bit) = find_next_zero_bit((addr), (size), (bit) + 1)) +/* same as for_each_set_bit() but use bit as value to start with */ #define for_each_set_bit_from (bit, addr, size) \ for ((bit) = find_next_bit((addr), (size), (bit)); \
tools/lib/find_bit.c +25 -0
@@ -82,3 +82,28 @@ unsigned long find_first_bit(const unsigned long *addr, unsigned long size) return size; }#endif + +#ifndef find_first_zero_bit +/* +* Find the first cleared bit in a memory region. +*/ +unsigned long find_first_zero_bit (const unsigned long *addr,unsigned long size) +{ +unsigned long idx; + +for (idx =0 ; idx *BITS_PER_LONG < size; idx++) { +if (addr[idx] != ~0UL ) +return min (idx *BITS_PER_LONG +ffz (addr[idx]), size); + } + +return size; +} +#endif + +#ifndef find_next_zero_bit +unsigned long find_next_zero_bit (const unsigned long *addr,unsigned long size, +unsigned long offset) +{ +return _find_next_bit (addr, size, offset, ~0UL ); +} +#endif
tools/perf/MANIFEST +1 -0
@@ -51,6 +51,7 @@ tools/include/asm-generic/bitops/arch_hweight.h tools/include/asm-generic/bitops/atomic.h tools/include/asm-generic/bitops/const_hweight.h tools/include/asm-generic/bitops/__ffs.h +tools/include/asm-generic/bitops/__ffz.h tools/include/asm-generic/bitops/__fls.h tools/include/asm-generic/bitops/find.h tools/include/asm-generic/bitops/fls64.h
Signature · 1 line
2.7.4