aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-01-04 13:19:29 -0500
committerIngo Molnar <mingo@elte.hu>2010-01-13 04:09:10 -0500
commitde1764892a61a3ed212973cc028c80dd083179dd (patch)
tree677ee82901a5c1e5ea34d8218e5fa859641de7dc /tools
parentf92cb24c78a7c853435e46a20d1bd5c894378132 (diff)
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-probe.c4
-rw-r--r--tools/perf/util/session.h1
-rw-r--r--tools/perf/util/symbol.c29
3 files changed, 15 insertions, 19 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index c1e6774fd3ed..ffdd3fe87b4a 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -235,9 +235,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
235 session.psession = perf_session__new(NULL, O_WRONLY, false); 235 session.psession = perf_session__new(NULL, O_WRONLY, false);
236 if (session.psession == NULL) 236 if (session.psession == NULL)
237 die("Failed to init perf_session."); 237 die("Failed to init perf_session.");
238 session.kmap = map_groups__find_by_name(&session.psession->kmaps, 238 session.kmap = session.psession->vmlinux_maps[MAP__FUNCTION];
239 MAP__FUNCTION,
240 "[kernel.kallsyms]");
241 if (!session.kmap) 239 if (!session.kmap)
242 die("Could not find kernel map.\n"); 240 die("Could not find kernel map.\n");
243 241
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 77c5ee2993c2..8db37bbf0e62 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -18,6 +18,7 @@ struct perf_session {
18 struct map_groups kmaps; 18 struct map_groups kmaps;
19 struct rb_root threads; 19 struct rb_root threads;
20 struct thread *last_match; 20 struct thread *last_match;
21 struct map *vmlinux_maps[MAP__NR_TYPES];
21 struct events_stats events_stats; 22 struct events_stats events_stats;
22 unsigned long event_total[PERF_RECORD_MAX]; 23 unsigned long event_total[PERF_RECORD_MAX];
23 unsigned long unknown_events; 24 unsigned long unknown_events;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 5dffcd132d15..e290429e9c00 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1662,7 +1662,7 @@ size_t dsos__fprintf_buildid(FILE *fp)
1662 __dsos__fprintf_buildid(&dsos__user, fp)); 1662 __dsos__fprintf_buildid(&dsos__user, fp));
1663} 1663}
1664 1664
1665static struct dso *dsos__create_kernel( const char *vmlinux) 1665static struct dso *dsos__create_kernel(const char *vmlinux)
1666{ 1666{
1667 struct dso *kernel = dso__new(vmlinux ?: "[kernel.kallsyms]"); 1667 struct dso *kernel = dso__new(vmlinux ?: "[kernel.kallsyms]");
1668 1668
@@ -1691,29 +1691,26 @@ out_delete_kernel_dso:
1691 return NULL; 1691 return NULL;
1692} 1692}
1693 1693
1694static int map_groups__create_kernel_maps(struct map_groups *self, const char *vmlinux) 1694static int map_groups__create_kernel_maps(struct map_groups *self,
1695 struct map *vmlinux_maps[MAP__NR_TYPES],
1696 const char *vmlinux)
1695{ 1697{
1696 struct map *functions, *variables;
1697 struct dso *kernel = dsos__create_kernel(vmlinux); 1698 struct dso *kernel = dsos__create_kernel(vmlinux);
1699 enum map_type type;
1698 1700
1699 if (kernel == NULL) 1701 if (kernel == NULL)
1700 return -1; 1702 return -1;
1701 1703
1702 functions = map__new2(0, kernel, MAP__FUNCTION); 1704 for (type = 0; type < MAP__NR_TYPES; ++type) {
1703 if (functions == NULL) 1705 vmlinux_maps[type] = map__new2(0, kernel, type);
1704 return -1; 1706 if (vmlinux_maps[type] == NULL)
1707 return -1;
1705 1708
1706 variables = map__new2(0, kernel, MAP__VARIABLE); 1709 vmlinux_maps[type]->map_ip =
1707 if (variables == NULL) { 1710 vmlinux_maps[type]->unmap_ip = identity__map_ip;
1708 map__delete(functions); 1711 map_groups__insert(self, vmlinux_maps[type]);
1709 return -1;
1710 } 1712 }
1711 1713
1712 functions->map_ip = functions->unmap_ip =
1713 variables->map_ip = variables->unmap_ip = identity__map_ip;
1714 map_groups__insert(self, functions);
1715 map_groups__insert(self, variables);
1716
1717 return 0; 1714 return 0;
1718} 1715}
1719 1716
@@ -1824,7 +1821,7 @@ out_free_comm_list:
1824 1821
1825int perf_session__create_kernel_maps(struct perf_session *self) 1822int perf_session__create_kernel_maps(struct perf_session *self)
1826{ 1823{
1827 if (map_groups__create_kernel_maps(&self->kmaps, 1824 if (map_groups__create_kernel_maps(&self->kmaps, self->vmlinux_maps,
1828 symbol_conf.vmlinux_name) < 0) 1825 symbol_conf.vmlinux_name) < 0)
1829 return -1; 1826 return -1;
1830 1827