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: Masami Hiramatsu <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 v11 2/5] ring-buffer: Introducing ring-buffer mapping functions
Date: Mon, 15 Jan 2024 13:03:53 -0500	[thread overview]
Message-ID: <20240115130353.78a7a587@rorschach.local.home> (raw)
In-Reply-To: <ZaVrZWGgmBNbsNba@google.com>

On Mon, 15 Jan 2024 17:29:09 +0000
Vincent Donnefort <vdonnefort@google.com> wrote:

> > 
> > What needs to be done, and feel free to add this as a separate patch,
> > is to have checks where snapshot is used.
> > 
> >   (All errors return -EBUSY)
> > 
> > Before allowing mapping, check to see if:
> > 
> >  1) the current tracer has "use_max_tr" set.
> >  2) any event has a "snapshot" trigger set
> >  3) Any function has a "snapshot" command set  
> 
> Could we sum-up this with a single check to allocate_snapshot? If that is
> allocated it's probably because we'll be using it?

Not always. It can be allocated at any time and never used.

I'd like to keep the allocation of the snapshot buffer agnostic to if
the buffer is mapped or not, especially since it can be allocated at
boot up and never used. Several of my boxes have "alloc_snapshot" on
the command line even though I don't always use it. But we could update
the output of reading the "snapshot" file to:

 ~# cat /sys/kernel/tracing/snapshot 
# tracer: nop
#
#
# ** Snapshot disabled due to the buffer being memory mapped **
#
# * Snapshot is freed *
#
# Snapshot commands:
# echo 0 > snapshot : Clears and frees snapshot buffer
# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.
#                      Takes a snapshot of the main buffer.
# echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)
#                      (Doesn't have to be '2' works with any number that
#                       is not a '0' or '1')

If it is allocated:

 ~# cat /sys/kernel/tracing/snapshot
# tracer: nop
#
# ** Snapshot disabled due to the buffer being memory mapped **
#
# * Snapshot is allocated *
#
# Snapshot commands:
# echo 0 > snapshot : Clears and frees snapshot buffer
# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.
#                      Takes a snapshot of the main buffer.
# echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)
#                      (Doesn't have to be '2' works with any number that
#                       is not a '0' or '1')


> 
> That would simply add the requirement to echo 0 > snapshot before starting the
> memory map?

I rather not depend on that. It just makes it more complex for why
mapping failed. If you get -EBUSY, it will be hard to know why.

> 
> The opposite could be to let tracing_alloc_snapshot_instance() fail whenever a
> mapping is in place?

Yes, that would fail if mapping is in place.

Because the snapshot being allocated can be something people want, as
it allows the snapshot to happen immediately when needed, I don't want
the fact that it is allocated to prevent mapping. As mapping may just
happen for a small period of time while an application is running.

-- Steve

  reply	other threads:[~2024-01-15 18:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-11 16:17 [PATCH v11 0/5] Introducing trace buffer mapping by user-space Vincent Donnefort
2024-01-11 16:17 ` [PATCH v11 1/5] ring-buffer: Zero ring-buffer sub-buffers Vincent Donnefort
2024-01-13 13:38   ` Masami Hiramatsu
2024-01-11 16:17 ` [PATCH v11 2/5] ring-buffer: Introducing ring-buffer mapping functions Vincent Donnefort
2024-01-11 16:34   ` Mathieu Desnoyers
2024-01-11 23:23     ` Steven Rostedt
2024-01-12  9:13       ` Vincent Donnefort
2024-01-12 15:06         ` Steven Rostedt
2024-01-12 15:58           ` Steven Rostedt
2024-01-15  4:43   ` Masami Hiramatsu
2024-01-15 15:37     ` Vincent Donnefort
2024-01-15 16:09       ` Steven Rostedt
2024-01-15 16:23         ` Steven Rostedt
2024-01-15 17:29           ` Vincent Donnefort
2024-01-15 18:03             ` Steven Rostedt [this message]
2024-01-15 23:48           ` Masami Hiramatsu
2024-01-11 16:17 ` [PATCH v11 3/5] tracing: Allow user-space mapping of the ring-buffer Vincent Donnefort
2024-01-11 16:17 ` [PATCH v11 4/5] Documentation: tracing: Add ring-buffer mapping Vincent Donnefort
2024-01-13 13:36   ` Masami Hiramatsu
2024-01-14 14:26   ` Masami Hiramatsu
2024-01-14 16:23     ` Steven Rostedt
2024-01-14 23:10       ` Masami Hiramatsu
2024-01-11 16:17 ` [PATCH v11 5/5] ring-buffer/selftest: Add ring-buffer mapping test Vincent Donnefort
2024-01-13 13:39   ` Masami Hiramatsu
2024-01-14 14:17     ` Masami Hiramatsu
2024-01-14 16:20       ` Steven Rostedt

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=20240115130353.78a7a587@rorschach.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®