Skip to content

Commit fa8f4a8

Browse files
committed
ring-buffer: Allow splice to read previous partially read pages
If a page is partially read, and then the splice system call is run against the ring buffer, it will always fail to read, no matter how much is in the ring buffer. That's because the code path for a partial read of the page does will fail if the "full" flag is set. The splice system call wants full pages, so if the read of the ring buffer is not yet full, it should return zero, and the splice will block. But if a previous read was done, where the beginning has been consumed, it should still be given to the splice caller if the rest of the page has been written to. This caused the splice command to never consume data in this scenario, and let the ring buffer just fill up and lose events. Link: https://lkml.kernel.org/r/[email protected] Cc: [email protected] Fixes: 8789a9e ("ring-buffer: read page interface") Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 9d2ce78 commit fa8f4a8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

kernel/trace/ring_buffer.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5616,7 +5616,15 @@ int ring_buffer_read_page(struct trace_buffer *buffer,
56165616
unsigned int pos = 0;
56175617
unsigned int size;
56185618

5619-
if (full)
5619+
/*
5620+
* If a full page is expected, this can still be returned
5621+
* if there's been a previous partial read and the
5622+
* rest of the page can be read and the commit page is off
5623+
* the reader page.
5624+
*/
5625+
if (full &&
5626+
(!read || (len < (commit - read)) ||
5627+
cpu_buffer->reader_page == cpu_buffer->commit_page))
56205628
goto out_unlock;
56215629

56225630
if (len > (commit - read))

0 commit comments

Comments
 (0)