[RFC/PATCH 04/38] perf tools: pass perf_mmap desc directly
From: Namhyung Kim
Date: Fri Oct 02 2015 - 01:23:30 EST
Pass struct perf_mmap to mmap handling functions directly. This will
be used by both of normal mmap and track mmap later.
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/util/evlist.c | 24 +++++++++++++++---------
tools/perf/util/evlist.h | 1 +
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 042dffc67986..8d31883cbeb8 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -921,8 +921,8 @@ struct mmap_params {
struct auxtrace_mmap_params auxtrace_mp;
};
-static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
- struct mmap_params *mp, int fd)
+static int perf_mmap__mmap(struct perf_mmap *desc,
+ struct mmap_params *mp, int fd)
{
/*
* The last one will be done at perf_evlist__mmap_consume(), so that we
@@ -937,21 +937,26 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
* evlist layer can't just drop it when filtering events in
* perf_evlist__filter_pollfd().
*/
- atomic_set(&evlist->mmap[idx].refcnt, 2);
- evlist->mmap[idx].prev = 0;
- evlist->mmap[idx].mask = perf_evlist__mmap_mask(mp->len);
- evlist->mmap[idx].base = mmap(NULL, mp->len, mp->prot,
+ atomic_set(&desc->refcnt, 2);
+ desc->prev = 0;
+ desc->mask = perf_evlist__mmap_mask(mp->len);
+ desc->base = mmap(NULL, mp->len, mp->prot,
MAP_SHARED, fd, 0);
- if (evlist->mmap[idx].base == MAP_FAILED) {
+ if (desc->base == MAP_FAILED) {
pr_debug2("failed to mmap perf event ring buffer, error %d\n",
errno);
- evlist->mmap[idx].base = NULL;
+ desc->base = NULL;
return -1;
}
return 0;
}
+struct perf_mmap *perf_evlist__mmap_desc(struct perf_evlist *evlist, int idx)
+{
+ return &evlist->mmap[idx];
+}
+
static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
struct mmap_params *mp, int cpu,
int thread, int *output)
@@ -960,6 +965,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
evlist__for_each(evlist, evsel) {
int fd;
+ struct perf_mmap *desc = perf_evlist__mmap_desc(evlist, idx);
if (evsel->system_wide && thread)
continue;
@@ -968,7 +974,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
if (*output == -1) {
*output = fd;
- if (__perf_evlist__mmap(evlist, idx, mp, *output) < 0)
+ if (perf_mmap__mmap(desc, mp, *output) < 0)
return -1;
if (auxtrace_mmap__mmap(&evlist->auxtrace_mmap[idx],
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 51574ce8ac69..79f8245300ad 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -145,6 +145,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
bool overwrite);
void perf_evlist__munmap(struct perf_evlist *evlist);
+struct perf_mmap *perf_evlist__mmap_desc(struct perf_evlist *evlist, int idx);
void perf_evlist__disable(struct perf_evlist *evlist);
void perf_evlist__enable(struct perf_evlist *evlist);
--
2.6.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/