mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Vincent Donnefort <vdonnefort@google.com>
Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org,
	mathieu.desnoyers@efficios.com, kernel-team@android.com
Subject: Re: [PATCH v16 2/6] ring-buffer: Introducing ring-buffer mapping functions
Date: Mon, 12 Feb 2024 16:47:23 -0500	[thread overview]
Message-ID: <20240212164723.55993db2@gandalf.local.home> (raw)
In-Reply-To: <Zcn2iotAnIWT4F_O@google.com>

On Mon, 12 Feb 2024 10:44:26 +0000
Vincent Donnefort <vdonnefort@google.com> wrote:

> > >  static void
> > >  rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
> > >  {
> > > @@ -5204,6 +5227,9 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
> > >  	cpu_buffer->lost_events = 0;
> > >  	cpu_buffer->last_overrun = 0;
> > >  
> > > +	if (READ_ONCE(cpu_buffer->mapped))  
> > 
> > Isn't the buffer_mutex held when we modify mapped? I believe it's held
> > here. I don't think we need a READ_ONCE() here. Is there a reason for it?
> > 
> > Hmm, looking down, it looks like you take the buffer->mutex after
> > setting mapped, is that necessary? If we take the buffer->mutex we can
> > sync the reset with mapping.  
> 
> The idea was to not take any of the buffer mutex, reader lock if the refcount is
> simply inc/dec. Locks are only used if the meta-page is
> installed/uninstalled.

Does it matter? The inc/dec is only done at initial mapping, right? That's
a very slow path.

> 
> The WRITE_ONCE/READ_ONCE is there only to make sure no compiler optimisation
> could lead a reader to wrongly interpret that refcount while it is inc/dec. That
> is probably not necessary and I'm happy to either drop it completely or replace
> it by taking buffer mutex and reader lock whenever the refcount is inc/dec.

Yeah, probably best to drop it and keep updates within the mutex.

-- Steve


  reply	other threads:[~2024-02-12 21:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 16:34 [PATCH v16 0/6] Introducing trace buffer mapping by user-space Vincent Donnefort
2024-02-09 16:34 ` [PATCH v16 1/6] ring-buffer: Zero ring-buffer sub-buffers Vincent Donnefort
2024-02-09 16:34 ` [PATCH v16 2/6] ring-buffer: Introducing ring-buffer mapping functions Vincent Donnefort
2024-02-11 22:18   ` Steven Rostedt
2024-02-12 10:44     ` Vincent Donnefort
2024-02-12 21:47       ` Steven Rostedt [this message]
2024-02-09 16:34 ` [PATCH v16 3/6] tracing: Add snapshot refcount Vincent Donnefort
2024-02-09 16:34 ` [PATCH v16 4/6] tracing: Allow user-space mapping of the ring-buffer Vincent Donnefort
2024-02-11 22:31   ` Steven Rostedt
2024-02-09 16:34 ` [PATCH v16 5/6] Documentation: tracing: Add ring-buffer mapping Vincent Donnefort
2024-02-11 22:38   ` Steven Rostedt
2024-02-09 16:34 ` [PATCH v16 6/6] ring-buffer/selftest: Add ring-buffer mapping test Vincent Donnefort

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=20240212164723.55993db2@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@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®