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>
This commit is contained in:
Arnaldo Carvalho de Melo
2010-04-27 21:20:43 -03:00
parent 48ea8f5470
commit d28c62232e
8 changed files with 74 additions and 81 deletions

View File

@ -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;