From: Steven Rostedt <rostedt@goodmis.org>
To: Wesley Atwell <atwellwea@gmail.com>
Cc: mhiramat@kernel.org, mark.rutland@arm.com,
mathieu.desnoyers@efficios.com, corbet@lwn.net,
skhan@linuxfoundation.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/2] tracing: preserve repeated boot-time tracing parameters
Date: Tue, 24 Mar 2026 14:43:45 -0400 [thread overview]
Message-ID: <20260324144345.0fff670b@gandalf.local.home> (raw)
In-Reply-To: <20260310064715.527906-2-atwellwea@gmail.com>
On Tue, 10 Mar 2026 00:47:14 -0600
Wesley Atwell <atwellwea@gmail.com> wrote:
Hi,
FYI, the tracing subsystem uses capital letters in subjects:
tracing: Preserve repeated boot-time tracing parameters
> 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, and document that behavior in
> admin-guide/kernel-parameters.txt.
>
> Use a shared trace_append_boot_param() helper for the ftrace filters,
> trace_options, and kprobe_event boot parameters. trace_trigger=
> tokenizes its backing storage in place, so keep a running offset and
> only parse the newly appended chunk into bootup_triggers[].
>
> This also lets Bootconfig array values work naturally when they expand
> to repeated param=value entries.
>
> Signed-off-by: Wesley Atwell <atwellwea@gmail.com>
> ---
> .../admin-guide/kernel-parameters.txt | 18 ++++++++++--
> kernel/trace/ftrace.c | 12 +++++---
> kernel/trace/trace.c | 3 +-
> kernel/trace/trace.h | 29 +++++++++++++++++++
> kernel/trace/trace_events.c | 26 +++++++++++++++--
> kernel/trace/trace_kprobe.c | 3 +-
> 6 files changed, 79 insertions(+), 12 deletions(-)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 55ffc0f8858a..203863c1839b 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -1803,13 +1803,15 @@ Kernel parameters
> tracer at boot up. function-list is a comma-separated
> list of functions. This list can be changed at run
> time by the set_ftrace_filter file in the debugfs
> - tracing directory.
> + tracing directory. Repeated instances append more
> + functions to the same list.
>
> ftrace_notrace=[function-list]
> [FTRACE] Do not trace the functions specified in
> function-list. This list can be changed at run time
> by the set_ftrace_notrace file in the debugfs
> - tracing directory.
> + tracing directory. Repeated instances append more
> + functions to the same list.
>
> ftrace_graph_filter=[function-list]
> [FTRACE] Limit the top level callers functions traced
> @@ -1817,12 +1819,16 @@ Kernel parameters
> function-list is a comma-separated list of functions
> that can be changed at run time by the
> set_graph_function file in the debugfs tracing directory.
> + Repeated instances append more functions to the same
> + list.
>
> ftrace_graph_notrace=[function-list]
> [FTRACE] Do not trace from the functions specified in
> function-list. This list is a comma-separated list of
> functions that can be changed at run time by the
> set_graph_notrace file in the debugfs tracing directory.
> + Repeated instances append more functions to the same
> + list.
>
> ftrace_graph_max_depth=<uint>
> [FTRACE] Used with the function graph tracer. This is
> @@ -3053,6 +3059,8 @@ Kernel parameters
> The probe-list is a semicolon delimited list of probe
> definitions. Each definition is same as kprobe_events
> interface, but the parameters are comma delimited.
> + Repeated instances append more probe definitions to
> + the same boot-time list.
> For example, to add a kprobe event on vfs_read with
> arg1 and arg2, add to the command line;
>
> @@ -7820,6 +7828,9 @@ Kernel parameters
>
> /sys/kernel/tracing/trace_options
>
> + Repeated instances append more options to the same
> + boot-time list.
> +
> For example, to enable stacktrace option (to dump the
> stack trace of each event), add to the command line:
>
> @@ -7831,7 +7842,8 @@ Kernel parameters
> trace_trigger=[trigger-list]
> [FTRACE] Add an event trigger on specific events.
> Set a trigger on top of a specific event, with an optional
> - filter.
> + filter. Repeated instances append more triggers to
> + the same boot-time list.
I know Masami mentioned to document this, but honestly, I don't think this
update is needed. Please remove it.
>
> The format is "trace_trigger=<event>.<trigger>[ if <filter>],..."
> Where more than one trigger may be specified that are comma delimited.
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 8df69e702706..d0a486b63ed6 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -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);
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index ebd996f8710e..5086239a75dc 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -329,7 +329,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);
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index b8f3804586a0..4f5abac4bd19 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -23,6 +23,7 @@
> #include <linux/once_lite.h>
> #include <linux/ftrace_regs.h>
> #include <linux/llist.h>
> +#include <linux/string.h>
>
> #include "pid_list.h"
>
> @@ -262,6 +263,34 @@ static inline bool still_need_pid_events(int type, struct trace_pid_list *pid_li
> (!(type & TRACE_NO_PIDS) && no_pid_list);
> }
>
> +/*
> + * Repeated boot parameters, including Bootconfig array expansions, need
> + * to stay in the delimiter form that the existing parser consumes.
> + */
> +static inline void __init trace_append_boot_param(char *buf, const char *str,
> + char sep, size_t size)
> +{
Masami said:
Please make a generic append function in kernel/trace/trace.h, e.g.
void trace_append_boot_param(char *buf, const char *str, char sep, size_t ssize);
and use it instead of strscpy.
He did not say to make a static inline in the header. Please make this a
normal function in trace.c and just add the prototype in the header.
-- Steve
> + size_t len, str_len;
> +
> + if (buf[0] == '\0') {
> + strscpy(buf, str, size);
> + return;
> + }
> +
> + str_len = strlen(str);
> + if (!str_len)
> + return;
> +
> + len = strlen(buf);
> + if (len >= size - 1)
> + return;
> + if (str_len >= size - len - 1)
> + return;
> +
> + buf[len] = sep;
> + strscpy(buf + len + 1, str, size - len - 1);
> +}
> +
> typedef bool (*cond_update_fn_t)(struct trace_array *tr, void *cond_data);
>
> /**
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index 249d1cba72c0..5f72be33f2d1 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -3679,20 +3679,40 @@ static struct boot_triggers {
> } bootup_triggers[MAX_BOOT_TRIGGERS];
>
> static char bootup_trigger_buf[COMMAND_LINE_SIZE];
> +static size_t bootup_trigger_buf_len;
> static int nr_boot_triggers;
>
> static __init int setup_trace_triggers(char *str)
> {
> char *trigger;
> char *buf;
> + size_t start, str_len;
> int i;
>
> - strscpy(bootup_trigger_buf, str, COMMAND_LINE_SIZE);
> + if (bootup_trigger_buf_len >= COMMAND_LINE_SIZE)
> + return 1;
> +
> + start = bootup_trigger_buf_len;
> + if (start && !*str)
> + return 1;
> +
> + str_len = strlen(str);
> + if (start && str_len >= COMMAND_LINE_SIZE - start)
> + return 1;
> +
> + /*
> + * trace_trigger= parsing tokenizes the backing storage in place.
> + * Copy each repeated parameter into fresh space and only parse that
> + * newly copied chunk here.
> + */
> + trace_append_boot_param(bootup_trigger_buf + start, str, '\0',
> + COMMAND_LINE_SIZE - start);
> + bootup_trigger_buf_len += strlen(bootup_trigger_buf + start) + 1;
> trace_set_ring_buffer_expanded(NULL);
> disable_tracing_selftest("running event triggers");
>
> - buf = bootup_trigger_buf;
> - for (i = 0; i < MAX_BOOT_TRIGGERS; i++) {
> + buf = bootup_trigger_buf + start;
> + for (i = nr_boot_triggers; i < MAX_BOOT_TRIGGERS; i++) {
> trigger = strsep(&buf, ",");
> if (!trigger)
> break;
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index a5dbb72528e0..e9f1c55aea64 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -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;
next prev parent reply other threads:[~2026-03-24 18:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 6:47 [PATCH v3 0/2] tracing: preserve repeated boot-time parameters and drain deferred trigger frees Wesley Atwell
2026-03-10 6:47 ` [PATCH v3 1/2] tracing: preserve repeated boot-time tracing parameters Wesley Atwell
2026-03-24 18:43 ` Steven Rostedt [this message]
2026-03-10 6:47 ` [PATCH v3 2/2] tracing: drain deferred trigger frees if kthread startup fails Wesley Atwell
2026-03-24 18:53 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260324144345.0fff670b@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=atwellwea@gmail.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox