]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
perf tools: Record whether a dso has data
authorAdrian Hunter <adrian.hunter@intel.com>
Tue, 22 Jul 2014 13:17:18 +0000 (16:17 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 23 Jul 2014 14:22:35 +0000 (11:22 -0300)
Add 'data.status' to record whether a dso has data (i.e. an object
file).  This is used to avoid repeatedly creating the file name and
attempting to open a file that is not present.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1406035081-14301-10-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

index 28cf7476b68c0f1fb0dd6b97f03196c99ddcd2c1..8827db3d2cba370885ef2d175958d5a213a42508 100644 (file)
@@ -331,26 +331,32 @@ int dso__data_fd(struct dso *dso, struct machine *machine)
        };
        int i = 0;
 
+       if (dso->data.status == DSO_DATA_STATUS_ERROR)
+               return -1;
+
        if (dso->data.fd >= 0)
-               return dso->data.fd;
+               goto out;
 
        if (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND) {
                dso->data.fd = open_dso(dso, machine);
-               return dso->data.fd;
+               goto out;
        }
 
        do {
-               int fd;
-
                dso->binary_type = binary_type_data[i++];
 
-               fd = open_dso(dso, machine);
-               if (fd >= 0)
-                       return dso->data.fd = fd;
+               dso->data.fd = open_dso(dso, machine);
+               if (dso->data.fd >= 0)
+                       goto out;
 
        } while (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND);
+out:
+       if (dso->data.fd >= 0)
+               dso->data.status = DSO_DATA_STATUS_OK;
+       else
+               dso->data.status = DSO_DATA_STATUS_ERROR;
 
-       return -EINVAL;
+       return dso->data.fd;
 }
 
 static void
@@ -701,6 +707,7 @@ struct dso *dso__new(const char *name)
                        dso->symbols[i] = dso->symbol_names[i] = RB_ROOT;
                dso->data.cache = RB_ROOT;
                dso->data.fd = -1;
+               dso->data.status = DSO_DATA_STATUS_UNKNOWN;
                dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND;
                dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND;
                dso->is_64_bit = (sizeof(void *) == 8);
index c239e86541a3d075a1b8790d89ffd356ead177e6..aeb7bcbf023978ac142ec5b4f11373131467d441 100644 (file)
@@ -40,6 +40,12 @@ enum dso_swap_type {
        DSO_SWAP__YES,
 };
 
+enum dso_data_status {
+       DSO_DATA_STATUS_ERROR   = -1,
+       DSO_DATA_STATUS_UNKNOWN = 0,
+       DSO_DATA_STATUS_OK      = 1,
+};
+
 #define DSO__SWAP(dso, type, val)                      \
 ({                                                     \
        type ____r = val;                               \
@@ -104,6 +110,7 @@ struct dso {
        struct {
                struct rb_root   cache;
                int              fd;
+               int              status;
                size_t           file_size;
                struct list_head open_entry;
        } data;