diff options
| author | Woradorn Laodhanadhaworn <woradorn.laon@gmail.com> | 2026-07-13 11:52:49 +0700 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2026-07-28 07:18:50 -0400 |
| commit | efdcfd9b4f4f07aa70663ee02a79dbdf980bf582 (patch) | |
| tree | 767ce1b80c4078f4d4c20d25f61ca3a06fb7b9b1 /kernel | |
| parent | dca6a22aee1b9fb2fe26823bc3b302e8eba8d05c (diff) | |
tracing: Use seq_buf for string concatenation
In preparation for removing the strlcat API[1],
replace the string concatenation logic with a struct seq_buf,
which tracks the current position and the remaining space internally.
Use seq_buf_str() to NUL-terminate before passing to early_enable_events().
Link: https://github.com/KSPP/linux/issues/370 [1]
Link: https://patch.msgid.link/20260713045249.69942-1-woradorn.laon@gmail.com
Signed-off-by: Woradorn Laodhanadhaworn <woradorn.laon@gmail.com>
[ Moved placement of #include <linux/seq_buf.h> ]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/trace/trace_events.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 714285e23a2e..a8590d2394e3 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -14,6 +14,7 @@ #include <linux/workqueue.h> #include <linux/security.h> #include <linux/spinlock.h> +#include <linux/seq_buf.h> #include <linux/kthread.h> #include <linux/tracefs.h> #include <linux/uaccess.h> @@ -4604,13 +4605,20 @@ 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; +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_seq) > 0) + seq_buf_puts(&bootup_event_seq, ","); + + seq_buf_puts(&bootup_event_seq, str); - strlcat(bootup_event_buf, str, COMMAND_LINE_SIZE); + if (seq_buf_has_overflowed(&bootup_event_seq)) + return -ENOMEM; trace_set_ring_buffer_expanded(NULL); disable_tracing_selftest("running event tracing"); @@ -4869,6 +4877,7 @@ static __init int event_trace_enable(void) */ __trace_early_add_events(tr); + seq_buf_str(&bootup_event_seq); early_enable_events(tr, bootup_event_buf, false); trace_printk_start_comm(); @@ -4897,6 +4906,7 @@ static __init int event_trace_enable_again(void) if (!tr) return -ENODEV; + seq_buf_str(&bootup_event_seq); early_enable_events(tr, bootup_event_buf, true); return 0; |
