From: Steven Rostedt <rostedt@goodmis.org>
To: Woradorn Laodhanadhaworn <woradorn.laon@gmail.com>
Cc: mhiramat@kernel.org, mathieu.desnoyers@efficios.com,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev, shuah@kernel.org,
skhan@linuxfoundation.org, me@brighamcampbell.com,
jkoolstra@xs4all.nl
Subject: Re: [PATCH v2] tracing: Use seq_buf for string concatenation
Date: Mon, 29 Jun 2026 14:39:47 -0400 [thread overview]
Message-ID: <20260629143947.2216574e@robin> (raw)
In-Reply-To: <20260622094623.18469-1-woradorn.laon@gmail.com>
On Mon, 22 Jun 2026 16:46:23 +0700
Woradorn Laodhanadhaworn <woradorn.laon@gmail.com> wrote:
>
> #include <trace/events/sched.h>
> #include <trace/syscall.h>
> @@ -4500,14 +4501,20 @@ static void __add_event_to_tracers(struct trace_event_call *call)
> extern struct trace_event_call *__start_ftrace_events[];
> extern struct trace_event_call *__stop_ftrace_events[];
>
> -static char bootup_event_buf[COMMAND_LINE_SIZE] __initdata;
Keep the above string and just assign it.
> +static struct seq_buf bootup_event_buf __initdata = {
> + .buffer = (char[COMMAND_LINE_SIZE]) {},
> + .size = COMMAND_LINE_SIZE,
> +};
static struct seq_buf bootup_event_seq __initdata = {
.buffer = bootup_event_buf;
.size = sizeof(bootup_event_buf);
};
>
> static __init int setup_trace_event(char *str)
> {
> - if (bootup_event_buf[0] != '\0')
> - strlcat(bootup_event_buf, ",", COMMAND_LINE_SIZE);
> + if (seq_buf_used(&bootup_event_buf) > 0)
> + seq_buf_puts(&bootup_event_buf, ",");
> +
> + seq_buf_puts(&bootup_event_buf, str);
>
> - strlcat(bootup_event_buf, str, COMMAND_LINE_SIZE);
> + if (seq_buf_has_overflowed(&bootup_event_buf))
> + return -ENOMEM;
>
> trace_set_ring_buffer_expanded(NULL);
> disable_tracing_selftest("running event tracing");
> @@ -4766,7 +4773,7 @@ static __init int event_trace_enable(void)
> */
> __trace_early_add_events(tr);
>
> - early_enable_events(tr, bootup_event_buf, false);
> + early_enable_events(tr, (char *)seq_buf_str(&bootup_event_buf), false);
The above then would be:
seq_buf_str(&bootup_event_seq);
early_enable_events(tr, bootup_event_buf, false);
Don't typecast a const char* to non const.
>
> trace_printk_start_comm();
>
> @@ -4794,7 +4801,7 @@ static __init int event_trace_enable_again(void)
> if (!tr)
> return -ENODEV;
>
> - early_enable_events(tr, bootup_event_buf, true);
> + early_enable_events(tr, (char *)seq_buf_str(&bootup_event_buf), true);
Same here.
-- Steve
>
> return 0;
> }
prev parent reply other threads:[~2026-06-29 18:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-22 9:46 [PATCH v2] tracing: Use seq_buf for string concatenation Woradorn Laodhanadhaworn
2026-06-29 18:39 ` Steven Rostedt [this message]
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=20260629143947.2216574e@robin \
--to=rostedt@goodmis.org \
--cc=jkoolstra@xs4all.nl \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=me@brighamcampbell.com \
--cc=mhiramat@kernel.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=woradorn.laon@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.