]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ring-buffer: Fix reporting of missed events in iterator
authorSteven Rostedt <rostedt@goodmis.org>
Thu, 21 May 2026 02:08:01 +0000 (22:08 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 21 May 2026 12:20:29 +0000 (08:20 -0400)
commita254b6d13b0edd6272926674d2afc46d46e496b7
treebd016cedee60ee7e0514227c46e5360868d4d960
parent5200f5f493f79f14bbdc349e402a40dfb32f23c8
ring-buffer: Fix reporting of missed events in iterator

When tracing is active while reading the trace file, if the iterator
reading the buffer detects that the writer has passed the iterator head,
it will reset and set a "missed events" flag. This flag is passed to the
output processing to show the user that events were missed:

  CPU:4 [LOST EVENTS]

The problem is that the flag is reset after it is checked in
ring_buffer_iter_dropped(). But the "trace" file iterates over all the CPU
ring buffers and it will check if they are dropped when figuring out which
buffer to print next. This prematurely clears the missed_events flag if
the CPU buffer with the missed events is not the one that is printed next.

On the iteration where the CPU buffer with the missed events is printed,
the check if it had missed events would return false and the output does
not show that events were missed.

Do not reset the missed_events flag when checking if there were missed
events, but instead clear it when moving the iterator head to the next
event.

Cc: stable@vger.kernel.org
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://patch.msgid.link/20260520220801.4fd09d13@fedora
Fixes: c9b7a4a72ff64 ("ring-buffer/tracing: Have iterator acknowledge dropped events")
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/ring_buffer.c