[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241011100132.456f903a@gandalf.local.home>
Date: Fri, 11 Oct 2024 10:01:32 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Petr Pavlu <petr.pavlu@...e.com>
Cc: LKML <linux-kernel@...r.kernel.org>, Linux Trace Kernel
<linux-trace-kernel@...r.kernel.org>, Masami Hiramatsu
<mhiramat@...nel.org>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Subject: Re: [PATCH] ring-buffer: Have the buffer update counter be atomic
On Fri, 11 Oct 2024 10:05:51 +0200
Petr Pavlu <petr.pavlu@...e.com> wrote:
> On 10/11/24 01:58, Steven Rostedt wrote:
> > From: Steven Rostedt <rostedt@...dmis.org>
> >
> > In order to prevent any subtle races with the buffer update counter,
> > change it to an atomic_t. Also, since atomic_t is 32 bits, move its
> > location in the ring_buffer_per_cpu structure next to "current_context" as
> > that too is only 32 bits (making 64 bit alignment).
> >
> > The counter is only used to detect that the buffer has been updated when
> > the buffer verifier check is being done. It's not really that important
> > that it's atomic or not. But since the updates to the counter are never in
> > the fast path, having it be consistent isn't a bad thing.
> >
> > Signed-off-by: Steven Rostedt (Google) <rostedt@...dmis.org>
> > ---
> > Note, this is based on top of:
> >
> > https://lore.kernel.org/linux-trace-kernel/20240715145141.5528-1-petr.pavlu@suse.com/
>
> Sorry for not replying to your last comment on my patch, I was ill.
>
> The member ring_buffer_per_cpu.cnt is intended to be accessed under the
> reader_lock, same as the pages pointer which it is tied to, so this
> change shouldn't be strictly needed.
>
Right, but there was one location that the cnt was updated outside the
lock. The one I commented on. But instead of adding a lock around it, I
decided to just make it an atomic. Then there would be no need for the
lock. Hmm, it still needs a memory barrier though. At least a
smp_mb__after_atomic().
-- Steve
Powered by blists - more mailing lists