linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] perf tools: Fixes
@ 2016-01-20 11:56 Jiri Olsa
  2016-01-20 11:56 ` [PATCH 1/4] perf tools: Do not read symbols/data from device files Jiri Olsa
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Jiri Olsa @ 2016-01-20 11:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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(-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] perf tools: Do not read symbols/data from device files
  2016-01-20 11:56 [PATCH 0/4] perf tools: Fixes Jiri Olsa
@ 2016-01-20 11:56 ` Jiri Olsa
  2016-02-03 10:06   ` [tip:perf/core] perf symbols: Do not read symbols/ data " tip-bot for Jiri Olsa
  2016-01-20 11:56 ` [PATCH 2/4] perf tools: Fix HISTC_MEM_DCACHELINE width setting Jiri Olsa
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Jiri Olsa @ 2016-01-20 11:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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.

Link: http://lkml.kernel.org/n/tip-rdj48ax089rhsdzpy31r48fw@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index e8e9a9dbf5e3..8e6395439ca0 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -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));
 		}
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index ab02209a7cf3..90cedfa30e43 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -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;
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index ead9509835d2..7a2da7ef556e 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -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);
+}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index fe915e616f9b..61650f05e5c1 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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 */
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] perf tools: Fix HISTC_MEM_DCACHELINE width setting
  2016-01-20 11:56 [PATCH 0/4] perf tools: Fixes Jiri Olsa
  2016-01-20 11:56 ` [PATCH 1/4] perf tools: Do not read symbols/data from device files Jiri Olsa
@ 2016-01-20 11:56 ` Jiri Olsa
  2016-01-30  8:25   ` [tip:perf/urgent] perf hists: " tip-bot for Jiri Olsa
  2016-01-20 11:56 ` [PATCH 3/4] perf stat: Do not clean event's private stats Jiri Olsa
  2016-01-20 11:56 ` [PATCH 4/4] perf stat: Making several helper functions static Jiri Olsa
  3 siblings, 1 reply; 9+ messages in thread
From: Jiri Olsa @ 2016-01-20 11:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

Set correct with for unresolved addr.

Link: http://lkml.kernel.org/n/tip-llh940fx5l1em3au9sse2lss@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/hist.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index c226303e3da0..68a7612019dc 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -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) {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] perf stat: Do not clean event's private stats
  2016-01-20 11:56 [PATCH 0/4] perf tools: Fixes Jiri Olsa
  2016-01-20 11:56 ` [PATCH 1/4] perf tools: Do not read symbols/data from device files Jiri Olsa
  2016-01-20 11:56 ` [PATCH 2/4] perf tools: Fix HISTC_MEM_DCACHELINE width setting Jiri Olsa
@ 2016-01-20 11:56 ` Jiri Olsa
  2016-01-30  8:25   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  2016-01-20 11:56 ` [PATCH 4/4] perf stat: Making several helper functions static Jiri Olsa
  3 siblings, 1 reply; 9+ messages in thread
From: Jiri Olsa @ 2016-01-20 11:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: stable, Mel Gorman, lkml, David Ahern, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra

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.

Reported-by: Mel Gorman <mgorman@techsingularity.net>
Tested-by: Mel Gorman <mgorman@techsingularity.net>
Cc: stable@vger.kernel.org # v4.2+
Cc: Mel Gorman <mgorman@techsingularity.net>
Link: http://lkml.kernel.org/n/tip-tbcxtpjsqrrbwn2me0je8yxt@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/stat.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 2f901d15e063..2b58edccd56f 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -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);
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] perf stat: Making several helper functions static
  2016-01-20 11:56 [PATCH 0/4] perf tools: Fixes Jiri Olsa
                   ` (2 preceding siblings ...)
  2016-01-20 11:56 ` [PATCH 3/4] perf stat: Do not clean event's private stats Jiri Olsa
@ 2016-01-20 11:56 ` Jiri Olsa
  2016-02-03 10:07   ` [tip:perf/core] " tip-bot for Jiri Olsa
  3 siblings, 1 reply; 9+ messages in thread
From: Jiri Olsa @ 2016-01-20 11:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

There'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.

Link: http://lkml.kernel.org/n/tip-5kzfn8belul4bh6qdhjf398l@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/stat.c | 14 +++++++-------
 tools/perf/util/stat.h | 10 ----------
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 2b58edccd56f..beeed0bd3bee 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -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);
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index 086f4e128d63..2af63c9cb59f 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -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);
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [tip:perf/urgent] perf hists: Fix HISTC_MEM_DCACHELINE width setting
  2016-01-20 11:56 ` [PATCH 2/4] perf tools: Fix HISTC_MEM_DCACHELINE width setting Jiri Olsa
@ 2016-01-30  8:25   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-01-30  8:25 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, tglx, dzickus, a.p.zijlstra, mingo, namhyung, acme, jolsa,
	dsahern, linux-kernel

Commit-ID:  0805909f59e02036a4e2660159f27dbf8b6084ac
Gitweb:     http://git.kernel.org/tip/0805909f59e02036a4e2660159f27dbf8b6084ac
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 20 Jan 2016 12:56:33 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Fixes: 9b32ba71ba90 ("perf tools: Add dcacheline sort")
Link: http://lkml.kernel.org/r/1453290995-18485-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/hist.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index c226303..68a7612 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -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) {

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [tip:perf/urgent] perf stat: Do not clean event's private stats
  2016-01-20 11:56 ` [PATCH 3/4] perf stat: Do not clean event's private stats Jiri Olsa
@ 2016-01-30  8:25   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-01-30  8:25 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mgorman, tglx, mingo, a.p.zijlstra, acme, linux-kernel, hpa,
	namhyung, dsahern, jolsa

Commit-ID:  3f416f22d1e21709a631189ba169f76fd267b374
Gitweb:     http://git.kernel.org/tip/3f416f22d1e21709a631189ba169f76fd267b374
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 20 Jan 2016 12:56:34 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Reported-and-Tested-by: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: stable@vger.kernel.org # v4.2+
Fixes: 106a94a0f8c2 ("perf stat: Introduce read_counters function")
Link: http://lkml.kernel.org/r/1453290995-18485-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/stat.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 2f901d1..2b58edc 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -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);

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [tip:perf/core] perf symbols: Do not read symbols/ data from device files
  2016-01-20 11:56 ` [PATCH 1/4] perf tools: Do not read symbols/data from device files Jiri Olsa
@ 2016-02-03 10:06   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-03 10:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, hpa, a.p.zijlstra, tglx, dsahern, jolsa, linux-kernel,
	acme, namhyung

Commit-ID:  403567217d3fa5d4801f820317ada52e5c5f0e53
Gitweb:     http://git.kernel.org/tip/403567217d3fa5d4801f820317ada52e5c5f0e53
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 20 Jan 2016 12:56:32 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453290995-18485-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index e8e9a9d..8e639543 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -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));
 		}
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index ab02209..90cedfa 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -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;
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index ead9509..7a2da7e 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -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);
+}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index fe915e6..61650f0 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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 */

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [tip:perf/core] perf stat: Making several helper functions static
  2016-01-20 11:56 ` [PATCH 4/4] perf stat: Making several helper functions static Jiri Olsa
@ 2016-02-03 10:07   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-03 10:07 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, mingo, tglx, dsahern, namhyung, jolsa, linux-kernel, hpa,
	a.p.zijlstra

Commit-ID:  86a2cf3123bfec118bfb98728d88be0668779b2b
Gitweb:     http://git.kernel.org/tip/86a2cf3123bfec118bfb98728d88be0668779b2b
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 20 Jan 2016 12:56:35 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453290995-18485-5-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/stat.c | 14 +++++++-------
 tools/perf/util/stat.h | 10 ----------
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 2b58edc..beeed0b 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -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);
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index 086f4e1..2af63c9 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -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);

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-02-03 10:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-20 11:56 [PATCH 0/4] perf tools: Fixes Jiri Olsa
2016-01-20 11:56 ` [PATCH 1/4] perf tools: Do not read symbols/data from device files Jiri Olsa
2016-02-03 10:06   ` [tip:perf/core] perf symbols: Do not read symbols/ data " tip-bot for Jiri Olsa
2016-01-20 11:56 ` [PATCH 2/4] perf tools: Fix HISTC_MEM_DCACHELINE width setting Jiri Olsa
2016-01-30  8:25   ` [tip:perf/urgent] perf hists: " tip-bot for Jiri Olsa
2016-01-20 11:56 ` [PATCH 3/4] perf stat: Do not clean event's private stats Jiri Olsa
2016-01-30  8:25   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2016-01-20 11:56 ` [PATCH 4/4] perf stat: Making several helper functions static Jiri Olsa
2016-02-03 10:07   ` [tip:perf/core] " tip-bot for Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).