Skip to content

Commit af1eea1

Browse files
committed
tracing: Use system_state in trace_printk_init_buffers()
The function trace_printk_init_buffers() is used to expand tha trace_printk buffers when trace_printk() is used within the kernel or in modules. On kernel boot up, it holds off from starting the sched switch cmdline recorder, but will start it immediately when it is added by a module. Currently it uses a trick to see if the global_trace buffer has been allocated or not to know if it was called by module load or not. But this is more of a hack, and can not be used when this code is moved out of trace.c. Instead simply look at the system_state and if it is running then it is know that it could only be called by module load. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Link: https://patch.msgid.link/20260208032450.660237094@kernel.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent f377912 commit af1eea1

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

kernel/trace/trace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3243,10 +3243,9 @@ void trace_printk_init_buffers(void)
32433243
/*
32443244
* trace_printk_init_buffers() can be called by modules.
32453245
* If that happens, then we need to start cmdline recording
3246-
* directly here. If the global_trace.buffer is already
3247-
* allocated here, then this was called by module code.
3246+
* directly here.
32483247
*/
3249-
if (global_trace.array_buffer.buffer)
3248+
if (system_state == SYSTEM_RUNNING)
32503249
tracing_start_cmdline_record();
32513250
}
32523251
EXPORT_SYMBOL_GPL(trace_printk_init_buffers);

0 commit comments

Comments
 (0)