提交 866548dd 编写于 作者: A Adrian Hunter 提交者: Arnaldo Carvalho de Melo

perf symbols: Rebuild rbtree when adjusting symbols for kcore

Normally symbols are read from the DSO and adjusted, if need be, so that
the symbol start matches the file offset in the DSO file (we want the
file offset because that is what we know from MMAP events). That is done
by dso__load_sym() which inserts the symbols *after* adjusting them.

In the case of kcore, the symbols have been read from kallsyms and the
symbol start is the memory address. The symbols have to be adjusted to
match the kcore file offsets. dso__split_kallsyms_for_kcore() does that,
but now the adjustment is being done *after* the symbols have been
inserted. It appears dso__split_kallsyms_for_kcore() was assuming that
changing the symbol start would not change the order in the rbtree -
which is, of course, not guaranteed.
Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
Tested-by: NWang Nan <wangnan0@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/563CB241.2090701@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 f6ba98c5
...@@ -654,19 +654,24 @@ static int dso__split_kallsyms_for_kcore(struct dso *dso, struct map *map, ...@@ -654,19 +654,24 @@ static int dso__split_kallsyms_for_kcore(struct dso *dso, struct map *map,
struct map_groups *kmaps = map__kmaps(map); struct map_groups *kmaps = map__kmaps(map);
struct map *curr_map; struct map *curr_map;
struct symbol *pos; struct symbol *pos;
int count = 0, moved = 0; int count = 0;
struct rb_root old_root = dso->symbols[map->type];
struct rb_root *root = &dso->symbols[map->type]; struct rb_root *root = &dso->symbols[map->type];
struct rb_node *next = rb_first(root); struct rb_node *next = rb_first(root);
if (!kmaps) if (!kmaps)
return -1; return -1;
*root = RB_ROOT;
while (next) { while (next) {
char *module; char *module;
pos = rb_entry(next, struct symbol, rb_node); pos = rb_entry(next, struct symbol, rb_node);
next = rb_next(&pos->rb_node); next = rb_next(&pos->rb_node);
rb_erase_init(&pos->rb_node, &old_root);
module = strchr(pos->name, '\t'); module = strchr(pos->name, '\t');
if (module) if (module)
*module = '\0'; *module = '\0';
...@@ -674,28 +679,21 @@ static int dso__split_kallsyms_for_kcore(struct dso *dso, struct map *map, ...@@ -674,28 +679,21 @@ static int dso__split_kallsyms_for_kcore(struct dso *dso, struct map *map,
curr_map = map_groups__find(kmaps, map->type, pos->start); curr_map = map_groups__find(kmaps, map->type, pos->start);
if (!curr_map || (filter && filter(curr_map, pos))) { if (!curr_map || (filter && filter(curr_map, pos))) {
rb_erase_init(&pos->rb_node, root);
symbol__delete(pos); symbol__delete(pos);
} else { continue;
pos->start -= curr_map->start - curr_map->pgoff;
if (pos->end)
pos->end -= curr_map->start - curr_map->pgoff;
if (curr_map->dso != map->dso) {
rb_erase_init(&pos->rb_node, root);
symbols__insert(
&curr_map->dso->symbols[curr_map->type],
pos);
++moved;
} else {
++count;
}
} }
pos->start -= curr_map->start - curr_map->pgoff;
if (pos->end)
pos->end -= curr_map->start - curr_map->pgoff;
symbols__insert(&curr_map->dso->symbols[curr_map->type], pos);
++count;
} }
/* Symbols have been adjusted */ /* Symbols have been adjusted */
dso->adjust_symbols = 1; dso->adjust_symbols = 1;
return count + moved; return count;
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册