diff options
author | Steven Rostedt (Google) <rostedt@goodmis.org> | 2024-01-09 21:51:46 -0500 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2024-01-09 22:07:15 -0500 |
commit | 2b5bb095dfecb4c7e1623c11892a68c0577f97a2 (patch) | |
tree | 2483acd633bfea4d72504e19205a93cb65c53422 | |
parent | dee0448b2e75eababc19e8bc6d6abd8f274a2df2 (diff) | |
download | libtracefs-2b5bb095dfecb4c7e1623c11892a68c0577f97a2.tar.gz |
libtracefs: Have tracefs_mmap_read() include subbuf meta data
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.
Link: https://lore.kernel.org/linux-trace-devel/20240110030116.81837-3-rostedt@goodmis.org
Cc: Vincent Donnefort <vdonnefort@google.com>
Fixes: 2ed14b59 ("libtracefs: Add ring buffer memory mapping APIs")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r-- | src/tracefs-mmap.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/tracefs-mmap.c b/src/tracefs-mmap.c index 0f90f51..f481bda 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); } |