mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
perf mmap: Use the head selected by read_init
perf_mmap__push() reads the producer head before calling
perf_mmap__read_init(), which reads it again to select the range to
copy.
If the producer advances between those reads, push() copies through the
newer head but stores the earlier head in prev. The next drain starts at
that earlier position and can write the same records to perf.data again.
Use the head selected by read_init(): end for forward buffers and start
for overwrite buffers. Save it before the copy loop advances start so
prev matches the range that was copied.
Fixes: 8872481bd0 ("perf mmap: Introduce perf_mmap__read_init()")
Signed-off-by: Paul Moses <p@1g4.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
98892841bd
commit
022c64992a
|
|
@ -330,7 +330,7 @@ int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, struct perf_cpu
|
|||
int perf_mmap__push(struct mmap *md, void *to,
|
||||
int push(struct mmap *map, void *to, void *buf, size_t size))
|
||||
{
|
||||
u64 head = perf_mmap__read_head(&md->core);
|
||||
u64 head;
|
||||
unsigned char *data = md->core.base + page_size;
|
||||
unsigned long size;
|
||||
void *buf;
|
||||
|
|
@ -340,6 +340,7 @@ int perf_mmap__push(struct mmap *md, void *to,
|
|||
if (rc < 0)
|
||||
return (rc == -EAGAIN) ? 1 : -1;
|
||||
|
||||
head = md->core.overwrite ? md->core.start : md->core.end;
|
||||
size = md->core.end - md->core.start;
|
||||
|
||||
if ((md->core.start & md->core.mask) + size != (md->core.end & md->core.mask)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user