perf mmap: Don't discard prev in backward mode
authorWang Nan <wangnan0@huawei.com>
Mon, 4 Dec 2017 16:51:06 +0000 (16:51 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 5 Dec 2017 18:59:37 +0000 (15:59 -0300)
commit7fb4b407a1242dbc85ea3ed1be065dca8f9a6f5b
tree456f8de768c54049f294f386ee79ab4f5cd9cc5b
parent71f566a34986f4a86a8c546c7a36f70f0132b8a9
perf mmap: Don't discard prev in backward mode

'perf record' can switch its output data file. The new output should
only store the data after switching. However, in overwrite backward
mode, the new output still can have data from before switching. That
also brings extra overhead.

At the end of mmap_read(), the position of the processed ring buffer is
saved in md->prev. Next mmap_read should be end in md->prev if it is not
overwriten. That avoids processing duplicate data.  However, md->prev is
discarded. So next the mmap_read() has to process whole valid ring
buffer, which probably includes old processed data.

Avoid calling backward_rb_find_range() when md->prev is still
available.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Kan Liang <kan.liang@intel.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mengting Zhang <zhangmengting@huawei.com>
Link: http://lkml.kernel.org/r/20171204165107.95327-3-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/mmap.c