aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/lib/mmap.c
diff options
context:
space:
mode:
authorJiri Olsa2019-10-07 14:53:19 +0200
committerArnaldo Carvalho de Melo2019-10-10 11:45:32 -0300
commit32fdc2ca7e2ae8ae5d0ff660ca7783acd8ee6396 (patch)
tree9924e96fd7075e5697de48eb3a9984b173389e3a /tools/perf/lib/mmap.c
parent7c4d41824f9afc659ba425a41018546531cffd72 (diff)
libperf: Adopt perf_mmap__read_done() from tools/perf
Move perf_mmap__read_init() from tools/perf to libperf and export it in the perf/mmap.h header. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/20191007125344.14268-12-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/lib/mmap.c')
-rw-r--r--tools/perf/lib/mmap.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/perf/lib/mmap.c b/tools/perf/lib/mmap.c
index fdbc6c550dea..97297cba44e3 100644
--- a/tools/perf/lib/mmap.c
+++ b/tools/perf/lib/mmap.c
@@ -175,3 +175,20 @@ int perf_mmap__read_init(struct perf_mmap *map)
return __perf_mmap__read_init(map);
}
+
+/*
+ * Mandatory for overwrite mode
+ * The direction of overwrite mode is backward.
+ * The last perf_mmap__read() will set tail to map->core.prev.
+ * Need to correct the map->core.prev to head which is the end of next read.
+ */
+void perf_mmap__read_done(struct perf_mmap *map)
+{
+ /*
+ * Check if event was unmapped due to a POLLHUP/POLLERR.
+ */
+ if (!refcount_read(&map->refcnt))
+ return;
+
+ map->prev = perf_mmap__read_head(map);
+}