Commit-ID: 6d363459d7e6e05f0afeb8e36e6de262a4964694 Gitweb: http://git.kernel.org/tip/6d363459d7e6e05f0afeb8e36e6de262a4964694 Author: Adrian Hunter <adrian.hunter@xxxxxxxxx> AuthorDate: Tue, 22 Jul 2014 16:17:35 +0300 Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> CommitDate: Wed, 23 Jul 2014 11:57:27 -0300 perf tools: Add dso__data_size() 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@xxxxxxxxx> Cc: David Ahern <dsahern@xxxxxxxxx> Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx> Cc: Jiri Olsa <jolsa@xxxxxxxxxx> Cc: Namhyung Kim <namhyung@xxxxxxxxx> Cc: Paul Mackerras <paulus@xxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: Stephane Eranian <eranian@xxxxxxxxxx> Link: http://lkml.kernel.org/r/1406035081-14301-27-git-send-email-adrian.hunter@xxxxxxxxx Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> --- tools/perf/util/dso.c | 22 ++++++++++++++++++++++ tools/perf/util/dso.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 84e4a05..e657d86 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -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) { diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index c805f60..af1c256 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -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 * @@ -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, -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html