Patch "ring-buffer: use READ_ONCE() to read cpu_buffer->commit_page in concurrent environment" has been added to the 6.8-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

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

to the 6.8-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ring-buffer-use-read_once-to-read-cpu_buffer-commit_.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit bf67ad798f6a7fd84178bbddd41476647569b13d
Author: linke li <lilinke99@xxxxxx>
Date:   Sat Mar 2 12:42:21 2024 +0800

    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@xxxxxx
    
    Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
    Cc: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
    Signed-off-by: linke li <lilinke99@xxxxxx>
    Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 43060a7ae15e7..2ad234366d21c 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -4395,7 +4395,7 @@ int ring_buffer_iter_empty(struct ring_buffer_iter *iter)
 	cpu_buffer = iter->cpu_buffer;
 	reader = cpu_buffer->reader_page;
 	head_page = cpu_buffer->head_page;
-	commit_page = cpu_buffer->commit_page;
+	commit_page = READ_ONCE(cpu_buffer->commit_page);
 	commit_ts = commit_page->page->time_stamp;
 
 	/*




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux