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 v10 1/2] ring-buffer: Introducing ring-buffer mapping functions
Date: Tue, 9 Jan 2024 11:42:00 -0500 [thread overview]
Message-ID: <20240109114200.01367342@gandalf.local.home> (raw)
In-Reply-To: <ZZ1ir0edlY3OzjyC@google.com>
On Tue, 9 Jan 2024 15:13:51 +0000
Vincent Donnefort <vdonnefort@google.com> wrote:
> > > @@ -388,6 +389,7 @@ struct rb_irq_work {
> > > bool waiters_pending;
> > > bool full_waiters_pending;
> > > bool wakeup_full;
> > > + bool is_cpu_buffer;
> >
> > I think 'is_cpu_buffer' is a bit unclear (or generic),
> > what about 'meta_page_update'?
>
> Hum not sure about that change. This was really to identify if parent of
> rb_irq_work is a cpu_buffer or a trace_buffer. It can be a cpu_buffer regardless
> of the need to update the meta-page.
Yeah, this was added because the irq_work is called with the rb_work for
both the cpu_buffer and the global struct tracing_buffer object. The
meta_page is only available to the cpu_buffer and does not exist on the
struct trace_buffer, so this is checked before doing a "container_of()" on
the wrong structure. Both the cpu_buffer and the global buffer call the
same function with the rb_work structure.
So "is_cpu_buffer" is the right terminology as it's unrelated to the meta page:
struct trace_buffer {
[..]
struct rb_irq_work irq_work;
[..]
};
struct trace_buffer *buffer;
buffer->irq_work.is_cpu_buffer = false;
struct ring_buffer_per_cpu {
[..]
struct rb_irq_work irq_work;
[..]
}
struct ring_buffer_per_cpu *cpu_buffer;
cpu_buffer->irq_work.is_cpu_buffer = true;
[..]
init_irq_work(&buffer->irq_work.work, rb_wake_up_waiters);
[..]
init_irq_work(&cpu_buffer->irq_work.work, rb_wake_up_waiters);
// both the buffer and cpu_buffer call rb_wake_up_waiters()
static void rb_wake_up_waiters(struct irq_work *work)
{
struct rb_irq_work *rbwork = container_of(work, struct rb_irq_work, work);
// This container_of() gets rbwork which is the rb_irq_work structure that
// both buffer and cpu_buffer have.
if (rbwork->is_cpu_buffer) {
struct ring_buffer_per_cpu *cpu_buffer;
cpu_buffer = container_of(rbwork, struct ring_buffer_per_cpu,
irq_work);
// The above crashes if done by the buffer and not the cpu_buffer.
// The "is_cpu_buffer" is there to differentiate the two rb_work entities.
// It is a way to say this is safe to do the above "container_of()".
/*
* If the waiter is a cpu_buffer, this might be due to a
* userspace mapping. Let's update the meta-page.
*/
rb_update_meta_page(cpu_buffer);
}
-- Steve
next prev parent reply other threads:[~2024-01-09 16:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-05 9:47 [PATCH v10 0/2] Introducing trace buffer mapping by user-space Vincent Donnefort
2024-01-05 9:47 ` [PATCH v10 1/2] ring-buffer: Introducing ring-buffer mapping functions Vincent Donnefort
2024-01-09 14:42 ` Masami Hiramatsu
2024-01-09 15:13 ` Vincent Donnefort
2024-01-09 16:42 ` Steven Rostedt [this message]
2024-01-09 23:42 ` Masami Hiramatsu
2024-01-09 23:58 ` Steven Rostedt
2024-01-11 9:52 ` Vincent Donnefort
2024-01-11 9:57 ` Vincent Donnefort
2024-01-05 9:47 ` [PATCH v10 2/2] tracing: Allow user-space mapping of the ring-buffer Vincent Donnefort
2024-01-09 13:04 ` [PATCH v10 0/2] Introducing trace buffer mapping by user-space Masami Hiramatsu
2024-01-09 13:20 ` Steven Rostedt
2024-01-09 13:47 ` 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=20240109114200.01367342@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®