Skip to content

Commit

Permalink
perf annnotate: Make __symbol__inc_addr_samples handle src->histogram…
Browse files Browse the repository at this point in the history
…s == NULL

Making it a bit more robust, this took place here when a sample appeared
right after:

  ffffffff8a925000 D __nosave_end

And before the next considered symbol, which, using kallsyms make us
over guess the size of __nosave_end, and then the sequence:

  hist_entry__inc_addr_samples ->
    symbol__inc_addr_samples ->
      symbol__hists ->
        annotated_source__alloc_histograms

Ends up not liking to allocate gigabytes of ram for annotation...

This will be alleviated by considering BSS symbols, which we should but
don't so far, and then we should investigate those samples further.

The testcase was to have:

   perf top -e cycles/call-graph=fp/,cache-misses/call-graph=dwarf/,instructions

Running for a while till it segfaulted trying to access NULL notes->src->histograms.

Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Wang Nan <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Jun 6, 2018
1 parent 9fb5233 commit 8d628d2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/perf/util/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,11 @@ static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,

offset = addr - sym->start;
h = annotated_source__histogram(src, evidx);
if (h == NULL) {
pr_debug("%s(%d): ENOMEM! sym->name=%s, start=%#" PRIx64 ", addr=%#" PRIx64 ", end=%#" PRIx64 ", func: %d\n",
__func__, __LINE__, sym->name, sym->start, addr, sym->end, sym->type == STT_FUNC);
return -ENOMEM;
}
h->nr_samples++;
h->addr[offset].nr_samples++;
h->period += sample->period;
Expand Down

0 comments on commit 8d628d2

Please sign in to comment.