Skip to content

Commit c27697d

Browse files
ahunter6acmel
authored andcommitted
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>
1 parent 578bea4 commit c27697d

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

‎tools/perf/util/dso.c‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,26 +331,32 @@ int dso__data_fd(struct dso *dso, struct machine *machine)
331331
};
332332
int i = 0;
333333

334+
if (dso->data.status == DSO_DATA_STATUS_ERROR)
335+
return -1;
336+
334337
if (dso->data.fd >= 0)
335-
return dso->data.fd;
338+
goto out;
336339

337340
if (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND) {
338341
dso->data.fd = open_dso(dso, machine);
339-
return dso->data.fd;
342+
goto out;
340343
}
341344

342345
do {
343-
int fd;
344-
345346
dso->binary_type = binary_type_data[i++];
346347

347-
fd = open_dso(dso, machine);
348-
if (fd >= 0)
349-
return dso->data.fd = fd;
348+
dso->data.fd = open_dso(dso, machine);
349+
if (dso->data.fd >= 0)
350+
goto out;
350351

351352
} 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;
352358

353-
return -EINVAL;
359+
return dso->data.fd;
354360
}
355361

356362
static void
@@ -701,6 +707,7 @@ struct dso *dso__new(const char *name)
701707
dso->symbols[i] = dso->symbol_names[i] = RB_ROOT;
702708
dso->data.cache = RB_ROOT;
703709
dso->data.fd = -1;
710+
dso->data.status = DSO_DATA_STATUS_UNKNOWN;
704711
dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND;
705712
dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND;
706713
dso->is_64_bit = (sizeof(void *) == 8);

‎tools/perf/util/dso.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ enum dso_swap_type {
4040
DSO_SWAP__YES,
4141
};
4242

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+
4349
#define DSO__SWAP(dso, type, val) \
4450
({ \
4551
type ____r = val; \
@@ -104,6 +110,7 @@ struct dso {
104110
struct {
105111
struct rb_root cache;
106112
int fd;
113+
int status;
107114
size_t file_size;
108115
struct list_head open_entry;
109116
} data;

0 commit comments

Comments
 (0)