From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> If the tracefs_cpu is opened with tracefs_cpu_open_mapped() and uses tracefs_cpu_read_buf() along with tracefs_cpu_flush_buf(), the flush will load the tcpu->kbuf with a new buffer which may make the one in the mmapped out of sync. If the tcpu is mapped, make sure tracefs_cpu_flush() and tracefs_cpu_flush_buf() also use the mapping. Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> --- src/tracefs-record.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tracefs-record.c b/src/tracefs-record.c index 4a59c61c195f..fca3ddf9afbe 100644 --- a/src/tracefs-record.c +++ b/src/tracefs-record.c @@ -690,6 +690,9 @@ int tracefs_cpu_flush(struct tracefs_cpu *tcpu, void *buffer) if (tcpu->buffered < 0) tcpu->buffered = 0; + if (tcpu->mapping) + return trace_mmap_read(tcpu->mapping, buffer); + if (tcpu->buffered) { ret = read(tcpu->splice_pipe[0], buffer, tcpu->subbuf_size); if (ret > 0) @@ -729,6 +732,13 @@ struct kbuffer *tracefs_cpu_flush_buf(struct tracefs_cpu *tcpu) if (!get_buffer(tcpu)) return NULL; + if (tcpu->mapping) { + /* Make sure that reading is now non blocking */ + set_nonblock(tcpu); + ret = trace_mmap_load_subbuf(tcpu->mapping, tcpu->kbuf); + return ret > 0 ? tcpu->kbuf : NULL; + } + ret = tracefs_cpu_flush(tcpu, tcpu->buffer); if (ret <= 0) return NULL; -- 2.43.0