Skip to content

Commit e948916

Browse files
committed
tracing: Fix ftrace_boot_snapshot command line logic
The kernel command line ftrace_boot_snapshot by itself is supposed to trigger a snapshot at the end of boot up of the main top level trace buffer. A ftrace_boot_snapshot=foo will do the same for an instance called foo that was created by trace_instance=foo,... The logic was broken where if ftrace_boot_snapshot was by itself, it would trigger a snapshot for all instances that had tracing enabled, regardless if it asked for a snapshot or not. When a snapshot is requested for a buffer, the buffer's tr->allocated_snapshot is set to true. Use that to know if a trace buffer wants a snapshot at boot up or not. Since the top level buffer is part of the ftrace_trace_arrays list, there's no reason to treat it differently than the other buffers. Just iterate the list if ftrace_boot_snapshot was specified. Link: https://lkml.kernel.org/r/[email protected] Cc: [email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Ross Zwisler <[email protected]> Fixes: 9c1c251 ("tracing: Allow boot instances to have snapshot buffers") Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 9d52727 commit e948916

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

kernel/trace/trace.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10393,19 +10393,20 @@ __init static int tracer_alloc_buffers(void)
1039310393

1039410394
void __init ftrace_boot_snapshot(void)
1039510395
{
10396+
#ifdef CONFIG_TRACER_MAX_TRACE
1039610397
struct trace_array *tr;
1039710398

10398-
if (snapshot_at_boot) {
10399-
tracing_snapshot();
10400-
internal_trace_puts("** Boot snapshot taken **\n");
10401-
}
10399+
if (!snapshot_at_boot)
10400+
return;
1040210401

1040310402
list_for_each_entry(tr, &ftrace_trace_arrays, list) {
10404-
if (tr == &global_trace)
10403+
if (!tr->allocated_snapshot)
1040510404
continue;
10406-
trace_array_puts(tr, "** Boot snapshot taken **\n");
10405+
1040710406
tracing_snapshot_instance(tr);
10407+
trace_array_puts(tr, "** Boot snapshot taken **\n");
1040810408
}
10409+
#endif
1040910410
}
1041010411

1041110412
void __init early_trace_init(void)

0 commit comments

Comments
 (0)