Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Do not disable source line lookup just because of 1 failure

Looking up an ip's source file name and line number does not succeed
always. Current logic disables the lookup for a dso entirely on any
failure. Change it so that disabling never happens if there has ever
been a successful lookup for that dso but disable if the first 123
lookups fail.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1386055390-13757-8-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
906049c8 0058aef6

+18 -4
+1
tools/perf/util/dso.c
··· 451 451 dso->sorted_by_name = 0; 452 452 dso->has_build_id = 0; 453 453 dso->has_srcline = 1; 454 + dso->a2l_fails = 1; 454 455 dso->kernel = DSO_TYPE_USER; 455 456 dso->needs_swap = DSO_SWAP__UNSET; 456 457 INIT_LIST_HEAD(&dso->node);
+1
tools/perf/util/dso.h
··· 79 79 struct rb_root cache; 80 80 void *a2l; 81 81 char *symsrc_filename; 82 + unsigned int a2l_fails; 82 83 enum dso_kernel_type kernel; 83 84 enum dso_swap_type needs_swap; 84 85 enum dso_binary_type symtab_type;
+16 -4
tools/perf/util/srcline.c
··· 244 244 245 245 #endif /* HAVE_LIBBFD_SUPPORT */ 246 246 247 + /* 248 + * Number of addr2line failures (without success) before disabling it for that 249 + * dso. 250 + */ 251 + #define A2L_FAIL_LIMIT 123 252 + 247 253 char *get_srcline(struct dso *dso, unsigned long addr) 248 254 { 249 255 char *file = NULL; ··· 274 268 if (!addr2line(dso_name, addr, &file, &line, dso)) 275 269 goto out; 276 270 277 - if (asprintf(&srcline, "%s:%u", file, line) < 0) 278 - srcline = SRCLINE_UNKNOWN; 271 + if (asprintf(&srcline, "%s:%u", file, line) < 0) { 272 + free(file); 273 + goto out; 274 + } 275 + 276 + dso->a2l_fails = 0; 279 277 280 278 free(file); 281 279 return srcline; 282 280 283 281 out: 284 - dso->has_srcline = 0; 285 - dso__free_a2l(dso); 282 + if (dso->a2l_fails && ++dso->a2l_fails > A2L_FAIL_LIMIT) { 283 + dso->has_srcline = 0; 284 + dso__free_a2l(dso); 285 + } 286 286 return SRCLINE_UNKNOWN; 287 287 } 288 288