Skip to content

Commit 4e8729e

Browse files
committed
ring-buffer: Better comment the use of RB_MISSED_EVENTS
If the persistent ring buffer is detected on boot up to have a corrupted sub-buffer, that sub-buffer is cleared to zero and its commit value has the RB_MISSED_EVENTS bit set. That bit is to allow the "trace", "trace_pipe" and "trace_pipe_raw" files know that events were dropped by outputting "[LOST EVENTS]". Only in this case does that bit get set in the writeable portion of the ring buffer. When events are dropped in the normal ring buffer, that information is stored in the cpu_buffer descriptor and the RB_MISSED_EVENTS is set in the buffer page at the time the page is consumed. It is never set in the writeable portion of the buffer. Add comments to describe this better as it can be confusing to know when the RB_MISSED_EVENTS are set in the commit portion of the buffer page. Link: https://lore.kernel.org/all/20260529001500.14178455a046a5cbc6180861@kernel.org/ Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Link: https://patch.msgid.link/20260528223738.41276c0e@fedora Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 8928e4a commit 4e8729e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

kernel/trace/ring_buffer.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,12 @@ static int __rb_validate_buffer(struct buffer_page *bpage, int cpu,
19291929
*/
19301930
if (ret < 0 || (prev_ts && prev_ts > ts) || (next_ts && ts > next_ts)) {
19311931
local_set(&bpage->entries, 0);
1932+
/*
1933+
* Note, the RB_MISSED_EVENTS is only set inside the main write
1934+
* buffer by this verification logic. The normal ring buffer
1935+
* has this bit set when the page is read and passed to the
1936+
* consumers.
1937+
*/
19321938
local_set(&dpage->commit, RB_MISSED_EVENTS);
19331939
dpage->time_stamp = prev_ts ? prev_ts : next_ts;
19341940
ret = -1;
@@ -7232,6 +7238,14 @@ int ring_buffer_read_page(struct trace_buffer *buffer,
72327238
local_add(RB_MISSED_STORED, &dpage->commit);
72337239
size += sizeof(missed_events);
72347240
}
7241+
/*
7242+
* Note, for the persistent ring buffer, the RB_MISSED_EVENTS
7243+
* may have been set in the main buffer via the verification code.
7244+
* But here, dpage is a copy of that page and has not yet had
7245+
* the RB_MISSED_EVENTS set. As for the normal buffers,
7246+
* the main write buffer does not set these bits and it needs
7247+
* to be set here.
7248+
*/
72357249
local_add(RB_MISSED_EVENTS, &dpage->commit);
72367250
}
72377251

0 commit comments

Comments
 (0)