diff options
| author | Ingo Molnar <mingo@elte.hu> | 2010-08-03 01:45:00 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2010-08-03 01:45:00 -0400 |
| commit | 43d7383bbec1878f838060d6bbd214f6d0485478 (patch) | |
| tree | 64869524fc8e9fe23a9712993c608ccdcecfc2a1 | |
| parent | 69e77a8b0426ded5d924eea7dbe4eca51e09f530 (diff) | |
| parent | 0a1eae391d0d92b60cff9f55cdaf3861b4e33922 (diff) | |
Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 into perf/core
| -rw-r--r-- | tools/perf/util/hist.c | 2 | ||||
| -rw-r--r-- | tools/perf/util/map.c | 49 | ||||
| -rw-r--r-- | tools/perf/util/map.h | 10 | ||||
| -rw-r--r-- | tools/perf/util/session.c | 8 | ||||
| -rw-r--r-- | tools/perf/util/symbol.c | 43 | ||||
| -rw-r--r-- | tools/perf/util/symbol.h | 2 |
6 files changed, 96 insertions, 18 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index a6cea2894d12..e7263d49bcf0 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
| @@ -93,6 +93,8 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template) | |||
| 93 | if (self != NULL) { | 93 | if (self != NULL) { |
| 94 | *self = *template; | 94 | *self = *template; |
| 95 | self->nr_events = 1; | 95 | self->nr_events = 1; |
| 96 | if (self->ms.map) | ||
| 97 | self->ms.map->referenced = true; | ||
| 96 | if (symbol_conf.use_callchain) | 98 | if (symbol_conf.use_callchain) |
| 97 | callchain_init(self->callchain); | 99 | callchain_init(self->callchain); |
| 98 | } | 100 | } |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 15d6a6dd50c5..3a7eb6ec0eec 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
| @@ -29,6 +29,7 @@ void map__init(struct map *self, enum map_type type, | |||
| 29 | self->unmap_ip = map__unmap_ip; | 29 | self->unmap_ip = map__unmap_ip; |
| 30 | RB_CLEAR_NODE(&self->rb_node); | 30 | RB_CLEAR_NODE(&self->rb_node); |
| 31 | self->groups = NULL; | 31 | self->groups = NULL; |
| 32 | self->referenced = false; | ||
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, | 35 | struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, |
| @@ -387,6 +388,7 @@ int map_groups__fixup_overlappings(struct map_groups *self, struct map *map, | |||
| 387 | { | 388 | { |
| 388 | struct rb_root *root = &self->maps[map->type]; | 389 | struct rb_root *root = &self->maps[map->type]; |
| 389 | struct rb_node *next = rb_first(root); | 390 | struct rb_node *next = rb_first(root); |
| 391 | int err = 0; | ||
| 390 | 392 | ||
| 391 | while (next) { | 393 | while (next) { |
| 392 | struct map *pos = rb_entry(next, struct map, rb_node); | 394 | struct map *pos = rb_entry(next, struct map, rb_node); |
| @@ -403,20 +405,16 @@ int map_groups__fixup_overlappings(struct map_groups *self, struct map *map, | |||
| 403 | 405 | ||
| 404 | rb_erase(&pos->rb_node, root); | 406 | rb_erase(&pos->rb_node, root); |
| 405 | /* | 407 | /* |
| 406 | * We may have references to this map, for instance in some | ||
| 407 | * hist_entry instances, so just move them to a separate | ||
| 408 | * list. | ||
| 409 | */ | ||
| 410 | list_add_tail(&pos->node, &self->removed_maps[map->type]); | ||
| 411 | /* | ||
| 412 | * Now check if we need to create new maps for areas not | 408 | * Now check if we need to create new maps for areas not |
| 413 | * overlapped by the new map: | 409 | * overlapped by the new map: |
| 414 | */ | 410 | */ |
| 415 | if (map->start > pos->start) { | 411 | if (map->start > pos->start) { |
| 416 | struct map *before = map__clone(pos); | 412 | struct map *before = map__clone(pos); |
| 417 | 413 | ||
| 418 | if (before == NULL) | 414 | if (before == NULL) { |
| 419 | return -ENOMEM; | 415 | err = -ENOMEM; |
| 416 | goto move_map; | ||
| 417 | } | ||
| 420 | 418 | ||
| 421 | before->end = map->start - 1; | 419 | before->end = map->start - 1; |
| 422 | map_groups__insert(self, before); | 420 | map_groups__insert(self, before); |
| @@ -427,14 +425,27 @@ int map_groups__fixup_overlappings(struct map_groups *self, struct map *map, | |||
| 427 | if (map->end < pos->end) { | 425 | if (map->end < pos->end) { |
| 428 | struct map *after = map__clone(pos); | 426 | struct map *after = map__clone(pos); |
| 429 | 427 | ||
| 430 | if (after == NULL) | 428 | if (after == NULL) { |
| 431 | return -ENOMEM; | 429 | err = -ENOMEM; |
| 430 | goto move_map; | ||
| 431 | } | ||
| 432 | 432 | ||
| 433 | after->start = map->end + 1; | 433 | after->start = map->end + 1; |
| 434 | map_groups__insert(self, after); | 434 | map_groups__insert(self, after); |
| 435 | if (verbose >= 2) | 435 | if (verbose >= 2) |
| 436 | map__fprintf(after, fp); | 436 | map__fprintf(after, fp); |
| 437 | } | 437 | } |
| 438 | move_map: | ||
| 439 | /* | ||
| 440 | * If we have references, just move them to a separate list. | ||
| 441 | */ | ||
| 442 | if (pos->referenced) | ||
| 443 | list_add_tail(&pos->node, &self->removed_maps[map->type]); | ||
| 444 | else | ||
| 445 | map__delete(pos); | ||
| 446 | |||
| 447 | if (err) | ||
| 448 | return err; | ||
| 438 | } | 449 | } |
| 439 | 450 | ||
| 440 | return 0; | 451 | return 0; |
| @@ -506,6 +517,11 @@ void maps__insert(struct rb_root *maps, struct map *map) | |||
| 506 | rb_insert_color(&map->rb_node, maps); | 517 | rb_insert_color(&map->rb_node, maps); |
| 507 | } | 518 | } |
| 508 | 519 | ||
| 520 | void maps__remove(struct rb_root *self, struct map *map) | ||
| 521 | { | ||
| 522 | rb_erase(&map->rb_node, self); | ||
| 523 | } | ||
| 524 | |||
| 509 | struct map *maps__find(struct rb_root *maps, u64 ip) | 525 | struct map *maps__find(struct rb_root *maps, u64 ip) |
| 510 | { | 526 | { |
| 511 | struct rb_node **p = &maps->rb_node; | 527 | struct rb_node **p = &maps->rb_node; |
| @@ -551,13 +567,6 @@ static void dsos__delete(struct list_head *self) | |||
| 551 | 567 | ||
| 552 | void machine__exit(struct machine *self) | 568 | void machine__exit(struct machine *self) |
| 553 | { | 569 | { |
| 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); | 570 | map_groups__exit(&self->kmaps); |
| 562 | dsos__delete(&self->user_dsos); | 571 | dsos__delete(&self->user_dsos); |
| 563 | dsos__delete(&self->kernel_dsos); | 572 | dsos__delete(&self->kernel_dsos); |
| @@ -565,6 +574,12 @@ void machine__exit(struct machine *self) | |||
| 565 | self->root_dir = NULL; | 574 | self->root_dir = NULL; |
| 566 | } | 575 | } |
| 567 | 576 | ||
| 577 | void machine__delete(struct machine *self) | ||
| 578 | { | ||
| 579 | machine__exit(self); | ||
| 580 | free(self); | ||
| 581 | } | ||
| 582 | |||
| 568 | struct machine *machines__add(struct rb_root *self, pid_t pid, | 583 | struct machine *machines__add(struct rb_root *self, pid_t pid, |
| 569 | const char *root_dir) | 584 | const char *root_dir) |
| 570 | { | 585 | { |
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 0e0984e86fce..78575796d5f3 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h | |||
| @@ -29,7 +29,8 @@ struct map { | |||
| 29 | }; | 29 | }; |
| 30 | u64 start; | 30 | u64 start; |
| 31 | u64 end; | 31 | u64 end; |
| 32 | enum map_type type; | 32 | u8 /* enum map_type */ type; |
| 33 | bool referenced; | ||
| 33 | u32 priv; | 34 | u32 priv; |
| 34 | u64 pgoff; | 35 | u64 pgoff; |
| 35 | 36 | ||
| @@ -125,6 +126,7 @@ void map__reloc_vmlinux(struct map *self); | |||
| 125 | size_t __map_groups__fprintf_maps(struct map_groups *self, | 126 | size_t __map_groups__fprintf_maps(struct map_groups *self, |
| 126 | enum map_type type, int verbose, FILE *fp); | 127 | enum map_type type, int verbose, FILE *fp); |
| 127 | void maps__insert(struct rb_root *maps, struct map *map); | 128 | void maps__insert(struct rb_root *maps, struct map *map); |
| 129 | void maps__remove(struct rb_root *self, struct map *map); | ||
| 128 | struct map *maps__find(struct rb_root *maps, u64 addr); | 130 | struct map *maps__find(struct rb_root *maps, u64 addr); |
| 129 | void map_groups__init(struct map_groups *self); | 131 | void map_groups__init(struct map_groups *self); |
| 130 | void map_groups__exit(struct map_groups *self); | 132 | void map_groups__exit(struct map_groups *self); |
| @@ -144,6 +146,7 @@ struct machine *machines__findnew(struct rb_root *self, pid_t pid); | |||
| 144 | char *machine__mmap_name(struct machine *self, char *bf, size_t size); | 146 | char *machine__mmap_name(struct machine *self, char *bf, size_t size); |
| 145 | int machine__init(struct machine *self, const char *root_dir, pid_t pid); | 147 | int machine__init(struct machine *self, const char *root_dir, pid_t pid); |
| 146 | void machine__exit(struct machine *self); | 148 | void machine__exit(struct machine *self); |
| 149 | void machine__delete(struct machine *self); | ||
| 147 | 150 | ||
| 148 | /* | 151 | /* |
| 149 | * Default guest kernel is defined by parameter --guestkallsyms | 152 | * Default guest kernel is defined by parameter --guestkallsyms |
| @@ -165,6 +168,11 @@ static inline void map_groups__insert(struct map_groups *self, struct map *map) | |||
| 165 | map->groups = self; | 168 | map->groups = self; |
| 166 | } | 169 | } |
| 167 | 170 | ||
| 171 | static inline void map_groups__remove(struct map_groups *self, struct map *map) | ||
| 172 | { | ||
| 173 | maps__remove(&self->maps[map->type], map); | ||
| 174 | } | ||
| 175 | |||
| 168 | static inline struct map *map_groups__find(struct map_groups *self, | 176 | static inline struct map *map_groups__find(struct map_groups *self, |
| 169 | enum map_type type, u64 addr) | 177 | enum map_type type, u64 addr) |
| 170 | { | 178 | { |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 04a3b3db9e90..fa9d652c2dc3 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
| @@ -79,6 +79,12 @@ int perf_session__create_kernel_maps(struct perf_session *self) | |||
| 79 | return ret; | 79 | return ret; |
