aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-05-25 14:30:09 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-05-27 19:27:16 -0400
commitfacf3f0621b2e11957af1aae9085730ea78ccf85 (patch)
treed898cea7cc764ce699c7da383310ed9c28b0bf3b
parent6a2ffcddad22ead7ce75c5773e87895b91e7cca7 (diff)
perf tools: Check if a map is still in use when deleting it
I.e. match RB_CLEAR_NODE() with RB_EMPTY_NODE(), to check that it isn't in a rb tree at the time of its deletion. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-vumvhird765id11zbx00d2r8@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-annotate.c4
-rw-r--r--tools/perf/util/map.c9
-rw-r--r--tools/perf/util/symbol.c8
3 files changed, 13 insertions, 8 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index b57a027fb200..c434e1264087 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -59,6 +59,10 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
59 (al->sym == NULL || 59 (al->sym == NULL ||
60 strcmp(ann->sym_hist_filter, al->sym->name) != 0)) { 60 strcmp(ann->sym_hist_filter, al->sym->name) != 0)) {
61 /* We're only interested in a symbol named sym_hist_filter */ 61 /* We're only interested in a symbol named sym_hist_filter */
62 /*
63 * FIXME: why isn't this done in the symbol_filter when loading
64 * the DSO?
65 */
62 if (al->sym != NULL) { 66 if (al->sym != NULL) {
63 rb_erase(&al->sym->rb_node, 67 rb_erase(&al->sym->rb_node,
64 &al->map->dso->symbols[al->map->type]); 68 &al->map->dso->symbols[al->map->type]);
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 0905b07072da..4d3a92d5dff3 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -225,6 +225,7 @@ struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
225 225
226void map__delete(struct map *map) 226void map__delete(struct map *map)
227{ 227{
228 BUG_ON(!RB_EMPTY_NODE(&map->rb_node));
228 free(map); 229 free(map);
229} 230}
230 231
@@ -446,7 +447,7 @@ static void __maps__purge(struct maps *maps)
446 struct map *pos = rb_entry(next, struct map, rb_node); 447 struct map *pos = rb_entry(next, struct map, rb_node);
447 448
448 next = rb_next(&pos->rb_node); 449 next = rb_next(&pos->rb_node);
449 rb_erase(&pos->rb_node, root); 450 rb_erase_init(&pos->rb_node, root);
450 map__delete(pos); 451 map__delete(pos);
451 } 452 }
452} 453}
@@ -456,7 +457,7 @@ static void __maps__purge_removed_maps(struct maps *maps)
456 struct map *pos, *n; 457 struct map *pos, *n;
457 458
458 list_for_each_entry_safe(pos, n, &maps->removed_maps, node) { 459 list_for_each_entry_safe(pos, n, &maps->removed_maps, node) {
459 list_del(&pos->node); 460 list_del_init(&pos->node);
460 map__delete(pos); 461 map__delete(pos);
461 } 462 }
462} 463}
@@ -671,7 +672,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp
671 map__fprintf(pos, fp); 672 map__fprintf(pos, fp);
672 } 673 }
673 674
674 rb_erase(&pos->rb_node, root); 675 rb_erase_init(&pos->rb_node, root);
675 /* 676 /*
676 * Now check if we need to create new maps for areas not 677 * Now check if we need to create new maps for areas not
677 * overlapped by the new map: 678 * overlapped by the new map:
@@ -782,7 +783,7 @@ void maps__insert(struct maps *maps, struct map *map)
782 783
783static void __maps__remove(struct maps *maps, struct map *map) 784static void __maps__remove(struct maps *maps, struct map *map)
784{ 785{
785 rb_erase(&map->rb_node, &maps->entries); 786 rb_erase_init(&map->rb_node, &maps->entries);
786} 787}
787 788
788void maps__remove(struct maps *maps, struct map *map) 789void maps__remove(struct maps *maps, struct map *map)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 8aae8b6b1cee..743a9b360e3d 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -659,14 +659,14 @@ static int dso__split_kallsyms_for_kcore(struct dso *dso, struct map *map,
659 curr_map = map_groups__find(kmaps, map->type, pos->start); 659 curr_map = map_groups__find(kmaps, map->type, pos->start);
660 660
661 if (!curr_map || (filter && filter(curr_map, pos))) { 661 if (!curr_map || (filter && filter(curr_map, pos))) {
662 rb_erase(&pos->rb_node, root); 662 rb_erase_init(&pos->rb_node, root);
663 symbol__delete(pos); 663 symbol__delete(pos);
664 } else { 664 } else {
665 pos->start -= curr_map->start - curr_map->pgoff; 665 pos->start -= curr_map->start - curr_map->pgoff;
666 if (pos->end) 666 if (pos->end)
667 pos->end -= curr_map->start - curr_map->pgoff; 667 pos->end -= curr_map->start - curr_map->pgoff;
668 if (curr_map != map) { 668 if (curr_map != map) {
669 rb_erase(&pos->rb_node, root); 669 rb_erase_init(&pos->rb_node, root);
670 symbols__insert( 670 symbols__insert(
671 &curr_map->dso->symbols[curr_map->type], 671 &curr_map->dso->symbols[curr_map->type],
672 pos); 672 pos);
@@ -1173,7 +1173,7 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
1173 /* Add new maps */ 1173 /* Add new maps */
1174 while (!list_empty(&md.maps)) { 1174 while (!list_empty(&md.maps)) {
1175 new_map = list_entry(md.maps.next, struct map, node); 1175 new_map = list_entry(md.maps.next, struct map, node);
1176 list_del(&new_map->node); 1176 list_del_init(&new_map->node);
1177 if (new_map == replacement_map) { 1177 if (new_map == replacement_map) {
1178 map->start = new_map->start; 1178 map->start = new_map->start;
1179 map->end = new_map->end; 1179 map->end = new_map->end;
@@ -1211,7 +1211,7 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
1211out_err: 1211out_err:
1212 while (!list_empty(&md.maps)) { 1212 while (!list_empty(&md.maps)) {
1213 map = list_entry(md.maps.next, struct map, node); 1213 map = list_entry(md.maps.next, struct map, node);
1214 list_del(&map->node); 1214 list_del_init(&map->node);
1215 map__delete(map); 1215 map__delete(map);
1216 } 1216 }
1217 close(fd); 1217 close(fd);