Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+2 -3
+2 -3
kernel/trace/trace.c
··· 3243 3243 /* 3244 3244 * trace_printk_init_buffers() can be called by modules. 3245 3245 * 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. 3248 3247 */ 3249 - if (global_trace.array_buffer.buffer) 3248 + if (system_state == SYSTEM_RUNNING) 3250 3249 tracing_start_cmdline_record(); 3251 3250 } 3252 3251 EXPORT_SYMBOL_GPL(trace_printk_init_buffers);