[PATCH] perf tools: Fix endless loop in dso__split_kallsyms_for_kcore

From: Jiri Olsa
Date: Mon Oct 26 2015 - 09:51:40 EST


On Mon, Oct 26, 2015 at 03:22:33PM +0200, Adrian Hunter wrote:
> On 26/10/15 15:01, Jiri Olsa wrote:
> > hi,
> > I'm getting stuck buildid-list command on s390
> >
> > seems like the kcore code gets stuck with inseting
> > into rbtree while iterating it..
> >
> > I was able to fix it with patch below, bu I'm not sure it's the
> > correct fix because the kcore maps magic is beyond me so far ;-)
> >
> > please check attached backtrace and patch
>
> Your fix looks correct to me.

great, attached patch with changelog.. please
feel free to add more detail or correct it

thanks,
jirka


---
Currently we split symbols based on the map comparison,
but symbols are stored within dso objects and maps could
point into same dso objects (kernel maps).

Hence we could end up changing rbtree we are currently
iterating and mess it up. It's easily reproduced on
s390x by running:

$ perf record -a -- sleep 3
$ perf buildid-list -i perf.data --with-hits

The fix is to compare dso objects instead.

Reported-by: Michael Petlan <mpetlan@xxxxxxxxxx>
Link: http://lkml.kernel.org/n/tip-p9ge2nvme7u5s21j0sn987wd@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/util/symbol.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index e7bf0c46918d..b0d2fb272f7e 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -680,7 +680,7 @@ static int dso__split_kallsyms_for_kcore(struct dso *dso, struct map *map,
pos->start -= curr_map->start - curr_map->pgoff;
if (pos->end)
pos->end -= curr_map->start - curr_map->pgoff;
- if (curr_map != map) {
+ if (curr_map->dso != map->dso) {
rb_erase_init(&pos->rb_node, root);
symbols__insert(
&curr_map->dso->symbols[curr_map->type],
--
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/