Adding 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.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/util/evlist.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 71fdc6c92920..a59303de3421 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -726,6 +726,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)
{
@@ -924,6 +947,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)
--
2.21.0
The following commit has been merged into the perf/core branch of tip:
Commit-ID: bb1b1885e2f22afb8bc7981cd865fe4b0e3d975b
Gitweb: https://git.kernel.org/tip/bb1b1885e2f22afb8bc7981cd865fe4b0e3d975b
Author: Jiri Olsa <[email protected]>
AuthorDate: Mon, 07 Oct 2019 14:53:27 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Thu, 10 Oct 2019 12:30:21 -03:00
perf evlist: Introduce perf_evlist__mmap_cb_get()
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 <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/evlist.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 11716f2..f50ee5c 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -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)