Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ring-buffer: use READ_ONCE() to read cpu_buffer->commit_page in concurrent environment

In function ring_buffer_iter_empty(), cpu_buffer->commit_page is read
while other threads may change it. It may cause the time_stamp that read
in the next line come from a different page. Use READ_ONCE() to avoid
having to reason about compiler optimizations now and in future.

Link: https://lore.kernel.org/linux-trace-kernel/tencent_DFF7D3561A0686B5E8FC079150A02505180A@qq.com

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: linke li <lilinke99@qq.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

linke li and committed by
Steven Rostedt (Google)
f1e30cb6 6b76323e

+1 -1
+1 -1
kernel/trace/ring_buffer.c
··· 4382 4382 cpu_buffer = iter->cpu_buffer; 4383 4383 reader = cpu_buffer->reader_page; 4384 4384 head_page = cpu_buffer->head_page; 4385 - commit_page = cpu_buffer->commit_page; 4385 + commit_page = READ_ONCE(cpu_buffer->commit_page); 4386 4386 commit_ts = commit_page->page->time_stamp; 4387 4387 4388 4388 /*