From: Breno Leitao <leitao@debian.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Vincent Donnefort <vdonnefort@google.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
Steven Rostedt <srostedt@redhat.com>,
kernel-team@meta.com, stable@vger.kernel.org
Subject: Re: [PATCH v2] ring-buffer: Handle a reader taking the new head in rb_handle_head_page()
Date: Mon, 9 Nov 2026 05:10:37 -0800 [thread overview]
Message-ID: <avHFeq9GjAVN_OnF@gmail.com> (raw)
In-Reply-To: <20261105155729.0f9c7e4d@gandalf.local.home>
Hello Steven,
On Thu, Nov 05, 2026 at 03:57:29PM -0500, Steven Rostedt wrote:
> Can you try this?
>
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index c64e001c3fc0..f0bb2d23d818 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -3721,6 +3721,14 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
> local_sub(rb_page_commit(next_page), &cpu_buffer->entries_bytes);
> local_inc(&cpu_buffer->pages_lost);
>
> + /*
> + * To prevent a stale head_page from being between
> + * the UPDATE and new HEAD pages, set it here to have
> + * the reader check always find the update before
> + * finding the HEAD page.
> + */
> + cpu_buffer->head_page = next_page;
> +
> if (cpu_buffer->ring_meta)
> rb_update_meta_head(cpu_buffer, next_page);
> /*
>
> We may need to add memory barriers here, but for now, I think this could
> fix it. As it should prevent the search from ever starting in between the
> two heads.
This seems to be racy as well. Sashiko found the race, and it can be
reproduced by adding some delays in the code.
Thanks for looking at it,
--breno
prev parent reply other threads:[~2026-11-09 13:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 11:12 Breno Leitao
2026-11-05 20:57 ` Steven Rostedt
2026-11-09 7:21 ` Steven Rostedt
2026-11-09 9:21 ` Vincent Donnefort
2026-11-09 13:10 ` Breno Leitao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=avHFeq9GjAVN_OnF@gmail.com \
--to=leitao@debian.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=srostedt@redhat.com \
--cc=stable@vger.kernel.org \
--cc=vdonnefort@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®