Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 205367
b: refs/heads/master
c: 0a1eae3
h: refs/heads/master
i:
  205365: b7f2caf
  205363: 41f70b7
  205359: 03aae3d
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Aug 2, 2010
1 parent c5fd7d1 commit 3464d8e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 70597f21f128b7dd6a2490078bea99d704b6f8c3
refs/heads/master: 0a1eae391d0d92b60cff9f55cdaf3861b4e33922
2 changes: 2 additions & 0 deletions trunk/tools/perf/util/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template)
if (self != NULL) {
*self = *template;
self->nr_events = 1;
if (self->ms.map)
self->ms.map->referenced = true;
if (symbol_conf.use_callchain)
callchain_init(self->callchain);
}
Expand Down
31 changes: 21 additions & 10 deletions trunk/tools/perf/util/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void map__init(struct map *self, enum map_type type,
self->unmap_ip = map__unmap_ip;
RB_CLEAR_NODE(&self->rb_node);
self->groups = NULL;
self->referenced = false;
}

struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
Expand Down Expand Up @@ -387,6 +388,7 @@ int map_groups__fixup_overlappings(struct map_groups *self, struct map *map,
{
struct rb_root *root = &self->maps[map->type];
struct rb_node *next = rb_first(root);
int err = 0;

while (next) {
struct map *pos = rb_entry(next, struct map, rb_node);
Expand All @@ -402,21 +404,17 @@ int map_groups__fixup_overlappings(struct map_groups *self, struct map *map,
}

rb_erase(&pos->rb_node, root);
/*
* We may have references to this map, for instance in some
* hist_entry instances, so just move them to a separate
* list.
*/
list_add_tail(&pos->node, &self->removed_maps[map->type]);
/*
* Now check if we need to create new maps for areas not
* overlapped by the new map:
*/
if (map->start > pos->start) {
struct map *before = map__clone(pos);

if (before == NULL)
return -ENOMEM;
if (before == NULL) {
err = -ENOMEM;
goto move_map;
}

before->end = map->start - 1;
map_groups__insert(self, before);
Expand All @@ -427,14 +425,27 @@ int map_groups__fixup_overlappings(struct map_groups *self, struct map *map,
if (map->end < pos->end) {
struct map *after = map__clone(pos);

if (after == NULL)
return -ENOMEM;
if (after == NULL) {
err = -ENOMEM;
goto move_map;
}

after->start = map->end + 1;
map_groups__insert(self, after);
if (verbose >= 2)
map__fprintf(after, fp);
}
move_map:
/*
* If we have references, just move them to a separate list.
*/
if (pos->referenced)
list_add_tail(&pos->node, &self->removed_maps[map->type]);
else
map__delete(pos);

if (err)
return err;
}

return 0;
Expand Down
3 changes: 2 additions & 1 deletion trunk/tools/perf/util/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ struct map {
};
u64 start;
u64 end;
enum map_type type;
u8 /* enum map_type */ type;
bool referenced;
u32 priv;
u64 pgoff;

Expand Down

0 comments on commit 3464d8e

Please sign in to comment.