aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/map.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-08-02 17:18:28 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-08-02 17:18:28 -0400
commit076c6e45215aea0de1ed34d3d5079fabeaabf5e1 (patch)
treea07e78f58e625eb69dfda8f32ab46e5316551025 /tools/perf/util/map.c
parent3772b734720e1a3f2dc1d95cfdfaa5332f4ccf01 (diff)
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>
Diffstat (limited to 'tools/perf/util/map.c')
-rw-r--r--tools/perf/util/map.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 15d6a6dd50c5..801e6962b0a6 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -506,6 +506,11 @@ void maps__insert(struct rb_root *maps, struct map *map)
506 rb_insert_color(&map->rb_node, maps); 506 rb_insert_color(&map->rb_node, maps);
507} 507}
508 508
509void maps__remove(struct rb_root *self, struct map *map)
510{
511 rb_erase(&map->rb_node, self);
512}
513
509struct map *maps__find(struct rb_root *maps, u64 ip) 514struct map *maps__find(struct rb_root *maps, u64 ip)
510{ 515{
511 struct rb_node **p = &maps->rb_node; 516 struct rb_node **p = &maps->rb_node;
@@ -551,13 +556,6 @@ static void dsos__delete(struct list_head *self)
551 556
552void machine__exit(struct machine *self) 557void machine__exit(struct machine *self)
553{ 558{
554 struct kmap *kmap = map__kmap(self->vmlinux_maps[MAP__FUNCTION]);
555
556 if (kmap->ref_reloc_sym) {
557 free((char *)kmap->ref_reloc_sym->name);
558 free(kmap->ref_reloc_sym);
559 }
560
561 map_groups__exit(&self->kmaps); 559 map_groups__exit(&self->kmaps);
562 dsos__delete(&self->user_dsos); 560 dsos__delete(&self->user_dsos);
563 dsos__delete(&self->kernel_dsos); 561 dsos__delete(&self->kernel_dsos);
@@ -565,6 +563,12 @@ void machine__exit(struct machine *self)
565 self->root_dir = NULL; 563 self->root_dir = NULL;
566} 564}
567 565
566void machine__delete(struct machine *self)
567{
568 machine__exit(self);
569 free(self);
570}
571
568struct machine *machines__add(struct rb_root *self, pid_t pid, 572struct machine *machines__add(struct rb_root *self, pid_t pid,
569 const char *root_dir) 573 const char *root_dir)
570{ 574{