Skip to content

Commit 45112e8

Browse files
olsajiriacmel
authored andcommitted
perf data: Move size to struct perf_data_file
We are about to add support for multiple files, so we need each file to keep its size. Signed-off-by: Jiri Olsa <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexey Budankov <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Namhyung Kim <[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 c60f83b commit 45112e8

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

tools/perf/builtin-record.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,9 @@ static int process_sample_event(struct perf_tool *tool,
660660

661661
static int process_buildids(struct record *rec)
662662
{
663-
struct perf_data *data = &rec->data;
664663
struct perf_session *session = rec->session;
665664

666-
if (data->size == 0)
665+
if (perf_data__size(&rec->data) == 0)
667666
return 0;
668667

669668
/*
@@ -851,7 +850,7 @@ record__finish_output(struct record *rec)
851850
return;
852851

853852
rec->session->header.data_size += rec->bytes_written;
854-
data->size = lseek(perf_data__fd(data), 0, SEEK_CUR);
853+
data->file.size = lseek(perf_data__fd(data), 0, SEEK_CUR);
855854

856855
if (!rec->no_buildid) {
857856
process_buildids(rec);

tools/perf/util/data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int open_file_read(struct perf_data *data)
8282
goto out_close;
8383
}
8484

85-
data->size = st.st_size;
85+
data->file.size = st.st_size;
8686
return fd;
8787

8888
out_close:

tools/perf/util/data.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ enum perf_data_mode {
1212
struct perf_data_file {
1313
const char *path;
1414
int fd;
15+
unsigned long size;
1516
};
1617

1718
struct perf_data {
1819
struct perf_data_file file;
1920
bool is_pipe;
2021
bool force;
21-
unsigned long size;
2222
enum perf_data_mode mode;
2323
};
2424

@@ -44,7 +44,7 @@ static inline int perf_data__fd(struct perf_data *data)
4444

4545
static inline unsigned long perf_data__size(struct perf_data *data)
4646
{
47-
return data->size;
47+
return data->file.size;
4848
}
4949

5050
int perf_data__open(struct perf_data *data);

0 commit comments

Comments
 (0)