Skip to content

Commit 6d36345

Browse files
ahunter6acmel
authored andcommitted
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 <[email protected]> Cc: David Ahern <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a6a69db commit 6d36345

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tools/perf/util/dso.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,28 @@ static int data_file_size(struct dso *dso)
544544
return 0;
545545
}
546546

547+
/**
548+
* dso__data_size - Return dso data size
549+
* @dso: dso object
550+
* @machine: machine object
551+
*
552+
* Return: dso data size
553+
*/
554+
off_t dso__data_size(struct dso *dso, struct machine *machine)
555+
{
556+
int fd;
557+
558+
fd = dso__data_fd(dso, machine);
559+
if (fd < 0)
560+
return fd;
561+
562+
if (data_file_size(dso))
563+
return -1;
564+
565+
/* For now just estimate dso data size is close to file size */
566+
return dso->data.file_size;
567+
}
568+
547569
static ssize_t data_read_offset(struct dso *dso, u64 offset,
548570
u8 *data, ssize_t size)
549571
{

tools/perf/util/dso.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type t
166166
* The dso__data_* external interface provides following functions:
167167
* dso__data_fd
168168
* dso__data_close
169+
* dso__data_size
169170
* dso__data_read_offset
170171
* dso__data_read_addr
171172
*
@@ -203,6 +204,7 @@ int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type t
203204
int dso__data_fd(struct dso *dso, struct machine *machine);
204205
void dso__data_close(struct dso *dso);
205206

207+
off_t dso__data_size(struct dso *dso, struct machine *machine);
206208
ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
207209
u64 offset, u8 *data, ssize_t size);
208210
ssize_t dso__data_read_addr(struct dso *dso, struct map *map,

0 commit comments

Comments
 (0)