Skip to content

Commit

Permalink
perf tools: Add dso__data_size()
Browse files Browse the repository at this point in the history
Add a function to return the dso data size, for use in estimating the
size an instruction cache.

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-27-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Adrian Hunter authored and Arnaldo Carvalho de Melo committed Jul 23, 2014
1 parent a6a69db commit 6d36345
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tools/perf/util/dso.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,28 @@ static int data_file_size(struct dso *dso)
return 0;
}

/**
* dso__data_size - Return dso data size
* @dso: dso object
* @machine: machine object
*
* Return: dso data size
*/
off_t dso__data_size(struct dso *dso, struct machine *machine)
{
int fd;

fd = dso__data_fd(dso, machine);
if (fd < 0)
return fd;

if (data_file_size(dso))
return -1;

/* For now just estimate dso data size is close to file size */
return dso->data.file_size;
}

static ssize_t data_read_offset(struct dso *dso, u64 offset,
u8 *data, ssize_t size)
{
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/util/dso.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type t
* The dso__data_* external interface provides following functions:
* dso__data_fd
* dso__data_close
* dso__data_size
* dso__data_read_offset
* dso__data_read_addr
*
Expand Down Expand Up @@ -203,6 +204,7 @@ int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type t
int dso__data_fd(struct dso *dso, struct machine *machine);
void dso__data_close(struct dso *dso);

off_t dso__data_size(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);
ssize_t dso__data_read_addr(struct dso *dso, struct map *map,
Expand Down

0 comments on commit 6d36345

Please sign in to comment.