diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2014-07-22 09:17:18 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-07-23 10:22:35 -0400 |
commit | c27697d6dee02ef2389b6701c792a075bc9873dc (patch) | |
tree | dd651ab086c5f25d5cee4a51b1b4f6928bad9645 /tools | |
parent | 578bea40058b68f83658827c2b68a596b08419fc (diff) |
perf tools: Record whether a dso has data
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>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/dso.c | 23 | ||||
-rw-r--r-- | tools/perf/util/dso.h | 7 |
2 files changed, 22 insertions, 8 deletions
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 28cf7476b68c..8827db3d2cba 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
@@ -331,26 +331,32 @@ int dso__data_fd(struct dso *dso, struct machine *machine) | |||
331 | }; | 331 | }; |
332 | int i = 0; | 332 | int i = 0; |
333 | 333 | ||
334 | if (dso->data.status == DSO_DATA_STATUS_ERROR) | ||
335 | return -1; | ||
336 | |||
334 | if (dso->data.fd >= 0) | 337 | if (dso->data.fd >= 0) |
335 | return dso->data.fd; | 338 | goto out; |
336 | 339 | ||
337 | if (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND) { | 340 | if (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND) { |
338 | dso->data.fd = open_dso(dso, machine); | 341 | dso->data.fd = open_dso(dso, machine); |
339 | return dso->data.fd; | 342 | goto out; |
340 | } | 343 | } |
341 | 344 | ||
342 | do { | 345 | do { |
343 | int fd; | ||
344 | |||
345 | dso->binary_type = binary_type_data[i++]; | 346 | dso->binary_type = binary_type_data[i++]; |
346 | 347 | ||
347 | fd = open_dso(dso, machine); | 348 | dso->data.fd = open_dso(dso, machine); |
348 | if (fd >= 0) | 349 | if (dso->data.fd >= 0) |
349 | return dso->data.fd = fd; | 350 | goto out; |
350 | 351 | ||
351 | } while (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND); | 352 | } while (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND); |
353 | out: | ||
354 | if (dso->data.fd >= 0) | ||
355 | dso->data.status = DSO_DATA_STATUS_OK; | ||
356 | else | ||
357 | dso->data.status = DSO_DATA_STATUS_ERROR; | ||
352 | 358 | ||
353 | return -EINVAL; | 359 | return dso->data.fd; |
354 | } | 360 | } |
355 | 361 | ||
356 | static void | 362 | static void |
@@ -701,6 +707,7 @@ struct dso *dso__new(const char *name) | |||
701 | dso->symbols[i] = dso->symbol_names[i] = RB_ROOT; | 707 | dso->symbols[i] = dso->symbol_names[i] = RB_ROOT; |
702 | dso->data.cache = RB_ROOT; | 708 | dso->data.cache = RB_ROOT; |
703 | dso->data.fd = -1; | 709 | dso->data.fd = -1; |
710 | dso->data.status = DSO_DATA_STATUS_UNKNOWN; | ||
704 | dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND; | 711 | dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND; |
705 | dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND; | 712 | dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND; |
706 | dso->is_64_bit = (sizeof(void *) == 8); | 713 | dso->is_64_bit = (sizeof(void *) == 8); |
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index c239e86541a3..aeb7bcbf0239 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h | |||
@@ -40,6 +40,12 @@ enum dso_swap_type { | |||
40 | DSO_SWAP__YES, | 40 | DSO_SWAP__YES, |
41 | }; | 41 | }; |
42 | 42 | ||
43 | enum dso_data_status { | ||
44 | DSO_DATA_STATUS_ERROR = -1, | ||
45 | DSO_DATA_STATUS_UNKNOWN = 0, | ||
46 | DSO_DATA_STATUS_OK = 1, | ||
47 | }; | ||
48 | |||
43 | #define DSO__SWAP(dso, type, val) \ | 49 | #define DSO__SWAP(dso, type, val) \ |
44 | ({ \ | 50 | ({ \ |
45 | type ____r = val; \ | 51 | type ____r = val; \ |
@@ -104,6 +110,7 @@ struct dso { | |||
104 | struct { | 110 | struct { |
105 | struct rb_root cache; | 111 | struct rb_root cache; |
106 | int fd; | 112 | int fd; |
113 | int status; | ||
107 | size_t file_size; | 114 | size_t file_size; |
108 | struct list_head open_entry; | 115 | struct list_head open_entry; |
109 | } data; | 116 | } data; |