Skip to content

Commit

Permalink
perf dso: Separate generic code in dso__data_file_size()
Browse files Browse the repository at this point in the history
Moving file specific code in dso__data_file_size function into separate
file_size function. I'll add bpf specific code in following patches.

Signed-off-by: Jiri Olsa <[email protected]>
Acked-by: Song Liu <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stanislav Fomichev <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
olsajiri authored and acmel committed May 28, 2019
1 parent 7cb10a0 commit 5523769
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tools/perf/util/dso.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,18 +898,12 @@ static ssize_t cached_read(struct dso *dso, struct machine *machine,
return r;
}

int dso__data_file_size(struct dso *dso, struct machine *machine)
static int file_size(struct dso *dso, struct machine *machine)
{
int ret = 0;
struct stat st;
char sbuf[STRERR_BUFSIZE];

if (dso->data.file_size)
return 0;

if (dso->data.status == DSO_DATA_STATUS_ERROR)
return -1;

pthread_mutex_lock(&dso__data_open_lock);

/*
Expand Down Expand Up @@ -938,6 +932,17 @@ int dso__data_file_size(struct dso *dso, struct machine *machine)
return ret;
}

int dso__data_file_size(struct dso *dso, struct machine *machine)
{
if (dso->data.file_size)
return 0;

if (dso->data.status == DSO_DATA_STATUS_ERROR)
return -1;

return file_size(dso, machine);
}

/**
* dso__data_size - Return dso data size
* @dso: dso object
Expand Down

0 comments on commit 5523769

Please sign in to comment.