Skip to content

Commit

Permalink
perf data: Make perf_data__size() work over directory
Browse files Browse the repository at this point in the history
Make perf_data__size() return proper size for directory data, summing up
all the individual file sizes.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20190308134745.5057-5-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Mar 11, 2019
1 parent e8be135 commit 29583c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
17 changes: 17 additions & 0 deletions tools/perf/util/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,20 @@ int perf_data__switch(struct perf_data *data,
free(new_filepath);
return ret;
}

unsigned long perf_data__size(struct perf_data *data)
{
u64 size = data->file.size;
int i;

if (!data->is_dir)
return size;

for (i = 0; i < data->dir.nr; i++) {
struct perf_data_file *file = &data->dir.files[i];

size += file->size;
}

return size;
}
6 changes: 1 addition & 5 deletions tools/perf/util/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ static inline int perf_data__fd(struct perf_data *data)
return data->file.fd;
}

static inline unsigned long perf_data__size(struct perf_data *data)
{
return data->file.size;
}

int perf_data__open(struct perf_data *data);
void perf_data__close(struct perf_data *data);
ssize_t perf_data__write(struct perf_data *data,
Expand All @@ -80,4 +75,5 @@ int perf_data__create_dir(struct perf_data *data, int nr);
int perf_data__open_dir(struct perf_data *data);
void perf_data__close_dir(struct perf_data *data);
int perf_data__update_dir(struct perf_data *data);
unsigned long perf_data__size(struct perf_data *data);
#endif /* __PERF_DATA_H */

0 comments on commit 29583c1

Please sign in to comment.