Re: [PATCH] perf symbols/KCORE: Rebuild rbtree when adjusting symbols for kcore

From: Arnaldo Carvalho de Melo
Date: Wed Nov 11 2015 - 15:44:38 EST


Em Wed, Nov 11, 2015 at 03:02:35PM +0800, Wangnan (F) escreveu:
>
>
> On 2015/11/6 21:59, Adrian Hunter wrote:
> >On 06/11/15 15:19, Arnaldo Carvalho de Melo wrote:
> >>Em Fri, Nov 06, 2015 at 09:46:12AM +0000, Wang Nan escreveu:
> >>>In dso__split_kallsyms_for_kcore(), current code adjusts symbol's
> >>>address but only reinsert it into rbtree if the symbol belongs to
> >>>another map. However, the expression for adjusting symbol (pos->start -=
> >>>curr_map->start - curr_map->pgoff) can change the relative order between
> >>>two symbols (even if the affected symbols are in different maps, in
> >>>kcore case they are possible to share one same dso), which damages the
> >>>rbtree.
> >>Right, some code does change the symbol values it gets from whatever
> >>symtab (kallsyms, ELF, JIT maps, etc) when it should instead use the per
> >>map data structure (struct map) and its ->{map,unmap}_ip, ->pgoff,
> >>->reloc, members for that :-\
> >>
> >>I.e. 'struct dso' should be just what comes from the symtab, while
> >>'struct map' should be about where that DSO is in memory.
> >>
> >>With that in mind, do you still think your fix is the correct one?
> >>
> >>Adrian?
> >The problem is when the order in memory (in kallsyms) is different
> >to the order on the dso (kcore).
> >
> >I think to make it more general it needs to insert to a new tree.
> >e.g.
> >
>
> I have tested this patch and it works for me.
>
> Thank you.

Adrian, I took your explanation as the commit log, adding your S-o-B, so
far not provided, is that ok with you, can I have your S-o-B?