aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/dso.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2014-07-22 16:17:35 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-07-23 11:57:27 -0300
commit6d363459d7e6e05f0afeb8e36e6de262a4964694 (patch)
tree01cdc30704115b5332bdd2b6f8f4f7a6ca3111f7 /tools/perf/util/dso.c
parentperf tools: Move rdtsc() function (diff)
downloadlinux-dev-6d363459d7e6e05f0afeb8e36e6de262a4964694.tar.xz
linux-dev-6d363459d7e6e05f0afeb8e36e6de262a4964694.zip
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@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>
Diffstat (limited to 'tools/perf/util/dso.c')
-rw-r--r--tools/perf/util/dso.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 84e4a0546a31..e657d86e82b9 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)
{