summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/map.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-04-27 21:20:43 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-04-27 21:21:18 -0300
commitd28c62232e50eab202bcd3f19b5c7a25b8b900b6 (patch)
tree544aca2fe1c7a6c813cf2bf319a8ceb4d212b649 /tools/perf/util/map.c
parent48ea8f5470aa6f35244d1b218316705ea88c0259 (diff)
downloadop-kernel-dev-d28c62232e50eab202bcd3f19b5c7a25b8b900b6.zip
op-kernel-dev-d28c62232e50eab202bcd3f19b5c7a25b8b900b6.tar.gz
perf machine: Adopt some map_groups functions
Those functions operated on members now grouped in 'struct machine', so move those methods to this new class. The changes made to 'perf probe' shows that using this abstraction inserting probes on guests almost got supported for free. Cc: Avi Kivity <avi@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Masami Hiramatsu <mhiramat@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Zhang, Yanmin <yanmin_zhang@linux.intel.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/map.c')
-rw-r--r--tools/perf/util/map.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index ee25ee9..44a4df6 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -513,6 +513,19 @@ struct map *maps__find(struct rb_root *maps, u64 ip)
return NULL;
}
+int machine__init(struct machine *self, const char *root_dir, pid_t pid)
+{
+ map_groups__init(&self->kmaps);
+ RB_CLEAR_NODE(&self->rb_node);
+ INIT_LIST_HEAD(&self->user_dsos);
+ INIT_LIST_HEAD(&self->kernel_dsos);
+
+ self->kmaps.machine = self;
+ self->pid = pid;
+ self->root_dir = strdup(root_dir);
+ return self->root_dir == NULL ? -ENOMEM : 0;
+}
+
struct machine *machines__add(struct rb_root *self, pid_t pid,
const char *root_dir)
{
@@ -523,13 +536,10 @@ struct machine *machines__add(struct rb_root *self, pid_t pid,
if (!machine)
return NULL;
- machine->pid = pid;
- map_groups__init(&machine->kmaps);
- machine->root_dir = strdup(root_dir);
- RB_CLEAR_NODE(&machine->rb_node);
- INIT_LIST_HEAD(&machine->user_dsos);
- INIT_LIST_HEAD(&machine->kernel_dsos);
- machine->kmaps.machine = machine;
+ if (machine__init(machine, root_dir, pid) != 0) {
+ free(machine);
+ return NULL;
+ }
while (*p != NULL) {
parent = *p;
OpenPOWER on IntegriCloud