perf session: Free the ref_reloc_sym memory at the right place

Which is at perf_session__destroy_kernel_maps, counterpart to the
perf_session__create_kernel_maps where the kmap structure is located, just
after the vmlinux_maps.

Make it also check if the kernel maps were actually created, which may not
be the case if, for instance, perf_session__new can't complete due to
permission problems in, for instance, a 'perf report' case, when a
segfault will take place, that is how this was noticed.

The problem was introduced in d65a458, thus post .35.

This also adds code to release guest machines as them are also created
in perf_session__create_kernel_maps, so should be deleted on this newly
introduced counterpart, perf_session__destroy_kernel_maps.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.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-08-02 18:18:28 -03:00
parent 3772b73472
commit 076c6e4521
5 changed files with 70 additions and 7 deletions

View File

@ -506,6 +506,11 @@ void maps__insert(struct rb_root *maps, struct map *map)
rb_insert_color(&map->rb_node, maps);
}
void maps__remove(struct rb_root *self, struct map *map)
{
rb_erase(&map->rb_node, self);
}
struct map *maps__find(struct rb_root *maps, u64 ip)
{
struct rb_node **p = &maps->rb_node;
@ -551,13 +556,6 @@ static void dsos__delete(struct list_head *self)
void machine__exit(struct machine *self)
{
struct kmap *kmap = map__kmap(self->vmlinux_maps[MAP__FUNCTION]);
if (kmap->ref_reloc_sym) {
free((char *)kmap->ref_reloc_sym->name);
free(kmap->ref_reloc_sym);
}
map_groups__exit(&self->kmaps);
dsos__delete(&self->user_dsos);
dsos__delete(&self->kernel_dsos);
@ -565,6 +563,12 @@ void machine__exit(struct machine *self)
self->root_dir = NULL;
}
void machine__delete(struct machine *self)
{
machine__exit(self);
free(self);
}
struct machine *machines__add(struct rb_root *self, pid_t pid,
const char *root_dir)
{