Re: [PATCH] tracing: Fix trace_buf_size= cmdline parameter with sizes >= 2G

From: Steven Rostedt

Date: Fri Mar 06 2026 - 21:37:43 EST


On Fri, 6 Mar 2026 18:28:38 -0800
Calvin Owens <calvin@xxxxxxxxxx> wrote:

> Some of the sizing logic through tracer_alloc_buffers() uses int
> internally, causing unexpected behavior if the user passes a value that
> does not fit in an int (on my x86 machine, the result is uselessly tiny
> buffers).
>
> Fix by plumbing the parameter's real type (unsigned long) through to the
> ring buffer allocation functions, which already use unsigned long. Also,
> tweak ring_buffer_meta_scratch() to avoid void pointer arithmetic.

Let's make this only fix the problem at hand and leave scratch alone.
Scratch is seldom more than a page size and int should be plenty.

>
> It has always been possible to create larger ring buffers via the sysfs
> interface: this only affects the cmdline parameter.
>
> Fixes: 73c5162aa362 ("tracing: keep ring buffer to minimum size till used")

Another reason not to touch scratch, is because it's a very new
feature, and this fix goes back to 2009. If you want this to hit stable
trees, only fix what is needed.

Generally, you should only fix the problem anyway in one patch, and use
other patches to make other updates.

-- Steve


> Signed-off-by: Calvin Owens <calvin@xxxxxxxxxx>