Re: [PATCH] ring-buffer: Add barrire in rb_move_tail

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

 



On Fri, 2 Sep 2022 11:47:58 +0800
lijiazi <jqqlijiazi@xxxxxxxxx> wrote:

> Yes, I'm thinking this may be a race issue too.
> But I didn't find race point through code review.

I think I may have found it. Can you test this patch?

[ Disclaimer, I did not even try to compile it ]

-- Steve

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index d59b6a328b7f..0f47e68fee9b 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -4580,6 +4580,10 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
 	goto again;
 
  out:
+	/* If the commit is past the end of page, a writer is still updating it */
+	if (reader && rb_page_size(reader) > BUF_PAGE_SIZE)
+		reader = NULL;
+
 	/* Update the read_stamp on the first event */
 	if (reader && reader->read == 0)
 		cpu_buffer->read_stamp = reader->page->time_stamp;



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux