perf tools: Fixes
Subsystems (2)
Jiri Olsa
reviewercover perf tools: Fixes
hi,
sending few assorted fixes, all on top
of my perf/fixes branch
thanks,
jirka
---
Jiri Olsa (4):
perf tools: Do not read symbols/data from device files perf tools: Fix HISTC_MEM_DCACHELINE width setting perf stat: Do not clean event's private stats perf stat: Making several helper functions static
tools/perf/util/dso.c | 5 +++++ tools/perf/util/hist.c | 2 ++ tools/perf/util/stat.c | 15 +++++++-------- tools/perf/util/stat.h | 10 ---------- tools/perf/util/symbol.c | 6 +++++- tools/perf/util/util.c | 10 ++++++++++ tools/perf/util/util.h | 1 + 7 files changed, 30 insertions(+), 19 deletions(-)
Jiri Olsa
reviewerPATCH 1/4 perf tools: Do not read symbols/data from device files
With mem sampling we could get data source within mapped device file. Processing such sample would block during report phase on trying to read the device file.
Chacking for device files and skip the processing if it's detected.
--- tools/perf/util/dso.c | 5 +++++ tools/perf/util/symbol.c | 6 +++++- tools/perf/util/util.c | 10 ++++++++++ tools/perf/util/util.h | 1 + 4 files changed, 21 insertions(+), 1 deletion(-)
tools/perf/util/dso.c +5 -0
@@ -52,6 +52,11 @@ int dso__read_binary_type_filename(const struct dso *dso, debuglink--;if (*debuglink =='/' ) debuglink++; + + ret =-1 ; +if (!is_regular_file (filename)) +break ; + ret =filename__read_debuglink (filename, debuglink, size - (debuglink - filename)); }
tools/perf/util/symbol.c +5 -1
@@ -1466,7 +1466,8 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)* Read the build id if possible. This is required for * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work */ -if (filename__read_build_id (dso->long_name, build_id,BUILD_ID_SIZE ) >0 ) +if (is_regular_file (name) && +filename__read_build_id (dso->long_name, build_id,BUILD_ID_SIZE ) >0 )dso__set_build_id (dso, build_id);/*
@@ -1487,6 +1488,9 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) root_dir, name, PATH_MAX))continue ; +if (!is_regular_file (name)) +continue ; +/* Name is now the name of the next image to try */ if (symsrc__init (ss, dso, name, symtab_type) <0 )continue ;
tools/perf/util/util.c +10 -0
@@ -691,3 +691,13 @@ out:return tip; } + +bool is_regular_file (const char *file) +{ +struct stat st; + +if (stat (file, &st)) +return false; + +return S_ISREG (st.st_mode); +}
tools/perf/util/util.h +1 -0
@@ -343,5 +343,6 @@ int fetch_kernel_version(unsigned int *puint,#define KVER_PARAM (x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x)const char *perf_tip (const char *dirpath); +bool is_regular_file (const char *file);#endif /* GIT_COMPAT_UTIL_H */
Signature · 1 line
2.4.3
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf symbols: Do not read symbols/ data from device files
perf symbols: Do not read symbols/data from device files
Commit-ID: 403567217d3fa5d4801f820317ada52e5c5f0e53 Gitweb: http://git.kernel.org/tip/403567217d3fa5d4801f820317ada52e5c5f0e53 Author: Jiri Olsa <[email protected]> AuthorDate: Wed, 20 Jan 2016 12:56:32 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 26 Jan 2016 11:52:43 -0300
perf symbols: Do not read symbols/data from device files
With mem sampling we could get data source within mapped device file. Processing such sample would block during report phase on trying to read the device file.
Chacking for device files and skip the processing if it's detected.
--- tools/perf/util/dso.c | 5 +++++ tools/perf/util/symbol.c | 6 +++++- tools/perf/util/util.c | 10 ++++++++++ tools/perf/util/util.h | 1 + 4 files changed, 21 insertions(+), 1 deletion(-)
tools/perf/util/dso.c +5 -0
@@ -52,6 +52,11 @@ int dso__read_binary_type_filename(const struct dso *dso, debuglink--;if (*debuglink =='/' ) debuglink++; + + ret =-1 ; +if (!is_regular_file (filename)) +break ; + ret =filename__read_debuglink (filename, debuglink, size - (debuglink - filename)); }
tools/perf/util/symbol.c +5 -1
@@ -1466,7 +1466,8 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)* Read the build id if possible. This is required for * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work */ -if (filename__read_build_id (dso->long_name, build_id,BUILD_ID_SIZE ) >0 ) +if (is_regular_file (name) && +filename__read_build_id (dso->long_name, build_id,BUILD_ID_SIZE ) >0 )dso__set_build_id (dso, build_id);/*
@@ -1487,6 +1488,9 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) root_dir, name, PATH_MAX))continue ; +if (!is_regular_file (name)) +continue ; +/* Name is now the name of the next image to try */ if (symsrc__init (ss, dso, name, symtab_type) <0 )continue ;
tools/perf/util/util.c +10 -0
@@ -691,3 +691,13 @@ out:return tip; } + +bool is_regular_file (const char *file) +{ +struct stat st; + +if (stat (file, &st)) +return false; + +return S_ISREG (st.st_mode); +}
tools/perf/util/util.h +1 -0
@@ -343,5 +343,6 @@ int fetch_kernel_version(unsigned int *puint,#define KVER_PARAM (x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x)const char *perf_tip (const char *dirpath); +bool is_regular_file (const char *file);#endif /* GIT_COMPAT_UTIL_H */
Jiri Olsa
reviewerPATCH 2/4 perf tools: Fix HISTC_MEM_DCACHELINE width setting
In reply to Jiri OlsaSet correct with for unresolved addr.
--- tools/perf/util/hist.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/hist.c +2 -0
@@ -131,6 +131,8 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) symlen = unresolved_col_width +4 +2 ;hists__new_col_len (hists,HISTC_MEM_DADDR_SYMBOL , symlen); +hists__new_col_len (hists,HISTC_MEM_DCACHELINE , + symlen); }if (h->mem_info->iaddr.sym) {
Signature · 1 line
2.4.3
tip-bot for Jiri Olsa
merge bot[tip:perf/urgent] perf hists: Fix HISTC_MEM_DCACHELINE width setting
perf hists: Fix HISTC_MEM_DCACHELINE width setting
Commit-ID: 0805909f59e02036a4e2660159f27dbf8b6084ac Gitweb: http://git.kernel.org/tip/0805909f59e02036a4e2660159f27dbf8b6084ac Author: Jiri Olsa <[email protected]> AuthorDate: Wed, 20 Jan 2016 12:56:33 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 26 Jan 2016 11:14:55 -0300
perf hists: Fix HISTC_MEM_DCACHELINE width setting
Set correct width for unresolved mem_dcacheline addr.
--- tools/perf/util/hist.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/hist.c +2 -0
@@ -131,6 +131,8 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) symlen = unresolved_col_width +4 +2 ;hists__new_col_len (hists,HISTC_MEM_DADDR_SYMBOL , symlen); +hists__new_col_len (hists,HISTC_MEM_DCACHELINE , + symlen); }if (h->mem_info->iaddr.sym) {
Jiri Olsa
reviewerPATCH 3/4 perf stat: Do not clean event's private stats
In reply to Jiri OlsaMel reported stddev reporting was broken due to following commit:
106a94a0f8c2 perf stat: Introduce read_counters function
This commit merged interval and overall counters reading into single read_counters function.
The old interval code cleaned the stddev data for some reason (it's never displayed in interval mode) and the mentioned commit kept on cleaning the stddev data in merged function, which resulted in the stddev not being displayed.
Removing the wrong stddev data cleanup init_stats call.
--- tools/perf/util/stat.c | 1 - 1 file changed, 1 deletion(-)
tools/perf/util/stat.c +0 -1
@@ -310,7 +310,6 @@ int perf_stat_process_counter(struct perf_stat_config *config,int i, ret; aggr->val = aggr->ena = aggr->run =0 ; -init_stats (ps->res_stats);if (counter->per_pkg)zero_per_pkg (counter);
Signature · 1 line
2.4.3
tip-bot for Jiri Olsa
merge bot[tip:perf/urgent] perf stat: Do not clean event's private stats
perf stat: Do not clean event's private stats
Commit-ID: 3f416f22d1e21709a631189ba169f76fd267b374 Gitweb: http://git.kernel.org/tip/3f416f22d1e21709a631189ba169f76fd267b374 Author: Jiri Olsa <[email protected]> AuthorDate: Wed, 20 Jan 2016 12:56:34 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 26 Jan 2016 11:15:11 -0300
perf stat: Do not clean event's private stats
Mel reported stddev reporting was broken due to following commit:
106a94a0f8c2 ("perf stat: Introduce read_counters function")
This commit merged interval and overall counters reading into single read_counters function.
The old interval code cleaned the stddev data for some reason (it's never displayed in interval mode) and the mentioned commit kept on cleaning the stddev data in merged function, which resulted in the stddev not being displayed.
Removing the wrong stddev data cleanup init_stats call.
--- tools/perf/util/stat.c | 1 - 1 file changed, 1 deletion(-)
tools/perf/util/stat.c +0 -1
@@ -310,7 +310,6 @@ int perf_stat_process_counter(struct perf_stat_config *config,int i, ret; aggr->val = aggr->ena = aggr->run =0 ; -init_stats (ps->res_stats);if (counter->per_pkg)zero_per_pkg (counter);
Jiri Olsa
reviewerPATCH 4/4 perf stat: Making several helper functions static
In reply to Jiri OlsaThere's no need for following functions to be global:
perf_evsel__reset_stat_priv
perf_evsel__alloc_stat_priv
perf_evsel__free_stat_priv
perf_evsel__alloc_prev_raw_counts
perf_evsel__free_prev_raw_counts
perf_evsel__alloc_stats
They all ended up in util/stat.c, and they no longer need to be called from outside this object.
--- tools/perf/util/stat.c | 14 +++++++------- tools/perf/util/stat.h | 10 ---------- 2 files changed, 7 insertions(+), 17 deletions(-)
tools/perf/util/stat.c +7 -7
@@ -97,7 +97,7 @@ void perf_stat_evsel_id_init(struct perf_evsel *evsel) } } -void perf_evsel__reset_stat_priv (struct perf_evsel *evsel) +static void perf_evsel__reset_stat_priv (struct perf_evsel *evsel) {int i;struct perf_stat_evsel *ps = evsel->priv;
@@ -108,7 +108,7 @@ void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)perf_stat_evsel_id_init (evsel); } -int perf_evsel__alloc_stat_priv (struct perf_evsel *evsel) +static int perf_evsel__alloc_stat_priv (struct perf_evsel *evsel) { evsel->priv =zalloc (sizeof (struct perf_stat_evsel ));if (evsel->priv ==NULL )
@@ -117,13 +117,13 @@ int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel)return 0 ; } -void perf_evsel__free_stat_priv (struct perf_evsel *evsel) +static void perf_evsel__free_stat_priv (struct perf_evsel *evsel) {zfree (&evsel->priv); } -int perf_evsel__alloc_prev_raw_counts (struct perf_evsel *evsel, -int ncpus,int nthreads) +static int perf_evsel__alloc_prev_raw_counts (struct perf_evsel *evsel, +int ncpus,int nthreads) {struct perf_counts *counts;
@@ -134,13 +134,13 @@ int perf_evsel__alloc_prev_raw_counts(struct perf_evsel *evsel,return counts ?0 : -ENOMEM ; } -void perf_evsel__free_prev_raw_counts (struct perf_evsel *evsel) +static void perf_evsel__free_prev_raw_counts (struct perf_evsel *evsel) {perf_counts__delete (evsel->prev_raw_counts); evsel->prev_raw_counts =NULL ; } -int perf_evsel__alloc_stats (struct perf_evsel *evsel,bool alloc_raw) +static int perf_evsel__alloc_stats (struct perf_evsel *evsel,bool alloc_raw) {int ncpus =perf_evsel__nr_cpus (evsel);int nthreads =thread_map__nr (evsel->threads);
tools/perf/util/stat.h +0 -10
@@ -74,16 +74,6 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count,void perf_stat__print_shadow_stats (FILE *out,struct perf_evsel *evsel,double avg,int cpu,enum aggr_mode aggr); -void perf_evsel__reset_stat_priv (struct perf_evsel *evsel); -int perf_evsel__alloc_stat_priv (struct perf_evsel *evsel); -void perf_evsel__free_stat_priv (struct perf_evsel *evsel); - -int perf_evsel__alloc_prev_raw_counts (struct perf_evsel *evsel, -int ncpus,int nthreads); -void perf_evsel__free_prev_raw_counts (struct perf_evsel *evsel); - -int perf_evsel__alloc_stats (struct perf_evsel *evsel,bool alloc_raw); -int perf_evlist__alloc_stats (struct perf_evlist *evlist,bool alloc_raw);void perf_evlist__free_stats (struct perf_evlist *evlist);void perf_evlist__reset_stats (struct perf_evlist *evlist);
Signature · 1 line
2.4.3
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf stat: Making several helper functions static
perf stat: Making several helper functions static
Commit-ID: 86a2cf3123bfec118bfb98728d88be0668779b2b Gitweb: http://git.kernel.org/tip/86a2cf3123bfec118bfb98728d88be0668779b2b Author: Jiri Olsa <[email protected]> AuthorDate: Wed, 20 Jan 2016 12:56:35 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 26 Jan 2016 11:52:43 -0300
perf stat: Making several helper functions static
There's no need for the following functions to be global:
perf_evsel__reset_stat_priv
perf_evsel__alloc_stat_priv
perf_evsel__free_stat_priv
perf_evsel__alloc_prev_raw_counts
perf_evsel__free_prev_raw_counts
perf_evsel__alloc_stats
They all ended up in util/stat.c, and they no longer need to be called from outside this object.
--- tools/perf/util/stat.c | 14 +++++++------- tools/perf/util/stat.h | 10 ---------- 2 files changed, 7 insertions(+), 17 deletions(-)
tools/perf/util/stat.c +7 -7
@@ -97,7 +97,7 @@ void perf_stat_evsel_id_init(struct perf_evsel *evsel) } } -void perf_evsel__reset_stat_priv (struct perf_evsel *evsel) +static void perf_evsel__reset_stat_priv (struct perf_evsel *evsel) {int i;struct perf_stat_evsel *ps = evsel->priv;
@@ -108,7 +108,7 @@ void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)perf_stat_evsel_id_init (evsel); } -int perf_evsel__alloc_stat_priv (struct perf_evsel *evsel) +static int perf_evsel__alloc_stat_priv (struct perf_evsel *evsel) { evsel->priv =zalloc (sizeof (struct perf_stat_evsel ));if (evsel->priv ==NULL )
@@ -117,13 +117,13 @@ int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel)return 0 ; } -void perf_evsel__free_stat_priv (struct perf_evsel *evsel) +static void perf_evsel__free_stat_priv (struct perf_evsel *evsel) {zfree (&evsel->priv); } -int perf_evsel__alloc_prev_raw_counts (struct perf_evsel *evsel, -int ncpus,int nthreads) +static int perf_evsel__alloc_prev_raw_counts (struct perf_evsel *evsel, +int ncpus,int nthreads) {struct perf_counts *counts;
@@ -134,13 +134,13 @@ int perf_evsel__alloc_prev_raw_counts(struct perf_evsel *evsel,return counts ?0 : -ENOMEM ; } -void perf_evsel__free_prev_raw_counts (struct perf_evsel *evsel) +static void perf_evsel__free_prev_raw_counts (struct perf_evsel *evsel) {perf_counts__delete (evsel->prev_raw_counts); evsel->prev_raw_counts =NULL ; } -int perf_evsel__alloc_stats (struct perf_evsel *evsel,bool alloc_raw) +static int perf_evsel__alloc_stats (struct perf_evsel *evsel,bool alloc_raw) {int ncpus =perf_evsel__nr_cpus (evsel);int nthreads =thread_map__nr (evsel->threads);
tools/perf/util/stat.h +0 -10
@@ -74,16 +74,6 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count,void perf_stat__print_shadow_stats (FILE *out,struct perf_evsel *evsel,double avg,int cpu,enum aggr_mode aggr); -void perf_evsel__reset_stat_priv (struct perf_evsel *evsel); -int perf_evsel__alloc_stat_priv (struct perf_evsel *evsel); -void perf_evsel__free_stat_priv (struct perf_evsel *evsel); - -int perf_evsel__alloc_prev_raw_counts (struct perf_evsel *evsel, -int ncpus,int nthreads); -void perf_evsel__free_prev_raw_counts (struct perf_evsel *evsel); - -int perf_evsel__alloc_stats (struct perf_evsel *evsel,bool alloc_raw); -int perf_evlist__alloc_stats (struct perf_evlist *evlist,bool alloc_raw);void perf_evlist__free_stats (struct perf_evlist *evlist);void perf_evlist__reset_stats (struct perf_evlist *evlist);