perf mmap: Introduce perf_mmap__read_done()
authorKan Liang <[email protected]>
Thu, 18 Jan 2018 21:26:22 +0000 (13:26 -0800)
committerArnaldo Carvalho de Melo <[email protected]>
Thu, 15 Feb 2018 12:53:15 +0000 (09:53 -0300)
The direction of overwrite mode is backward. The last perf_mmap__read()
will set tail to map->prev. Need to correct the map->prev to head which
is the end of next read.

It will be used later.

Signed-off-by: Kan Liang <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Wang Nan <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/mmap.c
tools/perf/util/mmap.h

index 125bfda9d03752e4a8724a68fe9cd10a504b893d..4f59eaefc706b038eb032fb0aba2581e6ca4f64b 100644 (file)
@@ -338,3 +338,14 @@ int perf_mmap__push(struct perf_mmap *md, bool overwrite,
 out:
        return rc;
 }
+
+/*
+ * Mandatory for overwrite mode
+ * The direction of overwrite mode is backward.
+ * The last perf_mmap__read() will set tail to map->prev.
+ * Need to correct the map->prev to head which is the end of next read.
+ */
+void perf_mmap__read_done(struct perf_mmap *map)
+{
+       map->prev = perf_mmap__read_head(map);
+}
index 9ab2b48df65bed7d416d8ef6d83a163626d90cdd..95549d4af9430092cbd15358a481e9fcb31eda51 100644 (file)
@@ -96,4 +96,5 @@ size_t perf_mmap__mmap_len(struct perf_mmap *map);
 
 int perf_mmap__read_init(struct perf_mmap *md, bool overwrite,
                         u64 *startp, u64 *endp);
+void perf_mmap__read_done(struct perf_mmap *map);
 #endif /*__PERF_MMAP_H */