[PATCH 42/49] perf record: Move bytes_written into struct record_thread

From: Jiri Olsa
Date: Tue Jan 09 2018 - 10:37:41 EST


Moving bytes_written into struct record_thread.

Link: http://lkml.kernel.org/n/tip-q1xlsqksw6i8my0wbunv066d@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/builtin-record.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 96f43fb5ba6f..fb15d4457cfa 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -72,12 +72,12 @@ struct record_thread {
struct fdarray pollfd;
struct record *rec;
unsigned long long samples;
+ u64 bytes_written;
};

struct record {
struct perf_tool tool;
struct record_opts opts;
- u64 bytes_written;
struct perf_data data;
struct auxtrace_record *itr;
struct perf_evlist *evlist;
@@ -114,7 +114,7 @@ static bool switch_output_size(struct record *rec)
{
return rec->switch_output.size &&
trigger_is_ready(&switch_output_trigger) &&
- (rec->bytes_written >= rec->switch_output.size);
+ (thread->bytes_written >= rec->switch_output.size);
}

static bool switch_output_time(struct record *rec)
@@ -138,7 +138,7 @@ static int record__write(struct record *rec, struct perf_mmap *map,
return -1;
}

- rec->bytes_written += size;
+ thread->bytes_written += size;

if (switch_output_size(rec))
trigger_hit(&switch_output_trigger);
@@ -541,7 +541,7 @@ static struct perf_event_header finished_round_event = {
static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evlist,
bool overwrite)
{
- u64 bytes_written = rec->bytes_written;
+ u64 bytes_written = thread->bytes_written;
int i, nr;
int rc = 0;
struct perf_mmap **maps;
@@ -579,7 +579,7 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli
* Mark the round finished in case we wrote
* at least one event.
*/
- if (bytes_written != rec->bytes_written) {
+ if (bytes_written != thread->bytes_written) {
/*
* All maps of the threads point to a single file,
* so we can just pick first one.
@@ -678,6 +678,7 @@ static int record__merge_index(struct record *rec)
goto out_close;

pr_debug(" ok\n");
+ rec->session->header.data_size += idx[i].size;
}

session->header.index = idx;
@@ -704,7 +705,7 @@ record__finish_output(struct record *rec)
if (data->is_pipe)
return;

- rec->session->header.data_size += rec->bytes_written;
+ rec->session->header.data_size += thread->bytes_written;

if (rec->opts.index)
record__merge_index(rec);
@@ -770,7 +771,7 @@ record__switch_output(struct record *rec, bool at_exit)
rec->session->header.data_offset,
at_exit);
if (fd >= 0 && !at_exit) {
- rec->bytes_written = 0;
+ thread->bytes_written = 0;
rec->session->header.data_size = 0;
}

@@ -890,7 +891,6 @@ static int record__synthesize(struct record *rec, bool tail)
pr_err("Couldn't record tracing data.\n");
goto out;
}
- rec->bytes_written += err;
}
}

--
2.13.6