linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 04/16] perf symbols: Do not read symbols/data from device files
Date: Thu, 21 Jan 2016 13:00:37 -0300	[thread overview]
Message-ID: <1453392049-5825-5-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1453392049-5825-1-git-send-email-acme@kernel.org>

From: Jiri Olsa <jolsa@kernel.org>

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 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.5.0

  parent reply	other threads:[~2016-01-21 16:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21 16:00 [GIT PULL 00/16] perf/core improvements and changes Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 01/16] perf tests: Remove wrong semicolon in while loop in CQM test Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 02/16] perf annotate browser: Fix behaviour of Shift-Tab with nothing focussed Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 03/16] perf pmu: Fix misleadingly indented assignment (whitespace) Arnaldo Carvalho de Melo
2016-01-21 16:00 ` Arnaldo Carvalho de Melo [this message]
2016-01-21 16:00 ` [PATCH 05/16] perf hists: Fix HISTC_MEM_DCACHELINE width setting Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 06/16] perf stat: Do not clean event's private stats Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 07/16] perf stat: Making several helper functions static Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 08/16] perf hists: Remove parent filter check in DSO filter function Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 09/16] perf hists: Cleanup filtering functions Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 10/16] perf tools: Document the perf sysctls Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 11/16] perf annotate: Rename 'colors.code' to 'colors.jump_arrows' Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 12/16] perf config: Document variables for 'colors' section in man page Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 13/16] perf config: Document variables for 'tui' and 'gtk' sections " Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 14/16] perf config: Document 'buildid.dir' variable " Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 15/16] perf config: Document variables for 'annotate' section " Arnaldo Carvalho de Melo
2016-01-21 16:00 ` [PATCH 16/16] perf config: Document 'hist.percentage' variable " Arnaldo Carvalho de Melo
2016-02-03 10:00 ` [GIT PULL 00/16] perf/core improvements and changes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453392049-5825-5-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).