summaryrefslogtreecommitdiffstats
path: root/tools/perf/lib/include
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2019-10-17 12:59:09 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-10-19 15:35:01 -0300
commit6eb65f7a5cc553f5dffb5cea3a874f1087524d99 (patch)
tree0a51ce3888aae612aeba90891f78c261fc0c361c /tools/perf/lib/include
parent6a5f3d94cb69a185b921cb92c39888dc31009acb (diff)
downloadlinux-6eb65f7a5cc553f5dffb5cea3a874f1087524d99.tar.gz
linux-6eb65f7a5cc553f5dffb5cea3a874f1087524d99.tar.bz2
linux-6eb65f7a5cc553f5dffb5cea3a874f1087524d99.zip
libperf: Introduce perf_evlist__for_each_mmap()
Add the perf_evlist__for_each_mmap() function and export it in the perf/evlist.h header, so that the user can iterate through 'struct perf_mmap' objects. Add a internal perf_mmap__link() function to do the actual linking. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexey Budankov <alexey.budankov@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jin Yao <yao.jin@linux.intel.com> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lore.kernel.org/lkml/20191017105918.20873-2-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/lib/include')
-rw-r--r--tools/perf/lib/include/internal/evlist.h2
-rw-r--r--tools/perf/lib/include/internal/mmap.h5
-rw-r--r--tools/perf/lib/include/perf/evlist.h9
3 files changed, 14 insertions, 2 deletions
diff --git a/tools/perf/lib/include/internal/evlist.h b/tools/perf/lib/include/internal/evlist.h
index be0b25a70730..20d90e29fc0e 100644
--- a/tools/perf/lib/include/internal/evlist.h
+++ b/tools/perf/lib/include/internal/evlist.h
@@ -25,6 +25,8 @@ struct perf_evlist {
struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
struct perf_mmap *mmap;
struct perf_mmap *mmap_ovw;
+ struct perf_mmap *mmap_first;
+ struct perf_mmap *mmap_ovw_first;
};
typedef void
diff --git a/tools/perf/lib/include/internal/mmap.h b/tools/perf/lib/include/internal/mmap.h
index ee536c4441bb..be7556e0a2b2 100644
--- a/tools/perf/lib/include/internal/mmap.h
+++ b/tools/perf/lib/include/internal/mmap.h
@@ -32,6 +32,7 @@ struct perf_mmap {
u64 flush;
libperf_unmap_cb_t unmap_cb;
char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);
+ struct perf_mmap *next;
};
struct perf_mmap_param {
@@ -41,8 +42,8 @@ struct perf_mmap_param {
size_t perf_mmap__mmap_len(struct perf_mmap *map);
-void perf_mmap__init(struct perf_mmap *map, bool overwrite,
- libperf_unmap_cb_t unmap_cb);
+void perf_mmap__init(struct perf_mmap *map, struct perf_mmap *prev,
+ bool overwrite, libperf_unmap_cb_t unmap_cb);
int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp,
int fd, int cpu);
void perf_mmap__munmap(struct perf_mmap *map);
diff --git a/tools/perf/lib/include/perf/evlist.h b/tools/perf/lib/include/perf/evlist.h
index 16f526e74d13..8c4b3c28535e 100644
--- a/tools/perf/lib/include/perf/evlist.h
+++ b/tools/perf/lib/include/perf/evlist.h
@@ -3,6 +3,7 @@
#define __LIBPERF_EVLIST_H
#include <perf/core.h>
+#include <stdbool.h>
struct perf_evlist;
struct perf_evsel;
@@ -38,4 +39,12 @@ LIBPERF_API int perf_evlist__filter_pollfd(struct perf_evlist *evlist,
LIBPERF_API int perf_evlist__mmap(struct perf_evlist *evlist, int pages);
LIBPERF_API void perf_evlist__munmap(struct perf_evlist *evlist);
+LIBPERF_API struct perf_mmap *perf_evlist__next_mmap(struct perf_evlist *evlist,
+ struct perf_mmap *map,
+ bool overwrite);
+#define perf_evlist__for_each_mmap(evlist, pos, overwrite) \
+ for ((pos) = perf_evlist__next_mmap((evlist), NULL, overwrite); \
+ (pos) != NULL; \
+ (pos) = perf_evlist__next_mmap((evlist), (pos), overwrite))
+
#endif /* __LIBPERF_EVLIST_H */