tracing: Fix trace_buf_size= cmdline parameter with sizes >= 2G

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.

It has always been possible to create larger ring buffers via the sysfs
interface: this only affects the cmdline parameter.

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://patch.msgid.link/bff42a4288aada08bdf74da3f5b67a2c28b761f8.1772852067.git.calvin@wbinvd.org
Fixes: 73c5162aa3 ("tracing: keep ring buffer to minimum size till used")
Signed-off-by: Calvin Owens <calvin@wbinvd.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
Calvin Owens 2026-03-06 19:19:25 -08:00 committed by Steven Rostedt (Google)
parent 3b1679e086
commit d008ba8be8

View file

@ -9350,7 +9350,7 @@ static void setup_trace_scratch(struct trace_array *tr,
} }
static int static int
allocate_trace_buffer(struct trace_array *tr, struct array_buffer *buf, int size) allocate_trace_buffer(struct trace_array *tr, struct array_buffer *buf, unsigned long size)
{ {
enum ring_buffer_flags rb_flags; enum ring_buffer_flags rb_flags;
struct trace_scratch *tscratch; struct trace_scratch *tscratch;
@ -9405,7 +9405,7 @@ static void free_trace_buffer(struct array_buffer *buf)
} }
} }
static int allocate_trace_buffers(struct trace_array *tr, int size) static int allocate_trace_buffers(struct trace_array *tr, unsigned long size)
{ {
int ret; int ret;
@ -10769,7 +10769,7 @@ __init static void enable_instances(void)
__init static int tracer_alloc_buffers(void) __init static int tracer_alloc_buffers(void)
{ {
int ring_buf_size; unsigned long ring_buf_size;
int ret = -ENOMEM; int ret = -ENOMEM;