diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-06-15 22:29:51 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-06-16 09:34:38 -0400 |
commit | 5c24b67aae72f54c5d2a6898be4bae9726df63bb (patch) | |
tree | 14cf53530c0b85b7e1cb5599c62be9a059ab978b /tools/perf/util/map.c | |
parent | 35a23ff928b066b00a826d0a9ed9411b8ab479ef (diff) |
perf tools: Replace map->referenced & maps->removed_maps with map->refcnt
Use just reference counts, so that when no more hist_entry instances
references a map and the thread instance goes away by processing a
PERF_RECORD_EXIT, we can delete the maps.
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-oym7lfhcc7ss6xpz44h7nbxs@git.kernel.org
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.c | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 1241ab989cf5..b5a5e9c02437 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -137,7 +137,6 @@ void map__init(struct map *map, enum map_type type, | |||
137 | map->unmap_ip = map__unmap_ip; | 137 | map->unmap_ip = map__unmap_ip; |
138 | RB_CLEAR_NODE(&map->rb_node); | 138 | RB_CLEAR_NODE(&map->rb_node); |
139 | map->groups = NULL; | 139 | map->groups = NULL; |
140 | map->referenced = false; | ||
141 | map->erange_warned = false; | 140 | map->erange_warned = false; |
142 | atomic_set(&map->refcnt, 1); | 141 | atomic_set(&map->refcnt, 1); |
143 | } | 142 | } |
@@ -439,7 +438,6 @@ static void maps__init(struct maps *maps) | |||
439 | { | 438 | { |
440 | maps->entries = RB_ROOT; | 439 | maps->entries = RB_ROOT; |
441 | pthread_rwlock_init(&maps->lock, NULL); | 440 | pthread_rwlock_init(&maps->lock, NULL); |
442 | INIT_LIST_HEAD(&maps->removed_maps); | ||
443 | } | 441 | } |
444 | 442 | ||
445 | void map_groups__init(struct map_groups *mg, struct machine *machine) | 443 | void map_groups__init(struct map_groups *mg, struct machine *machine) |
@@ -466,21 +464,10 @@ static void __maps__purge(struct maps *maps) | |||
466 | } | 464 | } |
467 | } | 465 | } |
468 | 466 | ||
469 | static void __maps__purge_removed_maps(struct maps *maps) | ||
470 | { | ||
471 | struct map *pos, *n; | ||
472 | |||
473 | list_for_each_entry_safe(pos, n, &maps->removed_maps, node) { | ||
474 | list_del_init(&pos->node); | ||
475 | map__put(pos); | ||
476 | } | ||
477 | } | ||
478 | |||
479 | static void maps__exit(struct maps *maps) | 467 | static void maps__exit(struct maps *maps) |
480 | { | 468 | { |
481 | pthread_rwlock_wrlock(&maps->lock); | 469 | pthread_rwlock_wrlock(&maps->lock); |
482 | __maps__purge(maps); | 470 | __maps__purge(maps); |
483 | __maps__purge_removed_maps(maps); | ||
484 | pthread_rwlock_unlock(&maps->lock); | 471 | pthread_rwlock_unlock(&maps->lock); |
485 | } | 472 | } |
486 | 473 | ||
@@ -499,8 +486,6 @@ bool map_groups__empty(struct map_groups *mg) | |||
499 | for (i = 0; i < MAP__NR_TYPES; ++i) { | 486 | for (i = 0; i < MAP__NR_TYPES; ++i) { |
500 | if (maps__first(&mg->maps[i])) | 487 | if (maps__first(&mg->maps[i])) |
501 | return false; | 488 | return false; |
502 | if (!list_empty(&mg->maps[i].removed_maps)) | ||
503 | return false; | ||
504 | } | 489 | } |
505 | 490 | ||
506 | return true; | 491 | return true; |
@@ -621,7 +606,7 @@ size_t __map_groups__fprintf_maps(struct map_groups *mg, enum map_type type, | |||
621 | return printed += maps__fprintf(&mg->maps[type], fp); | 606 | return printed += maps__fprintf(&mg->maps[type], fp); |
622 | } | 607 | } |
623 | 608 | ||
624 | static size_t map_groups__fprintf_maps(struct map_groups *mg, FILE *fp) | 609 | size_t map_groups__fprintf(struct map_groups *mg, FILE *fp) |
625 | { | 610 | { |
626 | size_t printed = 0, i; | 611 | size_t printed = 0, i; |
627 | for (i = 0; i < MAP__NR_TYPES; ++i) | 612 | for (i = 0; i < MAP__NR_TYPES; ++i) |
@@ -629,39 +614,6 @@ static size_t map_groups__fprintf_maps(struct map_groups *mg, FILE *fp) | |||
629 | return printed; | 614 | return printed; |
630 | } | 615 | } |
631 | 616 | ||
632 | static size_t __map_groups__fprintf_removed_maps(struct map_groups *mg, | ||
633 | enum map_type type, FILE *fp) | ||
634 | { | ||
635 | struct map *pos; | ||
636 | size_t printed = 0; | ||
637 | |||
638 | list_for_each_entry(pos, &mg->maps[type].removed_maps, node) { | ||
639 | printed += fprintf(fp, "Map:"); | ||
640 | printed += map__fprintf(pos, fp); | ||
641 | if (verbose > 1) { | ||
642 | printed += dso__fprintf(pos->dso, type, fp); | ||
643 | printed += fprintf(fp, "--\n"); | ||
644 | } | ||
645 | } | ||
646 | return printed; | ||
647 | } | ||
648 | |||
649 | static size_t map_groups__fprintf_removed_maps(struct map_groups *mg, | ||
650 | FILE *fp) | ||
651 | { | ||
652 | size_t printed = 0, i; | ||
653 | for (i = 0; i < MAP__NR_TYPES; ++i) | ||
654 | printed += __map_groups__fprintf_removed_maps(mg, i, fp); | ||
655 | return printed; | ||
656 | } | ||
657 | |||
658 | size_t map_groups__fprintf(struct map_groups *mg, FILE *fp) | ||
659 | { | ||
660 | size_t printed = map_groups__fprintf_maps(mg, fp); | ||
661 | printed += fprintf(fp, "Removed maps:\n"); | ||
662 | return printed + map_groups__fprintf_removed_maps(mg, fp); | ||
663 | } | ||
664 | |||
665 | static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) | 617 | static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) |
666 | { | 618 | { |
667 | struct rb_root *root; | 619 | struct rb_root *root; |
@@ -719,13 +671,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp | |||
719 | map__fprintf(after, fp); | 671 | map__fprintf(after, fp); |
720 | } | 672 | } |
721 | put_map: | 673 | put_map: |
722 | /* | 674 | map__put(pos); |
723 | * If we have references, just move them to a separate list. | ||
724 | */ | ||
725 | if (pos->referenced) | ||
726 | list_add_tail(&pos->node, &maps->removed_maps); | ||
727 | else | ||
728 | map__put(pos); | ||
729 | 675 | ||
730 | if (err) | 676 | if (err) |
731 | goto out; | 677 | goto out; |