]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tracing: Append repeated boot-time tracing parameters
authorWesley Atwell <atwellwea@gmail.com>
Mon, 30 Mar 2026 18:11:02 +0000 (12:11 -0600)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 31 Mar 2026 18:52:56 +0000 (14:52 -0400)
Some tracing boot parameters already accept delimited value lists, but
their __setup() handlers keep only the last instance seen at boot.
Make repeated instances append to the same boot-time buffer in the
format each parser already consumes.

Use a shared trace_append_boot_param() helper for the ftrace filters,
trace_options, and kprobe_event boot parameters.

This also lets Bootconfig array values work naturally when they expand
to repeated param=value entries.

Before this change, only the last instance from each repeated
parameter survived boot.

Link: https://patch.msgid.link/20260330181103.1851230-1-atwellwea@gmail.com
Signed-off-by: Wesley Atwell <atwellwea@gmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/ftrace.c
kernel/trace/trace.c
kernel/trace/trace.h
kernel/trace/trace_kprobe.c

index 4133109126098451fc2c5e2ab13bdfcd8ccd44b2..8bd3dd1d549cf2f7625c61bc1e295515ed9ba7e2 100644 (file)
@@ -6841,7 +6841,8 @@ bool ftrace_filter_param __initdata;
 static int __init set_ftrace_notrace(char *str)
 {
        ftrace_filter_param = true;
-       strscpy(ftrace_notrace_buf, str, FTRACE_FILTER_SIZE);
+       trace_append_boot_param(ftrace_notrace_buf, str, ',',
+                               FTRACE_FILTER_SIZE);
        return 1;
 }
 __setup("ftrace_notrace=", set_ftrace_notrace);
@@ -6849,7 +6850,8 @@ __setup("ftrace_notrace=", set_ftrace_notrace);
 static int __init set_ftrace_filter(char *str)
 {
        ftrace_filter_param = true;
-       strscpy(ftrace_filter_buf, str, FTRACE_FILTER_SIZE);
+       trace_append_boot_param(ftrace_filter_buf, str, ',',
+                               FTRACE_FILTER_SIZE);
        return 1;
 }
 __setup("ftrace_filter=", set_ftrace_filter);
@@ -6861,14 +6863,16 @@ static int ftrace_graph_set_hash(struct ftrace_hash *hash, char *buffer);
 
 static int __init set_graph_function(char *str)
 {
-       strscpy(ftrace_graph_buf, str, FTRACE_FILTER_SIZE);
+       trace_append_boot_param(ftrace_graph_buf, str, ',',
+                               FTRACE_FILTER_SIZE);
        return 1;
 }
 __setup("ftrace_graph_filter=", set_graph_function);
 
 static int __init set_graph_notrace_function(char *str)
 {
-       strscpy(ftrace_graph_notrace_buf, str, FTRACE_FILTER_SIZE);
+       trace_append_boot_param(ftrace_graph_notrace_buf, str, ',',
+                               FTRACE_FILTER_SIZE);
        return 1;
 }
 __setup("ftrace_graph_notrace=", set_graph_notrace_function);
index 7b9dd637884996b84aa2aab3184f8340ceae0edf..284f813a61f89cc47840321a0a8d2227a36d8ee4 100644 (file)
@@ -221,6 +221,34 @@ static char *default_bootup_tracer;
 static char boot_instance_info[COMMAND_LINE_SIZE] __initdata;
 static int boot_instance_index;
 
+/*
+ * Repeated boot parameters, including Bootconfig array expansions, need
+ * to stay in the delimiter form that the existing parser consumes.
+ */
+void __init trace_append_boot_param(char *buf, const char *str, char sep,
+                                   int size)
+{
+       int len, needed, str_len;
+
+       if (!*str)
+               return;
+
+       len = strlen(buf);
+       str_len = strlen(str);
+       needed = len + str_len + 1;
+
+       /* For continuation, account for the separator. */
+       if (len)
+               needed++;
+       if (needed > size)
+               return;
+
+       if (len)
+               buf[len++] = sep;
+
+       strscpy(buf + len, str, size - len);
+}
+
 static int __init set_cmdline_ftrace(char *str)
 {
        strscpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
@@ -290,7 +318,8 @@ static char trace_boot_options_buf[MAX_TRACER_SIZE] __initdata;
 
 static int __init set_trace_boot_options(char *str)
 {
-       strscpy(trace_boot_options_buf, str, MAX_TRACER_SIZE);
+       trace_append_boot_param(trace_boot_options_buf, str, ',',
+                               MAX_TRACER_SIZE);
        return 1;
 }
 __setup("trace_options=", set_trace_boot_options);
index a3ea735a9ef67f5dcf4413ce33ebc1dd86826a3e..0904fd356634a95d29dd41ec7ef1552e882131da 100644 (file)
@@ -905,6 +905,8 @@ extern int DYN_FTRACE_TEST_NAME(void);
 #define DYN_FTRACE_TEST_NAME2 trace_selftest_dynamic_test_func2
 extern int DYN_FTRACE_TEST_NAME2(void);
 
+void __init trace_append_boot_param(char *buf, const char *str,
+                                   char sep, int size);
 extern void trace_set_ring_buffer_expanded(struct trace_array *tr);
 extern bool tracing_selftest_disabled;
 
index a5dbb72528e0c3682c8d37da64c56d6b145a3749..e9f1c55aea64150c22903ce29107158f62ce145e 100644 (file)
@@ -31,7 +31,8 @@ static char kprobe_boot_events_buf[COMMAND_LINE_SIZE] __initdata;
 
 static int __init set_kprobe_boot_events(char *str)
 {
-       strscpy(kprobe_boot_events_buf, str, COMMAND_LINE_SIZE);
+       trace_append_boot_param(kprobe_boot_events_buf, str, ';',
+                               COMMAND_LINE_SIZE);
        disable_tracing_selftest("running kprobe events");
 
        return 1;