lkml.org 
[lkml]   [2018]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 41/48] perf record: Move bytes_written into struct record_thread
Date
Moving bytes_written into struct record_thread.

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

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index b17445f332a8..253bafd4dbe7 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -73,12 +73,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);
@@ -564,7 +564,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;
@@ -602,7 +602,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.
@@ -701,8 +701,12 @@ static int record__merge_index(struct record *rec)
goto out_close;

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

+ offset = lseek(output_fd, 0, SEEK_END);
+ rec->session->header.data_size = offset - session->header.data_offset;
+
session->header.index = idx;
session->header.nr_index = nr_index;

@@ -727,10 +731,11 @@ record__finish_output(struct record *rec)
if (data->is_pipe)
return;

- rec->session->header.data_size += rec->bytes_written;
-
if (rec->opts.index)
record__merge_index(rec);
+ else
+ rec->session->header.data_size += thread->bytes_written;
+

data->size = lseek(perf_data__fd(data), 0, SEEK_END);

@@ -793,7 +798,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;
}

@@ -917,7 +922,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.17.1
\
 
 \ /
  Last update: 2018-09-13 14:58    [W:0.291 / U:2.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site