mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Breno Leitao <leitao@debian.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: Tue, 10 Nov 2026 02:55:21 -0500	[thread overview]
Message-ID: <20261110025521.289f4303@fedora> (raw)
In-Reply-To: <avHFeq9GjAVN_OnF@gmail.com>

On Mon, 9 Nov 2026 05:10:37 -0800
Breno Leitao <leitao@debian.org> wrote:

> 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.

Yeah, I'm currently traveling and didn't have time to do a deep dive
into a real fix and decided to be lazy and post the patch and see what
sashiko found ;-)

Thanks for verifying the issue with this "fix" that Sashiko pointed out.

I need to spend a bit of time looking deeper into it to come up with a
real solution.

-- Steve

      reply	other threads:[~2026-11-10  7:55 UTC|newest]

Thread overview: 7+ 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-10  7:52     ` Steven Rostedt
2026-11-09 13:10   ` Breno Leitao
2026-11-10  7:55     ` Steven Rostedt [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=20261110025521.289f4303@fedora \
    --to=rostedt@goodmis.org \
    --cc=kernel-team@meta.com \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.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®