diff options
author | Jiri Olsa <jolsa@kernel.org> | 2014-04-28 10:43:43 -0400 |
---|---|---|
committer | Jiri Olsa <jolsa@kernel.org> | 2014-06-12 10:53:19 -0400 |
commit | 53fa8eaa093ad87eb59379de059e76d735a5de45 (patch) | |
tree | b06384fd7d6774a4156f78b105aae20c7c44496b /tools | |
parent | ca40e2af1f75eddf7eb2b93fde6391ea185d8fc8 (diff) |
perf tools: Add data_fd into dso object
Adding data_fd into dso object so we could handle caching
of opened dso file data descriptors coming int next patches.
Adding dso__data_close interface to keep the data_fd updated
when the descriptor is closed.
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1401892622-30848-4-git-send-email-jolsa@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/dso.c | 23 | ||||
-rw-r--r-- | tools/perf/util/dso.h | 3 | ||||
-rw-r--r-- | tools/perf/util/unwind-libunwind.c | 4 |
3 files changed, 24 insertions, 6 deletions
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 1c3cdaf228c1..5acb4b8b35d7 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
@@ -159,6 +159,14 @@ static int open_dso(struct dso *dso, struct machine *machine) | |||
159 | return fd; | 159 | return fd; |
160 | } | 160 | } |
161 | 161 | ||
162 | void dso__data_close(struct dso *dso) | ||
163 | { | ||
164 | if (dso->data.fd >= 0) { | ||
165 | close(dso->data.fd); | ||
166 | dso->data.fd = -1; | ||
167 | } | ||
168 | } | ||
169 | |||
162 | int dso__data_fd(struct dso *dso, struct machine *machine) | 170 | int dso__data_fd(struct dso *dso, struct machine *machine) |
163 | { | 171 | { |
164 | enum dso_binary_type binary_type_data[] = { | 172 | enum dso_binary_type binary_type_data[] = { |
@@ -168,8 +176,13 @@ int dso__data_fd(struct dso *dso, struct machine *machine) | |||
168 | }; | 176 | }; |
169 | int i = 0; | 177 | int i = 0; |
170 | 178 | ||
171 | if (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND) | 179 | if (dso->data.fd >= 0) |
172 | return open_dso(dso, machine); | 180 | return dso->data.fd; |
181 | |||
182 | if (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND) { | ||
183 | dso->data.fd = open_dso(dso, machine); | ||
184 | return dso->data.fd; | ||
185 | } | ||
173 | 186 | ||
174 | do { | 187 | do { |
175 | int fd; | 188 | int fd; |
@@ -178,7 +191,7 @@ int dso__data_fd(struct dso *dso, struct machine *machine) | |||
178 | 191 | ||
179 | fd = open_dso(dso, machine); | 192 | fd = open_dso(dso, machine); |
180 | if (fd >= 0) | 193 | if (fd >= 0) |
181 | return fd; | 194 | return dso->data.fd = fd; |
182 | 195 | ||
183 | } while (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND); | 196 | } while (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND); |
184 | 197 | ||
@@ -301,7 +314,7 @@ dso_cache__read(struct dso *dso, struct machine *machine, | |||
301 | if (ret <= 0) | 314 | if (ret <= 0) |
302 | free(cache); | 315 | free(cache); |
303 | 316 | ||
304 | close(fd); | 317 | dso__data_close(dso); |
305 | return ret; | 318 | return ret; |
306 | } | 319 | } |
307 | 320 | ||
@@ -474,6 +487,7 @@ struct dso *dso__new(const char *name) | |||
474 | for (i = 0; i < MAP__NR_TYPES; ++i) | 487 | for (i = 0; i < MAP__NR_TYPES; ++i) |
475 | dso->symbols[i] = dso->symbol_names[i] = RB_ROOT; | 488 | dso->symbols[i] = dso->symbol_names[i] = RB_ROOT; |
476 | dso->data.cache = RB_ROOT; | 489 | dso->data.cache = RB_ROOT; |
490 | dso->data.fd = -1; | ||
477 | dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND; | 491 | dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND; |
478 | dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND; | 492 | dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND; |
479 | dso->loaded = 0; | 493 | dso->loaded = 0; |
@@ -506,6 +520,7 @@ void dso__delete(struct dso *dso) | |||
506 | dso->long_name_allocated = false; | 520 | dso->long_name_allocated = false; |
507 | } | 521 | } |
508 | 522 | ||
523 | dso__data_close(dso); | ||
509 | dso_cache__free(&dso->data.cache); | 524 | dso_cache__free(&dso->data.cache); |
510 | dso__free_a2l(dso); | 525 | dso__free_a2l(dso); |
511 | zfree(&dso->symsrc_filename); | 526 | zfree(&dso->symsrc_filename); |
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 7637fdd680b2..e48dcf59b570 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h | |||
@@ -102,6 +102,7 @@ struct dso { | |||
102 | /* dso data file */ | 102 | /* dso data file */ |
103 | struct { | 103 | struct { |
104 | struct rb_root cache; | 104 | struct rb_root cache; |
105 | int fd; | ||
105 | } data; | 106 | } data; |
106 | 107 | ||
107 | char name[0]; | 108 | char name[0]; |
@@ -147,6 +148,8 @@ int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type t | |||
147 | char *root_dir, char *filename, size_t size); | 148 | char *root_dir, char *filename, size_t size); |
148 | 149 | ||
149 | int dso__data_fd(struct dso *dso, struct machine *machine); | 150 | int dso__data_fd(struct dso *dso, struct machine *machine); |
151 | void dso__data_close(struct dso *dso); | ||
152 | |||
150 | ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine, | 153 | ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine, |
151 | u64 offset, u8 *data, ssize_t size); | 154 | u64 offset, u8 *data, ssize_t size); |
152 | ssize_t dso__data_read_addr(struct dso *dso, struct map *map, | 155 | ssize_t dso__data_read_addr(struct dso *dso, struct map *map, |
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c index bd5768d74f01..4f8dd9ee3899 100644 --- a/tools/perf/util/unwind-libunwind.c +++ b/tools/perf/util/unwind-libunwind.c | |||
@@ -250,7 +250,7 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine, | |||
250 | 250 | ||
251 | /* Check the .eh_frame section for unwinding info */ | 251 | /* Check the .eh_frame section for unwinding info */ |
252 | offset = elf_section_offset(fd, ".eh_frame_hdr"); | 252 | offset = elf_section_offset(fd, ".eh_frame_hdr"); |
253 | close(fd); | 253 | dso__data_close(dso); |
254 | 254 | ||
255 | if (offset) | 255 | if (offset) |
256 | ret = unwind_spec_ehframe(dso, machine, offset, | 256 | ret = unwind_spec_ehframe(dso, machine, offset, |
@@ -271,7 +271,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso, | |||
271 | 271 | ||
272 | /* Check the .debug_frame section for unwinding info */ | 272 | /* Check the .debug_frame section for unwinding info */ |
273 | *offset = elf_section_offset(fd, ".debug_frame"); | 273 | *offset = elf_section_offset(fd, ".debug_frame"); |
274 | close(fd); | 274 | dso__data_close(dso); |
275 | 275 | ||
276 | if (*offset) | 276 | if (*offset) |
277 | return 0; | 277 | return 0; |