From: Steven Rostedt <rostedt@goodmis.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Feng Yang <yangfeng@kylinos.cn>,
Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Subject: Re: [GIT PULL] ring-buffer: Updates for v6.15
Date: Thu, 27 Mar 2025 22:01:06 -0400 [thread overview]
Message-ID: <20250327220106.37c921ea@batman.local.home> (raw)
In-Reply-To: <CAHk-=wgW4QfXuR0StSz15jqCs-suuPhfDajKr1bH2qS73cT4dA@mail.gmail.com>
On Thu, 27 Mar 2025 18:31:55 -0700
Linus Torvalds <torvalds@linux-foundation.org> wrote:
> On Thu, 27 Mar 2025 at 18:24, Steven Rostedt <rostedt@goodmis.org> wrote:
> >
> > The pages are never vmalloc'd, it's only ever vmap()'d on top of
> > contiguous physical memory or allocated via alloc_page() in the order
> > given. Thus, we do not support non consecutive physical memory.
>
> Christ, that just makes it EVEN WORSE.\
Let me explain this better. Yes it uses alloc_page() but that's just an
intermediate function. What is saved is the page_address(page), as that
is what is used by the code. That is, the allocation uses alloc_page()
but then immediately converted to page_address() to use. The page
itself is just an temp variable to get contiguous memory, as the
sub-buffers must be contiguous.
>
> Just keep track of the actual original physical allocation, then!
>
> By all means vmap it too for whoever wants the virtual allocation, but
> remember the *real* allocation, and keep it as a 'struct page'
> together with the order that you already have.
The virtual address needs to be created as that's all the code cares
about. For the case where the physical memory is passed in, it requires
a vmap(). The struct page is only needed when the ring buffer is going
to be mmapped to user space.
>
> And then you never use vmalloc_to_page() - or even virt_to_page() - at
> all, because you actually know your base allocation, and keep it in
> that form that so much of this code wants in the first place.
>
> Having a a nice reliable 'struct page *' (together with that size
> order) and keeping it in that form would be *so* much cleaner.
>
> Instead of randomly translating it to (two different!) kinds of
> virtual kernel addresses and then translating it back when you wanted
> the original proper format.
By moving the physical mapping of the code into the ring buffer code, I
can set a flag for the buffer to mark it as being mapped directly, and
we can save the struct pages for this location (easily found by the
address). Then to get the page, it could be a simple helper function of:
struct page *rb_get_page(struct trace_buffer *buffer, unsigned long addr)
{
if (buffer->flags & RB_FL_PHYSICAL) {
addr -= buffer->vmap_start;
addr += buffer->phys_start;
return pfn_to_page(addr >> PAGE_SHIFT);
}
return virt_to_page(addr);
}
next prev parent reply other threads:[~2025-03-28 2:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-27 21:10 Steven Rostedt
2025-03-28 0:59 ` Linus Torvalds
2025-03-28 1:24 ` Steven Rostedt
2025-03-28 1:31 ` Linus Torvalds
2025-03-28 2:01 ` Steven Rostedt [this message]
2025-03-28 2:17 ` Linus Torvalds
2025-03-28 2:19 ` Linus Torvalds
2025-03-28 3:01 ` Steven Rostedt
2025-03-28 3:19 ` Linus Torvalds
2025-03-28 3:29 ` Steven Rostedt
2025-03-28 3:36 ` Linus Torvalds
2025-03-28 4:00 ` Steven Rostedt
2025-03-28 2:44 ` Steven Rostedt
2025-03-28 3:05 ` Linus Torvalds
2025-03-28 3:27 ` Steven Rostedt
2025-03-28 3:43 ` Linus Torvalds
2025-03-28 12:50 ` 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=20250327220106.37c921ea@batman.local.home \
--to=rostedt@goodmis.org \
--cc=jiapeng.chong@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=yangfeng@kylinos.cn \
/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®