From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> The tracefs_cpu_read() returns tracefs_mmap_read() when the tcpu is mapped. But tracefs_cpu_read() is supposed to return the amount that was read, which includes the sub-buffer meta data. But kbuffer_read_buffer() only returns the amount of data that was read and does not include the sub-buffer meta data. Fixes: 2ed14b59 ("libtracefs: Add ring buffer memory mapping APIs") Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> --- src/tracefs-mmap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tracefs-mmap.c b/src/tracefs-mmap.c index 0f90f51e9339..f481bda37eaf 100644 --- a/src/tracefs-mmap.c +++ b/src/tracefs-mmap.c @@ -207,5 +207,10 @@ __hidden int trace_mmap_read(void *mapping, void *buffer) return ret; /* Update the buffer */ - return kbuffer_read_buffer(kbuf, buffer, tmap->map->subbuf_size); + ret = kbuffer_read_buffer(kbuf, buffer, tmap->map->subbuf_size); + if (ret <= 0) + return ret; + + /* This needs to include the size of the meta data too */ + return ret + kbuffer_start_of_data(kbuf); } -- 2.43.0