On Fri, 7 Aug 2026 15:26:41 -0400
Steven Rostedt <[email protected]> wrote:

> On Fri, 7 Aug 2026 16:45:23 +0100
> Vincent Donnefort <[email protected]> wrote:
> 
> > free_reserved_page() would do actually. But then it is definitive. 
> 
> It's not always a reserved page.
> 
> > 
> > Happy to implement something like that. That also means that the instance 
> > can be
> > actually freed?
> 
> They can be freed now. Try a rmdir on one.
> 
> Note implementing this is not straight forward. What I would suggest is
> that because the persistent ring buffers are contiguous, to resize, you
> basically need to remap to the new size. That means each of the buffers
> will still be attached to each other.
> 
> What would need to be done is:
> 
>   1. calculate the new size needed to accommodate all the CPU buffers.
>   2. Split them up within the new size region.
>   3. Then free the remaining pages.
> 
> Obviously, access to the buffer from readers and writers will need to be
> prohibited while this is happening.

Hmm, I think we also need to record the size of persistent ring buffer at
initialization. The buffer size (number of pages are calculated by the
size of reserved memory, which is defined in the kernel cmdline.

So if we have `reserve_mem=12M:4096:trace trace_instance=boot_map@trace` on
the kernel cmdline, and we write the buffer_size = 1024(KB) on 2CPU machine,
it can be shrinked down to ~2MB on the reserved memory. However, when we
reboot the machine, the kernel calculates the size as 12MB again, and may
get a validation failure.

So we also need to add nr_pages and nr_cpus (maybe) on ring_buffer_meta and
calculate the ring buffer size from it, instead of using the reserved memory
size (we also need to check the calculated size is smaller than that.)

Thank you,

-- 
Masami Hiramatsu (Google) <[email protected]>

Reply via email to