* [PATCH] perf:tools: figure out start address of kernel map from /proc/kallsyms(v1)
@ 2010-11-25 11:27 Ming Lei
2010-11-30 15:40 ` [tip:perf/urgent] perf symbols: Figure out start address of kernel map from kallsyms tip-bot for Ming Lei
0 siblings, 1 reply; 2+ messages in thread
From: Ming Lei @ 2010-11-25 11:27 UTC (permalink / raw)
To: acme
Cc: Ian Munsie, Ingo Molnar, Paul Mackerras, Peter Zijlstra,
Thomas Gleixner, Tom Zanussi, linux-kernel
>From 5dffda5978f0cae0b390e01957e49522a60324ac Mon Sep 17 00:00:00 2001
From: Ming Lei <tom.leiming@gmail.com>
Date: Wed, 24 Nov 2010 16:31:15 +0800
Subject: [PATCH] perf:tools: figure out start address of kernel map from /proc/kallsyms(v1)
On ARM, module symbol start address is ahead of kernel symbol start
address, so we can't suppose that the start address of kenerl map
always is zero, otherwise may cause incorrect .start and .end of kernel map
(caused by fixup) when there are modules loaded, then map_groups__find
may return incorrect map for symbol query.
This patch always figures out the start address of kernel map from
/proc/kallsyms if the file is available, so fix the issues on ARM for
module loaded case.
This patch fixes the following issues on ARM when modules are loaded:
- vmlinux symbol can't be found by kallsyms maps doing 'perf test'
- module symbols are parsed mistakenlly when doing 'perf top'/'perf report'
Cc: Ian Munsie <imunsie@au1.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tom Zanussi <tzanussi@gmail.com>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
v1: use kallsyms__parse, suggested by Arnaldo
---
tools/perf/util/symbol.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 43 insertions(+), 1 deletions(-)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 2af4d7d..00189d1 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -2131,14 +2131,56 @@ static struct dso *machine__create_kernel(struct machine *self)
return kernel;
}
+struct process_args {
+ u64 start;
+};
+
+static int find_kernel_start(void *arg, const char *name,
+ char type __attribute__((__unused__)), u64 start)
+{
+ struct process_args *args = arg;
+
+ if (strchr(name, '['))
+ return 0;
+
+ args->start = start;
+ return 1;
+}
+
+/*figure out the start address of kernel map from /proc/kallsyms*/
+static u64 __machine_get_kernel_start_addr(struct machine *machine)
+{
+ const char *filename;
+ char path[PATH_MAX];
+ struct process_args args;
+
+ if (machine__is_host(machine)) {
+ filename = "/proc/kallsyms";
+ } else {
+ if (machine__is_default_guest(machine))
+ filename = (char *) symbol_conf.default_guest_kallsyms;
+ else {
+ sprintf(path, "%s/proc/kallsyms", machine->root_dir);
+ filename = path;
+ }
+ }
+
+ if (kallsyms__parse(filename, &args, find_kernel_start) <= 0)
+ return 0;
+
+ return args.start;
+}
+
int __machine__create_kernel_maps(struct machine *self, struct dso *kernel)
{
enum map_type type;
+ u64 start;
+ start = __machine_get_kernel_start_addr(self);
for (type = 0; type < MAP__NR_TYPES; ++type) {
struct kmap *kmap;
- self->vmlinux_maps[type] = map__new2(0, kernel, type);
+ self->vmlinux_maps[type] = map__new2(start, kernel, type);
if (self->vmlinux_maps[type] == NULL)
return -1;
--
1.7.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* [tip:perf/urgent] perf symbols: Figure out start address of kernel map from kallsyms
2010-11-25 11:27 [PATCH] perf:tools: figure out start address of kernel map from /proc/kallsyms(v1) Ming Lei
@ 2010-11-30 15:40 ` tip-bot for Ming Lei
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Ming Lei @ 2010-11-30 15:40 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, paulus, hpa, mingo, tzanussi, a.p.zijlstra,
imunsie, tglx, tom.leiming, mingo
Commit-ID: d214afbd81405d4da2c5745fe867e6b313fd4178
Gitweb: http://git.kernel.org/tip/d214afbd81405d4da2c5745fe867e6b313fd4178
Author: Ming Lei <tom.leiming@gmail.com>
AuthorDate: Thu, 25 Nov 2010 19:27:25 +0800
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 30 Nov 2010 14:47:58 -0200
perf symbols: Figure out start address of kernel map from kallsyms
On ARM, module symbol start address is ahead of kernel symbol start address, so
we can't suppose that the start address of kernel map always is zero, otherwise
may cause incorrect .start and .end of kernel map (caused by fixup) when there
are modules loaded, then map_groups__find may return incorrect map for symbol
query.
This patch always figures out the start address of kernel map from
/proc/kallsyms if the file is available, so fix the issues on ARM for module
loaded case.
This patch fixes the following issues on ARM when modules are loaded:
- vmlinux symbol can't be found by kallsyms maps doing 'perf test'
- module symbols are parsed mistakenlly when doing 'perf top'/'perf report'
Cc: Ian Munsie <imunsie@au1.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20101125192725.62d31b42@tom-lei>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/symbol.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 2af4d7d..d628c8d 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -2131,14 +2131,55 @@ static struct dso *machine__create_kernel(struct machine *self)
return kernel;
}
+struct process_args {
+ u64 start;
+};
+
+static int symbol__in_kernel(void *arg, const char *name,
+ char type __used, u64 start)
+{
+ struct process_args *args = arg;
+
+ if (strchr(name, '['))
+ return 0;
+
+ args->start = start;
+ return 1;
+}
+
+/* Figure out the start address of kernel map from /proc/kallsyms */
+static u64 machine__get_kernel_start_addr(struct machine *machine)
+{
+ const char *filename;
+ char path[PATH_MAX];
+ struct process_args args;
+
+ if (machine__is_host(machine)) {
+ filename = "/proc/kallsyms";
+ } else {
+ if (machine__is_default_guest(machine))
+ filename = (char *)symbol_conf.default_guest_kallsyms;
+ else {
+ sprintf(path, "%s/proc/kallsyms", machine->root_dir);
+ filename = path;
+ }
+ }
+
+ if (kallsyms__parse(filename, &args, symbol__in_kernel) <= 0)
+ return 0;
+
+ return args.start;
+}
+
int __machine__create_kernel_maps(struct machine *self, struct dso *kernel)
{
enum map_type type;
+ u64 start = machine__get_kernel_start_addr(self);
for (type = 0; type < MAP__NR_TYPES; ++type) {
struct kmap *kmap;
- self->vmlinux_maps[type] = map__new2(0, kernel, type);
+ self->vmlinux_maps[type] = map__new2(start, kernel, type);
if (self->vmlinux_maps[type] == NULL)
return -1;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-30 15:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-25 11:27 [PATCH] perf:tools: figure out start address of kernel map from /proc/kallsyms(v1) Ming Lei
2010-11-30 15:40 ` [tip:perf/urgent] perf symbols: Figure out start address of kernel map from kallsyms tip-bot for Ming Lei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome