]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ring-buffer: use READ_ONCE() to read cpu_buffer->commit_page in concurrent environment
authorlinke li <lilinke99@qq.com>
Sat, 2 Mar 2024 04:42:21 +0000 (12:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Apr 2024 11:07:38 +0000 (13:07 +0200)
commitfb8579acacd0c39b7da0a647a8130c21f782fb5b
treea13bb3a756a018f705d3dc5b69b18333a25f38a3
parent80f175d0f35224dd365b556cd5dbb752c018af0e
ring-buffer: use READ_ONCE() to read cpu_buffer->commit_page in concurrent environment

[ Upstream commit f1e30cb6369251c03f63c564006f96a54197dcc4 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/trace/ring_buffer.c