On Wed, 28 Sep 2022 10:54:43 -0400 Steven Rostedt <rostedt@xxxxxxxxxxx> wrote: > Will reply with an updated patch. Can you try this patch? diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 677812b8fae0..7b548a26009e 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -2643,6 +2643,9 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer, /* Mark the rest of the page with padding */ rb_event_set_padding(event); + /* Make sure the padding is visible before the write update */ + smp_wmb(); + /* Set the write back to the previous setting */ local_sub(length, &tail_page->write); return; @@ -2654,6 +2657,9 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer, /* time delta must be non zero */ event->time_delta = 1; + /* Make sure the padding is visible before the tail_page->write update */ + smp_wmb(); + /* Set write to end of buffer */ length = (tail + length) - BUF_PAGE_SIZE; local_sub(length, &tail_page->write); @@ -4615,6 +4621,13 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer) goto again; out: + /* If the write is past the end of page, a writer is still updating it */ + if (reader && rb_page_write(reader) > BUF_PAGE_SIZE) + reader = NULL; + + /* Make sure we see any padding after the write update (see rb_reset_tail()) */ + smp_rmb(); + /* Update the read_stamp on the first event */ if (reader && reader->read == 0) cpu_buffer->read_stamp = reader->page->time_stamp;