Skip to contentSkip to conversation

ring-buffer: Fix ring_buffer_read_page() copying only one event per page

PATCH New David Carlier 1 participant 1 message Jun 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ring-buffer: Fix ring_buffer_read_page() copying only one event per page

Commit 8928e4a3be34 ("ring-buffer: Show persistent buffer dropped events in trace_pipe file") split the "commit" variable in ring_buffer_read_page() into "commit" (raw) and "size" (masked page size), but the inner copy loop's terminator was changed to compare rpos against "event_size" instead of "size".

rpos is the cumulative read offset within the page; event_size is the length of the single event just copied. The loop thus breaks after the first event, so only one event is copied per call. This regresses the per-event memcpy path (partial reads, the active commit page, and mapped/remote buffers) used by splice/trace_pipe_raw and mmap consumers into a one-event-at-a-time read.

Compare rpos against the page size as the original code did.

Fixes 8928e4a3be34 ("ring-buffer: Show persistent buffer dropped events in trace_pipe file")
---
 kernel/trace/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ring_buffer.c +1 -1
index 06fb365bb86e..06155ab3366f 100644
@@ -7181,7 +7181,7 @@ int ring_buffer_read_page(struct trace_buffer *buffer,
 			rpos = reader->read;
 			pos += event_size;
 
-			if (rpos >= event_size)
+			if (rpos >= size)
 				break;
 
 			event = rb_reader_event(cpu_buffer);
Signature · 1 line
2.53.0