perf session: Keep pointers to the vmlinux maps
So that tools such as 'perf probe' don't have to lookup '[kernel.kallsyms]' but instead access them directly after perf_session__create_kernel_maps or map_groups__create_kernel_maps. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Masami Hiramatsu <mhiramat@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1262629169-22797-4-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
committed by
Ingo Molnar
parent
f92cb24c78
commit
de1764892a
@@ -235,9 +235,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
|
|||||||
session.psession = perf_session__new(NULL, O_WRONLY, false);
|
session.psession = perf_session__new(NULL, O_WRONLY, false);
|
||||||
if (session.psession == NULL)
|
if (session.psession == NULL)
|
||||||
die("Failed to init perf_session.");
|
die("Failed to init perf_session.");
|
||||||
session.kmap = map_groups__find_by_name(&session.psession->kmaps,
|
session.kmap = session.psession->vmlinux_maps[MAP__FUNCTION];
|
||||||
MAP__FUNCTION,
|
|
||||||
"[kernel.kallsyms]");
|
|
||||||
if (!session.kmap)
|
if (!session.kmap)
|
||||||
die("Could not find kernel map.\n");
|
die("Could not find kernel map.\n");
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@ struct perf_session {
|
|||||||
struct map_groups kmaps;
|
struct map_groups kmaps;
|
||||||
struct rb_root threads;
|
struct rb_root threads;
|
||||||
struct thread *last_match;
|
struct thread *last_match;
|
||||||
|
struct map *vmlinux_maps[MAP__NR_TYPES];
|
||||||
struct events_stats events_stats;
|
struct events_stats events_stats;
|
||||||
unsigned long event_total[PERF_RECORD_MAX];
|
unsigned long event_total[PERF_RECORD_MAX];
|
||||||
unsigned long unknown_events;
|
unsigned long unknown_events;
|
||||||
|
@@ -1662,7 +1662,7 @@ size_t dsos__fprintf_buildid(FILE *fp)
|
|||||||
__dsos__fprintf_buildid(&dsos__user, fp));
|
__dsos__fprintf_buildid(&dsos__user, fp));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dso *dsos__create_kernel( const char *vmlinux)
|
static struct dso *dsos__create_kernel(const char *vmlinux)
|
||||||
{
|
{
|
||||||
struct dso *kernel = dso__new(vmlinux ?: "[kernel.kallsyms]");
|
struct dso *kernel = dso__new(vmlinux ?: "[kernel.kallsyms]");
|
||||||
|
|
||||||
@@ -1691,29 +1691,26 @@ out_delete_kernel_dso:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int map_groups__create_kernel_maps(struct map_groups *self, const char *vmlinux)
|
static int map_groups__create_kernel_maps(struct map_groups *self,
|
||||||
|
struct map *vmlinux_maps[MAP__NR_TYPES],
|
||||||
|
const char *vmlinux)
|
||||||
{
|
{
|
||||||
struct map *functions, *variables;
|
|
||||||
struct dso *kernel = dsos__create_kernel(vmlinux);
|
struct dso *kernel = dsos__create_kernel(vmlinux);
|
||||||
|
enum map_type type;
|
||||||
|
|
||||||
if (kernel == NULL)
|
if (kernel == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
functions = map__new2(0, kernel, MAP__FUNCTION);
|
for (type = 0; type < MAP__NR_TYPES; ++type) {
|
||||||
if (functions == NULL)
|
vmlinux_maps[type] = map__new2(0, kernel, type);
|
||||||
return -1;
|
if (vmlinux_maps[type] == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
variables = map__new2(0, kernel, MAP__VARIABLE);
|
vmlinux_maps[type]->map_ip =
|
||||||
if (variables == NULL) {
|
vmlinux_maps[type]->unmap_ip = identity__map_ip;
|
||||||
map__delete(functions);
|
map_groups__insert(self, vmlinux_maps[type]);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
functions->map_ip = functions->unmap_ip =
|
|
||||||
variables->map_ip = variables->unmap_ip = identity__map_ip;
|
|
||||||
map_groups__insert(self, functions);
|
|
||||||
map_groups__insert(self, variables);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1824,7 +1821,7 @@ out_free_comm_list:
|
|||||||
|
|
||||||
int perf_session__create_kernel_maps(struct perf_session *self)
|
int perf_session__create_kernel_maps(struct perf_session *self)
|
||||||
{
|
{
|
||||||
if (map_groups__create_kernel_maps(&self->kmaps,
|
if (map_groups__create_kernel_maps(&self->kmaps, self->vmlinux_maps,
|
||||||
symbol_conf.vmlinux_name) < 0)
|
symbol_conf.vmlinux_name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user