Switch the maps source from evlist into thread data.

Link: http://lkml.kernel.org/n/tip-2r6hn6shl185j66b4vl1k...@git.kernel.org
Signed-off-by: Jiri Olsa <jo...@kernel.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 5c6b56f164a9..d6fef646b67f 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);
@@ -561,24 +563,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, rec, record__pushfn) != 0) {
@@ -592,21 +594,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, 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);
@@ -1222,6 +1223,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];
@@ -1415,7 +1418,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.17.1

Reply via email to