Re: [PATCH v2 1/2] tracing: ring-buffer: Have the ring buffer code do the vmap of physical memory

From: Steven Rostedt
Date: Tue Apr 01 2025 - 11:53:30 EST


On Tue, 1 Apr 2025 18:26:43 +0300
Mike Rapoport <rppt@xxxxxxxxxx> wrote:

> > But if I use vmap_page_range(), how do I give that back to the memory allocator?
>
> But you don't need neither vmap() nor vmap_page_range() to have kernel page
> tables for memory that you get from reserve_mem. It's already mapped and
> plain phys_to_virt() gives you the virtual address you can use.

Oh! That makes things so much easier! Especially since that means it should
work like the normal buffer where virt_to_page() should also work. Right?

Now I do support mapping the persistent ring buffer via memmap, but I can
just give up on allowing that to be memory mapped to user space, or even
freed.

>
> > Calling vunmap() on that memory gives me:
> >
> > 1779.832484] ------------[ cut here ]------------
> > [ 1779.834076] Trying to vunmap() nonexistent vm area (000000027c000000)
> > [ 1779.835941] WARNING: CPU: 6 PID: 956 at mm/vmalloc.c:3413 vunmap+0x5a/0x60
> >
> > What's the proper way to say: "I no longer need this physical memory I
> > reserved, the kernel can now use it"?
>
> free_reserved_area()

Awesome!

Thanks,

-- Steve