All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Vincent Donnefort <vdonnefort@google.com>
Cc: sashiko-bot@kernel.org, sashiko-reviews@lists.linux.dev,
	linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v7 1/3] tracing: Fix subbuf resize races with trace_pipe_raw readers
Date: Mon, 24 Aug 2026 10:53:15 -0400	[thread overview]
Message-ID: <20260824105315.27377f30@gandalf.local.home> (raw)
In-Reply-To: <aotTYT0zE5LNik06@google.com>

On Sun, 23 Aug 2026 21:09:05 +0100
Vincent Donnefort <vdonnefort@google.com> wrote:

> > > [Severity: High]
> > > If ring_buffer_read_page() returns -EAGAIN because the subbuffer order was
> > > updated but cpu_buffer->reader_page->order hasn't been updated yet, this
> > > branches back to the again label.
> > > 
> > > Since the loop does not yield the CPU or call cond_resched(), could this cause
> > > a hard lockup if the reader and the resize thread are on the same CPU?  
> > 
> > Hmm, this looks legit. We should at least have a way to break out if it
> > loops too many times.  
> 
> Can this happen only on !CONFIG_PREEMPT systems?

It can happen with RT tasks as they don't yield. If this task is of higher
priority than the one resizing, then it will loop forever even with a
cond_resched().

> 
> I can add a cond_resched() here though, I believe that would make sense: if an
> order modification is pending, writing is disabled anyway and we are about to
> loose the stored events.

For RT tasks, cond_resched() wouldn't be enough.

> 
> Additionally I can reduce the window where buffer::subbuf_order differs from the
> reader page order by adding an "order" argument to __rb_allocate_pages() and
> only set buffer::subbuf_order later in ring_buffer_subbuf_order_set().

I'm wondering if we even care if data_page->order != cpu_buffer->reader_page->order
and should change it to being a force copy instead.

If the reader_page is bigger than the dpage, and only copy what the dpage
can hold. It would also update the read value of the reader_page which
would allow another copy to get the rest. If the data page is bigger, then
just copy everything.

It's not like this will happen often.

-- Steve

  reply	other threads:[~2026-08-24 14:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 13:47 [PATCH v7 0/3] ring-buffer: Fixes for subbuf resizing and persistent buffers Vincent Donnefort
2026-08-17 13:47 ` [PATCH v7 1/3] tracing: Fix subbuf resize races with trace_pipe_raw readers Vincent Donnefort
2026-08-17 14:08   ` sashiko-bot
2026-08-22 15:04     ` Steven Rostedt
2026-08-23 20:09       ` Vincent Donnefort
2026-08-24 14:53         ` Steven Rostedt [this message]
2026-08-25  8:26           ` Vincent Donnefort
2026-08-25 12:47             ` Steven Rostedt
2026-08-25 12:52               ` Vincent Donnefort
2026-08-25 14:25                 ` Steven Rostedt
2026-08-17 13:47 ` [PATCH v7 2/3] ring-buffer: Cap static ring buffer nr_pages Vincent Donnefort
2026-08-17 14:03   ` sashiko-bot
2026-08-17 13:47 ` [PATCH v7 3/3] ring-buffer: Prevent truncation of nr_pages / nr_subbufs Vincent Donnefort
2026-08-17 13:59   ` sashiko-bot

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=20260824105315.27377f30@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-bot@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.