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>
This commit is contained in:
@@ -159,6 +159,14 @@ static int open_dso(struct dso *dso, struct machine *machine)
|
|||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dso__data_close(struct dso *dso)
|
||||||
|
{
|
||||||
|
if (dso->data.fd >= 0) {
|
||||||
|
close(dso->data.fd);
|
||||||
|
dso->data.fd = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int dso__data_fd(struct dso *dso, struct machine *machine)
|
int dso__data_fd(struct dso *dso, struct machine *machine)
|
||||||
{
|
{
|
||||||
enum dso_binary_type binary_type_data[] = {
|
enum dso_binary_type binary_type_data[] = {
|
||||||
@@ -168,8 +176,13 @@ int dso__data_fd(struct dso *dso, struct machine *machine)
|
|||||||
};
|
};
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND)
|
if (dso->data.fd >= 0)
|
||||||
return open_dso(dso, machine);
|
return dso->data.fd;
|
||||||
|
|
||||||
|
if (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND) {
|
||||||
|
dso->data.fd = open_dso(dso, machine);
|
||||||
|
return dso->data.fd;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int fd;
|
int fd;
|
||||||
@@ -178,7 +191,7 @@ int dso__data_fd(struct dso *dso, struct machine *machine)
|
|||||||
|
|
||||||
fd = open_dso(dso, machine);
|
fd = open_dso(dso, machine);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
return fd;
|
return dso->data.fd = fd;
|
||||||
|
|
||||||
} while (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND);
|
} while (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND);
|
||||||
|
|
||||||
@@ -301,7 +314,7 @@ dso_cache__read(struct dso *dso, struct machine *machine,
|
|||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
free(cache);
|
free(cache);
|
||||||
|
|
||||||
close(fd);
|
dso__data_close(dso);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,6 +487,7 @@ struct dso *dso__new(const char *name)
|
|||||||
for (i = 0; i < MAP__NR_TYPES; ++i)
|
for (i = 0; i < MAP__NR_TYPES; ++i)
|
||||||
dso->symbols[i] = dso->symbol_names[i] = RB_ROOT;
|
dso->symbols[i] = dso->symbol_names[i] = RB_ROOT;
|
||||||
dso->data.cache = RB_ROOT;
|
dso->data.cache = RB_ROOT;
|
||||||
|
dso->data.fd = -1;
|
||||||
dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND;
|
dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND;
|
||||||
dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND;
|
dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND;
|
||||||
dso->loaded = 0;
|
dso->loaded = 0;
|
||||||
@@ -506,6 +520,7 @@ void dso__delete(struct dso *dso)
|
|||||||
dso->long_name_allocated = false;
|
dso->long_name_allocated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dso__data_close(dso);
|
||||||
dso_cache__free(&dso->data.cache);
|
dso_cache__free(&dso->data.cache);
|
||||||
dso__free_a2l(dso);
|
dso__free_a2l(dso);
|
||||||
zfree(&dso->symsrc_filename);
|
zfree(&dso->symsrc_filename);
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ struct dso {
|
|||||||
/* dso data file */
|
/* dso data file */
|
||||||
struct {
|
struct {
|
||||||
struct rb_root cache;
|
struct rb_root cache;
|
||||||
|
int fd;
|
||||||
} data;
|
} data;
|
||||||
|
|
||||||
char name[0];
|
char name[0];
|
||||||
@@ -147,6 +148,8 @@ int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type t
|
|||||||
char *root_dir, char *filename, size_t size);
|
char *root_dir, char *filename, size_t size);
|
||||||
|
|
||||||
int dso__data_fd(struct dso *dso, struct machine *machine);
|
int dso__data_fd(struct dso *dso, struct machine *machine);
|
||||||
|
void dso__data_close(struct dso *dso);
|
||||||
|
|
||||||
ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
|
ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
|
||||||
u64 offset, u8 *data, ssize_t size);
|
u64 offset, u8 *data, ssize_t size);
|
||||||
ssize_t dso__data_read_addr(struct dso *dso, struct map *map,
|
ssize_t dso__data_read_addr(struct dso *dso, struct map *map,
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine,
|
|||||||
|
|
||||||
/* Check the .eh_frame section for unwinding info */
|
/* Check the .eh_frame section for unwinding info */
|
||||||
offset = elf_section_offset(fd, ".eh_frame_hdr");
|
offset = elf_section_offset(fd, ".eh_frame_hdr");
|
||||||
close(fd);
|
dso__data_close(dso);
|
||||||
|
|
||||||
if (offset)
|
if (offset)
|
||||||
ret = unwind_spec_ehframe(dso, machine, offset,
|
ret = unwind_spec_ehframe(dso, machine, offset,
|
||||||
@@ -271,7 +271,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
|
|||||||
|
|
||||||
/* Check the .debug_frame section for unwinding info */
|
/* Check the .debug_frame section for unwinding info */
|
||||||
*offset = elf_section_offset(fd, ".debug_frame");
|
*offset = elf_section_offset(fd, ".debug_frame");
|
||||||
close(fd);
|
dso__data_close(dso);
|
||||||
|
|
||||||
if (*offset)
|
if (*offset)
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user