[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190913132355.21634-41-jolsa@kernel.org>
Date: Fri, 13 Sep 2019 15:23:22 +0200
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>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Michael Petlan <mpetlan@...hat.com>
Subject: [PATCH 40/73] libperf: Add struct perf_mmap_param
Adding libperf's version of mmap params 'struct perf_mmap_param'
object with the basics: prot and mask. It's encapsulated in current
struct mmap_params object.
Link: http://lkml.kernel.org/n/tip-jl518fuinj826rsmve5qhrff@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/perf/lib/include/internal/mmap.h | 5 +++++
tools/perf/util/evlist.c | 14 +++++++++-----
tools/perf/util/mmap.c | 4 ++--
tools/perf/util/mmap.h | 3 ++-
4 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/tools/perf/lib/include/internal/mmap.h b/tools/perf/lib/include/internal/mmap.h
index e95fc51e5bd0..8e06eb840c47 100644
--- a/tools/perf/lib/include/internal/mmap.h
+++ b/tools/perf/lib/include/internal/mmap.h
@@ -29,6 +29,11 @@ struct perf_mmap {
char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);
};
+struct perf_mmap_param {
+ int prot;
+ int mask;
+};
+
void perf_mmap__init(struct perf_mmap *map, bool overwrite);
#endif /* __LIBPERF_INTERNAL_MMAP_H */
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 0d1ae00d22f3..c0c0882dc343 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -642,7 +642,7 @@ static int evlist__mmap_per_evsel(struct evlist *evlist, int idx,
int fd;
int cpu;
- mp->prot = PROT_READ | PROT_WRITE;
+ mp->core.prot = PROT_READ | PROT_WRITE;
if (evsel->core.attr.write_backward) {
output = _output_overwrite;
maps = evlist->overwrite_mmap;
@@ -655,7 +655,7 @@ static int evlist__mmap_per_evsel(struct evlist *evlist, int idx,
if (evlist->bkw_mmap_state == BKW_MMAP_NOTREADY)
perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_RUNNING);
}
- mp->prot &= ~PROT_WRITE;
+ mp->core.prot &= ~PROT_WRITE;
}
if (evsel->core.system_wide && thread)
@@ -896,8 +896,12 @@ int evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
* Its value is decided by evsel's write_backward.
* So &mp should not be passed through const pointer.
*/
- struct mmap_params mp = { .nr_cblocks = nr_cblocks, .affinity = affinity, .flush = flush,
- .comp_level = comp_level };
+ struct mmap_params mp = {
+ .nr_cblocks = nr_cblocks,
+ .affinity = affinity,
+ .flush = flush,
+ .comp_level = comp_level
+ };
if (!evlist->mmap)
evlist->mmap = evlist__alloc_mmap(evlist, false);
@@ -909,7 +913,7 @@ int evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
evlist->core.mmap_len = evlist__mmap_size(pages);
pr_debug("mmap size %zuB\n", evlist->core.mmap_len);
- mp.mask = evlist->core.mmap_len - page_size - 1;
+ mp.core.mask = evlist->core.mmap_len - page_size - 1;
auxtrace_mmap_params__init(&mp.auxtrace_mp, evlist->core.mmap_len,
auxtrace_pages, auxtrace_overwrite);
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index 4cc3b54b2f73..2f34a93a72f4 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -369,8 +369,8 @@ int perf_mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu)
*/
refcount_set(&map->core.refcnt, 2);
map->core.prev = 0;
- map->core.mask = mp->mask;
- map->core.base = mmap(NULL, perf_mmap__mmap_len(map), mp->prot,
+ map->core.mask = mp->core.mask;
+ map->core.base = mmap(NULL, perf_mmap__mmap_len(map), mp->core.prot,
MAP_SHARED, fd, 0);
if (map->core.base == MAP_FAILED) {
pr_debug2("failed to mmap perf event ring buffer, error %d\n",
diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h
index e335c341d073..965acb46df81 100644
--- a/tools/perf/util/mmap.h
+++ b/tools/perf/util/mmap.h
@@ -65,7 +65,8 @@ enum bkw_mmap_state {
};
struct mmap_params {
- int prot, mask, nr_cblocks, affinity, flush, comp_level;
+ struct perf_mmap_param core;
+ int nr_cblocks, affinity, flush, comp_level;
struct auxtrace_mmap_params auxtrace_mp;
};
--
2.21.0
Powered by blists - more mailing lists