Skip to content

Commit 153368c

Browse files
committed
ring-buffer: Optimize rb_iter_head_event()
As it is fine to perform several "peeks" of event data in the ring buffer via the iterator before moving it forward, do not re-read the event, just return what was read before. Otherwise, it can cause inconsistent results, especially when testing multiple CPU buffers to interleave them. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent ff84c50 commit 153368c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/trace/ring_buffer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,9 @@ rb_iter_head_event(struct ring_buffer_iter *iter)
19291929
unsigned long commit;
19301930
unsigned length;
19311931

1932+
if (iter->head != iter->next_event)
1933+
return iter->event;
1934+
19321935
/*
19331936
* When the writer goes across pages, it issues a cmpxchg which
19341937
* is a mb(), which will synchronize with the rmb here.

0 commit comments

Comments
 (0)