Skip to content

Commit d008ba8

Browse files
jcalvinowensrostedt
authored andcommitted
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: 73c5162 ("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>
1 parent 3b1679e commit d008ba8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

kernel/trace/trace.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9350,7 +9350,7 @@ static void setup_trace_scratch(struct trace_array *tr,
93509350
}
93519351

93529352
static int
9353-
allocate_trace_buffer(struct trace_array *tr, struct array_buffer *buf, int size)
9353+
allocate_trace_buffer(struct trace_array *tr, struct array_buffer *buf, unsigned long size)
93549354
{
93559355
enum ring_buffer_flags rb_flags;
93569356
struct trace_scratch *tscratch;
@@ -9405,7 +9405,7 @@ static void free_trace_buffer(struct array_buffer *buf)
94059405
}
94069406
}
94079407

9408-
static int allocate_trace_buffers(struct trace_array *tr, int size)
9408+
static int allocate_trace_buffers(struct trace_array *tr, unsigned long size)
94099409
{
94109410
int ret;
94119411

@@ -10769,7 +10769,7 @@ __init static void enable_instances(void)
1076910769

1077010770
__init static int tracer_alloc_buffers(void)
1077110771
{
10772-
int ring_buf_size;
10772+
unsigned long ring_buf_size;
1077310773
int ret = -ENOMEM;
1077410774

1077510775

0 commit comments

Comments
 (0)