Skip to content

Commit 78f5b3b

Browse files
rostedtgregkh
authored andcommitted
tracing: Always update snapshot buffer size
commit 7be76461f302ec05cbd62b90b2a05c64299ca01f upstream. It use to be that only the top level instance had a snapshot buffer (for latency tracers like wakeup and irqsoff). The update of the ring buffer size would check if the instance was the top level and if so, it would also update the snapshot buffer as it needs to be the same as the main buffer. Now that lower level instances also has a snapshot buffer, they too need to update their snapshot buffer sizes when the main buffer is changed, otherwise the following can be triggered: # cd /sys/kernel/tracing # echo 1500 > buffer_size_kb # mkdir instances/foo # echo irqsoff > instances/foo/current_tracer # echo 1000 > instances/foo/buffer_size_kb Produces: WARNING: CPU: 2 PID: 856 at kernel/trace/trace.c:1938 update_max_tr_single.part.0+0x27d/0x320 Which is: ret = ring_buffer_swap_cpu(tr->max_buffer.buffer, tr->array_buffer.buffer, cpu); if (ret == -EBUSY) { [..] } WARN_ON_ONCE(ret && ret != -EAGAIN && ret != -EBUSY); <== here That's because ring_buffer_swap_cpu() has: int ret = -EINVAL; [..] /* At least make sure the two buffers are somewhat the same */ if (cpu_buffer_a->nr_pages != cpu_buffer_b->nr_pages) goto out; [..] out: return ret; } Instead, update all instances' snapshot buffer sizes when their main buffer size is updated. Link: https://lkml.kernel.org/r/[email protected] Cc: [email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Fixes: 6d9b3fa ("tracing: Move tracing_max_latency into trace_array") Signed-off-by: Steven Rostedt (Google) <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5eaa4d2 commit 78f5b3b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

kernel/trace/trace.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5258,8 +5258,7 @@ static int __tracing_resize_ring_buffer(struct trace_array *tr,
52585258
return ret;
52595259

52605260
#ifdef CONFIG_TRACER_MAX_TRACE
5261-
if (!(tr->flags & TRACE_ARRAY_FL_GLOBAL) ||
5262-
!tr->current_trace->use_max_tr)
5261+
if (!tr->current_trace->use_max_tr)
52635262
goto out;
52645263

52655264
ret = ring_buffer_resize(tr->max_buffer.buffer, size, cpu);

0 commit comments

Comments
 (0)