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, kernel-team@android.com
Subject: Re: [PATCH 1/2] ring-buffer: Introducing ring-buffer mapping functions
Date: Tue, 21 Mar 2023 12:51:59 -0400	[thread overview]
Message-ID: <20230321125159.5ddc2da7@gandalf.local.home> (raw)
In-Reply-To: <ZBnZWhcelEpKXHo8@google.com>

On Tue, 21 Mar 2023 16:20:42 +0000
Vincent Donnefort <vdonnefort@google.com> wrote:

> > > Do we want a specific field here? That could be deduced from nr_data_pages()
> > > quite easily?  
> > 
> > I rather not have too much implementation detail knowledge in user space.
> > It only removes a single entry, and it makes user space easier. In fact,  
> 
> Ack.
> 
> > I'm thinking we should not include "__u32 data_pages[]" but instead add a:
> > "__u32 data_start" where user space does:
> > 
> > 	__u32 *data_pages = (_u32 *)meta_page + meta_page->data_start;
> > 
> > That way we could extend the data provided by the meta_page in the future.  
> 
> That'd be nice. Couldn't we keep both to simplify the code for the kernel side?

I would not expose the data_pages[] to user space, because then they'll use
it, and that *will* become an API.

But we could expose it to the kernel side with;

include/uapi/linux/trace_mmap.h:

struct ring_buffer_meta_page {
#if __BITS_PER_LONG == 64
	__u64	entries;
	__u64	overrun;
#else
	__u32	entries;
	__u32	overrun;
#endif
	__u32	pages_touched;
	__u32	reader_page;
	__u32	nr_data_pages;	/* doesn't take into account the reader_page */
	__u32	data_page_head;	/* index of data_pages[] */
	__u32	meta_page_size;	/* size of the meta page */
	__u32	data_start;	/* offset to where data_pages are */
};

kernel/trace/ring_buffer.c:

struct ring_buffer_meta {
	struct ring_buffer_meta_page	meta;
	u32				data_pages[];
}

Then we can start each function with:

	struct ring_buffer_meta_page *meta = &cpu_buffer->meta_page.meta;
	u32 *data_pages = cpu_buffer->meta_page.data_pages;

-- Steve

  reply	other threads:[~2023-03-21 16:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 14:33 [PATCH 0/2] Introducing trace buffer mapping by user-space Vincent Donnefort
2023-03-17 14:33 ` [PATCH 1/2] ring-buffer: Introducing ring-buffer mapping functions Vincent Donnefort
2023-03-21  1:45   ` Steven Rostedt
2023-03-21 15:17     ` Vincent Donnefort
2023-03-21 15:40       ` Steven Rostedt
2023-03-21 16:20         ` Vincent Donnefort
2023-03-21 16:51           ` Steven Rostedt [this message]
2023-03-21 16:44         ` Steven Rostedt
2023-03-21 16:50           ` Vincent Donnefort
2023-03-17 14:33 ` [PATCH 2/2] tracing: Allow user-space mapping of the ring-buffer 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=20230321125159.5ddc2da7@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=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®