[PATCH 41/49] perf record: Move samples into struct record_thread

Jiri Olsa
2018-01-09T15:40:42Z

Moving samples value into struct record_thread, because
we need to have this value per thread for checking
if there have been new data.

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

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 5fd0a955a52d..96f43fb5ba6f 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -71,6 +71,7 @@ struct record_thread {
int ovw_mmap_nr;
struct fdarray pollfd;
struct record *rec;
+ unsigned long long samples;
};

struct record {
@@ -159,7 +160,7 @@ static int record__pushfn(struct perf_mmap *map, void *to, void *bf, size_t size
{
struct record *rec = to;

- rec->samples++;
+ thread->samples++;
return record__write(rec, map, bf, size);
}

@@ -243,7 +244,7 @@ static int record__auxtrace_mmap_read(struct record *rec,
return ret;

if (ret)
- rec->samples++;
+ thread->samples++;

return 0;
}
@@ -260,7 +261,7 @@ static int record__auxtrace_mmap_read_snapshot(struct record *rec,
return ret;

if (ret)
- rec->samples++;
+ thread->samples++;

return 0;
}
@@ -1314,7 +1315,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
trigger_ready(&switch_output_trigger);
perf_hooks__invoke_record_start();
for (;;) {
- unsigned long long hits = rec->samples;
+ unsigned long long hits = thread->samples;

/*
* rec->evlist->bkw_mmap_state is possible to be
@@ -1383,7 +1384,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
alarm(rec->switch_output.time);
}

- if (hits == rec->samples) {
+ if (hits == thread->samples) {
if (done || draining)
break;
err = fdarray__poll(&thread->pollfd, -1);
--
2.13.6