[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180109153522.14116-40-jolsa@kernel.org>
Date: Tue, 9 Jan 2018 16:35:12 +0100
From: Jiri Olsa <jolsa@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
David Ahern <dsahern@...il.com>,
Andi Kleen <ak@...ux.intel.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: [PATCH 39/49] perf record: Read record thread's mmaps
Switch the maps source from evlist into thread data.
Link: http://lkml.kernel.org/n/tip-2r6hn6shl185j66b4vl1k4pr@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/perf/builtin-record.c | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 2c8500163d24..4d08f81a3bfe 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -96,6 +96,8 @@ struct record {
int threads_cnt;
};
+static __thread struct record_thread *thread;
+
static volatile int auxtrace_record__snapshot_started;
static DEFINE_TRIGGER(auxtrace_snapshot_trigger);
static DEFINE_TRIGGER(switch_output_trigger);
@@ -538,24 +540,24 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli
bool overwrite)
{
u64 bytes_written = rec->bytes_written;
- int i;
+ int i, nr;
int rc = 0;
- struct perf_mmap *maps;
+ struct perf_mmap **maps;
if (!evlist)
return 0;
- maps = overwrite ? evlist->overwrite_mmap : evlist->mmap;
+ maps = overwrite ? thread->ovw_mmap : thread->mmap;
if (!maps)
return 0;
if (overwrite && evlist->bkw_mmap_state != BKW_MMAP_DATA_PENDING)
return 0;
- for (i = 0; i < evlist->nr_mmaps; i++) {
- struct perf_mmap *map = &maps[i];
- struct perf_mmap *track_map = evlist->track_mmap ?
- &evlist->track_mmap[i] : NULL;
+ nr = overwrite ? thread->ovw_mmap_nr : thread->mmap_nr;
+
+ for (i = 0; i < nr; i++) {
+ struct perf_mmap *map = maps[i];
if (map->base) {
if (perf_mmap__push(map, overwrite, rec, record__pushfn) != 0) {
@@ -569,21 +571,20 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli
rc = -1;
goto out;
}
-
- if (track_map && track_map->base) {
- if (perf_mmap__push(track_map, overwrite, rec, record__pushfn) != 0) {
- rc = -1;
- goto out;
- }
- }
}
/*
* Mark the round finished in case we wrote
* at least one event.
*/
- if (bytes_written != rec->bytes_written)
- rc = record__write(rec, NULL, &finished_round_event, sizeof(finished_round_event));
+ if (bytes_written != rec->bytes_written) {
+ /*
+ * All maps of the threads point to a single file,
+ * so we can just pick first one.
+ */
+ rc = record__write(rec, thread->mmap[0], &finished_round_event,
+ sizeof(finished_round_event));
+ }
if (overwrite)
perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_EMPTY);
@@ -1189,6 +1190,8 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
goto out_child;
}
+ thread = &rec->threads[0];
+
err = bpf__apply_obj_config();
if (err) {
char errbuf[BUFSIZ];
@@ -1383,7 +1386,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
if (hits == rec->samples) {
if (done || draining)
break;
- err = perf_evlist__poll(rec->evlist, -1);
+ err = fdarray__poll(&thread->pollfd, -1);
/*
* Propagate error, only if there's any. Ignore positive
* number of returned events and interrupt error.
--
2.13.6
Powered by blists - more mailing lists