public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	linux-kernel@vger.kernel.org, David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
	Namhyung Kim <namhyung@gmail.com>,
	Paul Mackerras <paulus@samba.org>,
	Stephane Eranian <eranian@google.com>
Subject: [PATCH 01/11] perf tools: fix buildid cache handling of kallsyms with kcore
Date: Mon, 16 Sep 2013 13:52:42 +0300	[thread overview]
Message-ID: <1379328772-21214-2-git-send-email-adrian.hunter@intel.com> (raw)
In-Reply-To: <1379328772-21214-1-git-send-email-adrian.hunter@intel.com>

When kallsyms is used with kcore the dso long_name becomes
the kcore file name.  That prevents the buildid cache from
caching kallsyms.  (There is no support at present for
caching kcore).  Fix by changing it so that the kallsyms
name is used in that case instead.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/header.c | 44 ++++++++++++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 14 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 26441d0..cff62f6 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -199,9 +199,11 @@ static int write_buildid(char *name, size_t name_len, u8 *build_id,
 	return write_padded(fd, name, name_len + 1, len);
 }
 
-static int __dsos__write_buildid_table(struct list_head *head, pid_t pid,
-				u16 misc, int fd)
+static int __dsos__write_buildid_table(struct machine *machine,
+				       struct list_head *head, pid_t pid,
+				       u16 misc, int fd)
 {
+	char nm[PATH_MAX];
 	struct dso *pos;
 
 	dsos__for_each_with_build_id(pos, head) {
@@ -215,6 +217,10 @@ static int __dsos__write_buildid_table(struct list_head *head, pid_t pid,
 		if (is_vdso_map(pos->short_name)) {
 			name = (char *) VDSO__MAP_NAME;
 			name_len = sizeof(VDSO__MAP_NAME) + 1;
+		} else if (dso__is_kcore(pos)) {
+			machine__mmap_name(machine, nm, sizeof(nm));
+			name = nm;
+			name_len = strlen(nm) + 1;
 		} else {
 			name = pos->long_name;
 			name_len = pos->long_name_len + 1;
@@ -240,10 +246,10 @@ static int machine__write_buildid_table(struct machine *machine, int fd)
 		umisc = PERF_RECORD_MISC_GUEST_USER;
 	}
 
-	err = __dsos__write_buildid_table(&machine->kernel_dsos, machine->pid,
-					  kmisc, fd);
+	err = __dsos__write_buildid_table(machine, &machine->kernel_dsos,
+					  machine->pid, kmisc, fd);
 	if (err == 0)
-		err = __dsos__write_buildid_table(&machine->user_dsos,
+		err = __dsos__write_buildid_table(machine, &machine->user_dsos,
 						  machine->pid, umisc, fd);
 	return err;
 }
@@ -375,32 +381,42 @@ out_free:
 	return err;
 }
 
-static int dso__cache_build_id(struct dso *dso, const char *debugdir)
+static int dso__cache_build_id(struct machine *machine, struct dso *dso,
+			       const char *debugdir)
 {
 	bool is_kallsyms = dso->kernel && dso->long_name[0] != '/';
 	bool is_vdso = is_vdso_map(dso->short_name);
+	char *name = dso->long_name;
+	char nm[PATH_MAX];
 
-	return build_id_cache__add_b(dso->build_id, sizeof(dso->build_id),
-				     dso->long_name, debugdir,
-				     is_kallsyms, is_vdso);
+	if (dso__is_kcore(dso)) {
+		is_kallsyms = true;
+		machine__mmap_name(machine, nm, sizeof(nm));
+		name = nm;
+	}
+	return build_id_cache__add_b(dso->build_id, sizeof(dso->build_id), name,
+				     debugdir, is_kallsyms, is_vdso);
 }
 
-static int __dsos__cache_build_ids(struct list_head *head, const char *debugdir)
+static int __dsos__cache_build_ids(struct machine *machine,
+				   struct list_head *head, const char *debugdir)
 {
 	struct dso *pos;
 	int err = 0;
 
 	dsos__for_each_with_build_id(pos, head)
-		if (dso__cache_build_id(pos, debugdir))
+		if (dso__cache_build_id(machine, pos, debugdir))
 			err = -1;
 
 	return err;
 }
 
-static int machine__cache_build_ids(struct machine *machine, const char *debugdir)
+static int machine__cache_build_ids(struct machine *machine,
+				    const char *debugdir)
 {
-	int ret = __dsos__cache_build_ids(&machine->kernel_dsos, debugdir);
-	ret |= __dsos__cache_build_ids(&machine->user_dsos, debugdir);
+	int ret = __dsos__cache_build_ids(machine, &machine->kernel_dsos,
+					  debugdir);
+	ret |= __dsos__cache_build_ids(machine, &machine->user_dsos, debugdir);
 	return ret;
 }
 
-- 
1.7.11.7


  reply	other threads:[~2013-09-16 10:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-16 10:52 [PATCH 00/11] perf tools: kcore improvements Adrian Hunter
2013-09-16 10:52 ` Adrian Hunter [this message]
2013-09-16 10:52 ` [PATCH 02/11] perf tools: fix path unpopulated in machine__create_modules() Adrian Hunter
2013-09-19 14:49   ` Arnaldo Carvalho de Melo
2013-09-16 10:52 ` [PATCH 03/11] perf tools: make a separate function to parse /proc/modules Adrian Hunter
2013-09-16 10:52 ` [PATCH 04/11] perf tools: validate kcore module addresses Adrian Hunter
2013-09-16 10:52 ` [PATCH 05/11] perf tools: workaround objdump difficulties with kcore Adrian Hunter
2013-09-16 10:52 ` [PATCH 06/11] perf tools: add map__find_other_map_symbol() Adrian Hunter
2013-09-16 10:52 ` [PATCH 07/11] perf tools: fix annotate_browser__callq() Adrian Hunter
2013-09-16 10:52 ` [PATCH 08/11] perf tools: find kcore symbols on other maps Adrian Hunter
2013-09-16 10:52 ` [PATCH 09/11] perf tools: add copyfile_mode() Adrian Hunter
2013-09-16 10:52 ` [PATCH 10/11] perf buildid-cache: add ability to add kcore to the cache Adrian Hunter
2013-09-16 10:52 ` [PATCH 11/11] perf tools: add ability to find kcore in build-id cache Adrian Hunter

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=1379328772-21214-2-git-send-email-adrian.hunter@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=dsahern@gmail.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.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