To be able to pass specific callbacks to evlist's mmap. There will be
specific call to this function from perf's evlist__mmap() and libperf's
perf_evlist__mmap() functions in following changes.
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/lib/evlist.c | 24 ++++++++++++++++++------
tools/perf/lib/include/internal/evlist.h | 8 ++++++++
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c
index 250ad5752589..88d63f5cd9ca 100644
--- a/tools/perf/lib/evlist.c
+++ b/tools/perf/lib/evlist.c
@@ -472,12 +472,16 @@ mmap_per_cpu(struct perf_evlist *evlist, struct perf_mmap_param *mp)
return -1;
}
-int perf_evlist__mmap(struct perf_evlist *evlist, int pages)
+int perf_evlist__mmap_ops(struct perf_evlist *evlist,
+ struct perf_evlist_mmap_ops *ops,
+ struct perf_mmap_param *mp)
{
struct perf_evsel *evsel;
const struct perf_cpu_map *cpus = evlist->cpus;
const struct perf_thread_map *threads = evlist->threads;
- struct perf_mmap_param mp;
+
+ if (!ops)
+ return -EINVAL;
if (!evlist->mmap)
evlist->mmap = perf_evlist__alloc_mmap(evlist, false);
@@ -491,13 +495,21 @@ int perf_evlist__mmap(struct perf_evlist *evlist, int pages)
return -ENOMEM;
}
+ if (perf_cpu_map__empty(cpus))
+ return mmap_per_thread(evlist, mp);
+
+ return mmap_per_cpu(evlist, mp);
+}
+
+int perf_evlist__mmap(struct perf_evlist *evlist, int pages)
+{
+ struct perf_mmap_param mp;
+ struct perf_evlist_mmap_ops ops;
+
evlist->mmap_len = (pages + 1) * page_size;
mp.mask = evlist->mmap_len - page_size - 1;
- if (perf_cpu_map__empty(cpus))
- return mmap_per_thread(evlist, &mp);
-
- return mmap_per_cpu(evlist, &mp);
+ return perf_evlist__mmap_ops(evlist, &ops, &mp);
}
void perf_evlist__munmap(struct perf_evlist *evlist)
diff --git a/tools/perf/lib/include/internal/evlist.h b/tools/perf/lib/include/internal/evlist.h
index 4438a19ceba3..e5f092ff6202 100644
--- a/tools/perf/lib/include/internal/evlist.h
+++ b/tools/perf/lib/include/internal/evlist.h
@@ -11,6 +11,7 @@
struct perf_cpu_map;
struct perf_thread_map;
+struct perf_mmap_param;
struct perf_evlist {
struct list_head entries;
@@ -26,10 +27,17 @@ struct perf_evlist {
struct perf_mmap *mmap_ovw;
};
+struct perf_evlist_mmap_ops {
+};
+
int perf_evlist__alloc_pollfd(struct perf_evlist *evlist);
int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd,
void *ptr, short revent);
+int perf_evlist__mmap_ops(struct perf_evlist *evlist,
+ struct perf_evlist_mmap_ops *ops,
+ struct perf_mmap_param *mp);
+
/**
* __perf_evlist__for_each_entry - iterate thru all the evsels
* @list: list_head instance to iterate
--
2.21.0
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 0b5ea10d4c312f5b17af9d09187efb9418517bec
Gitweb: https://git.kernel.org/tip/0b5ea10d4c312f5b17af9d09187efb9418517bec
Author: Jiri Olsa <[email protected]>
AuthorDate: Mon, 07 Oct 2019 14:53:22 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Thu, 10 Oct 2019 12:18:00 -03:00
libperf: Introduce perf_evlist__mmap_ops()
To be able to pass specific callbacks to evlist's mmap.
There will be a specific call to this function from perf's
evlist__mmap() and libperf's perf_evlist__mmap() functions in following
changes.
Signed-off-by: Arnaldo Carvalho de Melo <[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: Jiri Olsa <[email protected]>
---
tools/perf/lib/evlist.c | 24 +++++++++++++++++------
tools/perf/lib/include/internal/evlist.h | 8 ++++++++-
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c
index 250ad57..88d63f5 100644
--- a/tools/perf/lib/evlist.c
+++ b/tools/perf/lib/evlist.c
@@ -472,12 +472,16 @@ out_unmap:
return -1;
}
-int perf_evlist__mmap(struct perf_evlist *evlist, int pages)
+int perf_evlist__mmap_ops(struct perf_evlist *evlist,
+ struct perf_evlist_mmap_ops *ops,
+ struct perf_mmap_param *mp)
{
struct perf_evsel *evsel;
const struct perf_cpu_map *cpus = evlist->cpus;
const struct perf_thread_map *threads = evlist->threads;
- struct perf_mmap_param mp;
+
+ if (!ops)
+ return -EINVAL;
if (!evlist->mmap)
evlist->mmap = perf_evlist__alloc_mmap(evlist, false);
@@ -491,13 +495,21 @@ int perf_evlist__mmap(struct perf_evlist *evlist, int pages)
return -ENOMEM;
}
+ if (perf_cpu_map__empty(cpus))
+ return mmap_per_thread(evlist, mp);
+
+ return mmap_per_cpu(evlist, mp);
+}
+
+int perf_evlist__mmap(struct perf_evlist *evlist, int pages)
+{
+ struct perf_mmap_param mp;
+ struct perf_evlist_mmap_ops ops;
+
evlist->mmap_len = (pages + 1) * page_size;
mp.mask = evlist->mmap_len - page_size - 1;
- if (perf_cpu_map__empty(cpus))
- return mmap_per_thread(evlist, &mp);
-
- return mmap_per_cpu(evlist, &mp);
+ return perf_evlist__mmap_ops(evlist, &ops, &mp);
}
void perf_evlist__munmap(struct perf_evlist *evlist)
diff --git a/tools/perf/lib/include/internal/evlist.h b/tools/perf/lib/include/internal/evlist.h
index 4438a19..e5f092f 100644
--- a/tools/perf/lib/include/internal/evlist.h
+++ b/tools/perf/lib/include/internal/evlist.h
@@ -11,6 +11,7 @@
struct perf_cpu_map;
struct perf_thread_map;
+struct perf_mmap_param;
struct perf_evlist {
struct list_head entries;
@@ -26,10 +27,17 @@ struct perf_evlist {
struct perf_mmap *mmap_ovw;
};
+struct perf_evlist_mmap_ops {
+};
+
int perf_evlist__alloc_pollfd(struct perf_evlist *evlist);
int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd,
void *ptr, short revent);
+int perf_evlist__mmap_ops(struct perf_evlist *evlist,
+ struct perf_evlist_mmap_ops *ops,
+ struct perf_mmap_param *mp);
+
/**
* __perf_evlist__for_each_entry - iterate thru all the evsels
* @list: list_head instance to iterate