summaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2020-03-17 17:32:29 -0400
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2020-03-19 19:11:20 -0400
commit153368ce1bd0ccb47812a3185e824445a7024ea5 (patch)
tree1733d0e1eeb0611c99aa07bd96b697a03b00d198 /kernel/trace
parentff84c50cfb4b8dc68c982fb6c05a524e1539ee2f (diff)
downloadlinux-153368ce1bd0ccb47812a3185e824445a7024ea5.tar.gz
linux-153368ce1bd0ccb47812a3185e824445a7024ea5.tar.bz2
linux-153368ce1bd0ccb47812a3185e824445a7024ea5.zip
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/20200317213416.592032170@goodmis.org Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/ring_buffer.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 475338fda969..5979327254f9 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1929,6 +1929,9 @@ rb_iter_head_event(struct ring_buffer_iter *iter)
unsigned long commit;
unsigned length;
+ if (iter->head != iter->next_event)
+ return iter->event;
+
/*
* When the writer goes across pages, it issues a cmpxchg which
* is a mb(), which will synchronize with the rmb here.