Skip to content

Commit ee023de

Browse files
kliang2acmel
authored andcommitted
perf mmap: Introduce perf_mmap__read_done()
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]>
1 parent b4b036b commit ee023de

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

tools/perf/util/mmap.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,14 @@ int perf_mmap__push(struct perf_mmap *md, bool overwrite,
338338
out:
339339
return rc;
340340
}
341+
342+
/*
343+
* Mandatory for overwrite mode
344+
* The direction of overwrite mode is backward.
345+
* The last perf_mmap__read() will set tail to map->prev.
346+
* Need to correct the map->prev to head which is the end of next read.
347+
*/
348+
void perf_mmap__read_done(struct perf_mmap *map)
349+
{
350+
map->prev = perf_mmap__read_head(map);
351+
}

tools/perf/util/mmap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,5 @@ size_t perf_mmap__mmap_len(struct perf_mmap *map);
9696

9797
int perf_mmap__read_init(struct perf_mmap *md, bool overwrite,
9898
u64 *startp, u64 *endp);
99+
void perf_mmap__read_done(struct perf_mmap *map);
99100
#endif /*__PERF_MMAP_H */

0 commit comments

Comments
 (0)