perf tools: Do not disable source line lookup just because of 1 failure
authorAdrian Hunter <adrian.hunter@intel.com>
Tue, 3 Dec 2013 07:23:10 +0000 (09:23 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 4 Dec 2013 16:46:36 +0000 (13:46 -0300)
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>
tools/perf/util/dso.c
tools/perf/util/dso.h
tools/perf/util/srcline.c

index 49da9684f63595bcfc892f80c59df08c29ea3d36..a0c7c591f4b2d5b571eecbb157c3b2d7185174fc 100644 (file)
@@ -451,6 +451,7 @@ struct dso *dso__new(const char *name)
                dso->sorted_by_name = 0;
                dso->has_build_id = 0;
                dso->has_srcline = 1;
+               dso->a2l_fails = 1;
                dso->kernel = DSO_TYPE_USER;
                dso->needs_swap = DSO_SWAP__UNSET;
                INIT_LIST_HEAD(&dso->node);
index 7142e526126605964fbd4359cf7e9fcbf21b6512..384f2d97e38e110aa0ebb9fc95103bf02a0cb44c 100644 (file)
@@ -79,6 +79,7 @@ struct dso {
        struct rb_root   cache;
        void             *a2l;
        char             *symsrc_filename;
+       unsigned int     a2l_fails;
        enum dso_kernel_type    kernel;
        enum dso_swap_type      needs_swap;
        enum dso_binary_type    symtab_type;
index 93795f9c24806069eea5b0c9ec11d2273475b65b..0c075560ad46bc6989de9569ea91928d3017ccb6 100644 (file)
@@ -244,6 +244,12 @@ void dso__free_a2l(struct dso *dso __maybe_unused)
 
 #endif /* HAVE_LIBBFD_SUPPORT */
 
+/*
+ * Number of addr2line failures (without success) before disabling it for that
+ * dso.
+ */
+#define A2L_FAIL_LIMIT 123
+
 char *get_srcline(struct dso *dso, unsigned long addr)
 {
        char *file = NULL;
@@ -268,15 +274,21 @@ char *get_srcline(struct dso *dso, unsigned long addr)
        if (!addr2line(dso_name, addr, &file, &line, dso))
                goto out;
 
-       if (asprintf(&srcline, "%s:%u", file, line) < 0)
-               srcline = SRCLINE_UNKNOWN;
+       if (asprintf(&srcline, "%s:%u", file, line) < 0) {
+               free(file);
+               goto out;
+       }
+
+       dso->a2l_fails = 0;
 
        free(file);
        return srcline;
 
 out:
-       dso->has_srcline = 0;
-       dso__free_a2l(dso);
+       if (dso->a2l_fails && ++dso->a2l_fails > A2L_FAIL_LIMIT) {
+               dso->has_srcline = 0;
+               dso__free_a2l(dso);
+       }
        return SRCLINE_UNKNOWN;
 }