]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
perf evlist: Introduce perf_evlist__mmap_cb_get()
authorJiri Olsa <jolsa@kernel.org>
Mon, 7 Oct 2019 12:53:27 +0000 (14:53 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 10 Oct 2019 15:30:21 +0000 (12:30 -0300)
Add the perf_evlist__mmap_cb_get() function to return 'struct perf_mmap'
object during perf_evlist__mmap_ops() call.

The array of 'struct mmap' is allocated via evlist__alloc_mmap(), in
this callback we simply returns pointer to the base object.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20191007125344.14268-20-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c

index 11716f2b965aefe12d8e75304559bd19e4a4bb26..f50ee5cb6554389f7e6c93ffd5c4dbd95e19c40f 100644 (file)
@@ -750,6 +750,29 @@ perf_evlist__mmap_cb_idx(struct perf_evlist *_evlist,
        auxtrace_mmap_params__set_idx(&mp->auxtrace_mp, evlist, idx, per_cpu);
 }
 
+static struct perf_mmap*
+perf_evlist__mmap_cb_get(struct perf_evlist *_evlist, bool overwrite, int idx)
+{
+       struct evlist *evlist = container_of(_evlist, struct evlist, core);
+       struct mmap *maps = evlist->mmap;
+
+       if (overwrite) {
+               maps = evlist->overwrite_mmap;
+
+               if (!maps) {
+                       maps = evlist__alloc_mmap(evlist, true);
+                       if (!maps)
+                               return NULL;
+
+                       evlist->overwrite_mmap = maps;
+                       if (evlist->bkw_mmap_state == BKW_MMAP_NOTREADY)
+                               perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_RUNNING);
+               }
+       }
+
+       return &maps[idx].core;
+}
+
 static int evlist__mmap_per_cpu(struct evlist *evlist,
                                     struct mmap_params *mp)
 {
@@ -948,6 +971,7 @@ int evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
        };
        struct perf_evlist_mmap_ops ops __maybe_unused = {
                .idx = perf_evlist__mmap_cb_idx,
+               .get = perf_evlist__mmap_cb_get,
        };
 
        if (!evlist->mmap)