diff --git a/patches.kernel.org/6.2.12-100-tracing-Add-trace_array_puts-to-write-into-ins.patch b/patches.kernel.org/6.2.12-100-tracing-Add-trace_array_puts-to-write-into-ins.patch new file mode 100644 index 0000000..c757e96 --- /dev/null +++ b/patches.kernel.org/6.2.12-100-tracing-Add-trace_array_puts-to-write-into-ins.patch @@ -0,0 +1,116 @@ +From: "Steven Rostedt (Google)" +Date: Tue, 7 Feb 2023 12:28:52 -0500 +Subject: [PATCH] tracing: Add trace_array_puts() to write into instance +References: bsc#1012628 +Patch-mainline: 6.2.12 +Git-commit: d503b8f7474fe7ac616518f7fc49773cbab49f36 + +[ Upstream commit d503b8f7474fe7ac616518f7fc49773cbab49f36 ] + +Add a generic trace_array_puts() that can be used to "trace_puts()" into +an allocated trace_array instance. This is just another variant of +trace_array_printk(). + +Link: https://lkml.kernel.org/r/20230207173026.584717290@goodmis.org + +Cc: Masami Hiramatsu +Cc: Andrew Morton +Reviewed-by: Ross Zwisler +Signed-off-by: Steven Rostedt (Google) +Stable-dep-of: 9d52727f8043 ("tracing: Have tracing_snapshot_instance_cond() write errors to the appropriate instance") +Signed-off-by: Sasha Levin +Signed-off-by: Jiri Slaby +--- + include/linux/trace.h | 12 ++++++++++++ + kernel/trace/trace.c | 27 +++++++++++++++++---------- + 2 files changed, 29 insertions(+), 10 deletions(-) + +diff --git a/include/linux/trace.h b/include/linux/trace.h +index 80ffda87..2a70a447 100644 +--- a/include/linux/trace.h ++++ b/include/linux/trace.h +@@ -33,6 +33,18 @@ struct trace_array; + int register_ftrace_export(struct trace_export *export); + int unregister_ftrace_export(struct trace_export *export); + ++/** ++ * trace_array_puts - write a constant string into the trace buffer. ++ * @tr: The trace array to write to ++ * @str: The constant string to write ++ */ ++#define trace_array_puts(tr, str) \ ++ ({ \ ++ str ? __trace_array_puts(tr, _THIS_IP_, str, strlen(str)) : -1; \ ++ }) ++int __trace_array_puts(struct trace_array *tr, unsigned long ip, ++ const char *str, int size); ++ + void trace_printk_init_buffers(void); + __printf(3, 4) + int trace_array_printk(struct trace_array *tr, unsigned long ip, +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c +index 1a931896..13c46787 100644 +--- a/kernel/trace/trace.c ++++ b/kernel/trace/trace.c +@@ -1001,13 +1001,8 @@ __buffer_unlock_commit(struct trace_buffer *buffer, struct ring_buffer_event *ev + ring_buffer_unlock_commit(buffer); + } + +-/** +- * __trace_puts - write a constant string into the trace buffer. +- * @ip: The address of the caller +- * @str: The constant string to write +- * @size: The size of the string. +- */ +-int __trace_puts(unsigned long ip, const char *str, int size) ++int __trace_array_puts(struct trace_array *tr, unsigned long ip, ++ const char *str, int size) + { + struct ring_buffer_event *event; + struct trace_buffer *buffer; +@@ -1015,7 +1010,7 @@ int __trace_puts(unsigned long ip, const char *str, int size) + unsigned int trace_ctx; + int alloc; + +- if (!(global_trace.trace_flags & TRACE_ITER_PRINTK)) ++ if (!(tr->trace_flags & TRACE_ITER_PRINTK)) + return 0; + + if (unlikely(tracing_selftest_running || tracing_disabled)) +@@ -1024,7 +1019,7 @@ int __trace_puts(unsigned long ip, const char *str, int size) + alloc = sizeof(*entry) + size + 2; /* possible \n added */ + + trace_ctx = tracing_gen_ctx(); +- buffer = global_trace.array_buffer.buffer; ++ buffer = tr->array_buffer.buffer; + ring_buffer_nest_start(buffer); + event = __trace_buffer_lock_reserve(buffer, TRACE_PRINT, alloc, + trace_ctx); +@@ -1046,11 +1041,23 @@ int __trace_puts(unsigned long ip, const char *str, int size) + entry->buf[size] = '\0'; + + __buffer_unlock_commit(buffer, event); +- ftrace_trace_stack(&global_trace, buffer, trace_ctx, 4, NULL); ++ ftrace_trace_stack(tr, buffer, trace_ctx, 4, NULL); + out: + ring_buffer_nest_end(buffer); + return size; + } ++EXPORT_SYMBOL_GPL(__trace_array_puts); ++ ++/** ++ * __trace_puts - write a constant string into the trace buffer. ++ * @ip: The address of the caller ++ * @str: The constant string to write ++ * @size: The size of the string. ++ */ ++int __trace_puts(unsigned long ip, const char *str, int size) ++{ ++ return __trace_array_puts(&global_trace, ip, str, size); ++} + EXPORT_SYMBOL_GPL(__trace_puts); + + /** +-- +2.35.3 + diff --git a/series.conf b/series.conf index d62d1d8..1f53e99 100644 --- a/series.conf +++ b/series.conf @@ -2327,6 +2327,7 @@ patches.kernel.org/6.2.12-097-drm-amdgpu-Force-signal-hw_fences-that-are-emb.patch patches.kernel.org/6.2.12-098-drm-amdgpu-gfx-set-cg-flags-to-enter-exit-safe.patch patches.kernel.org/6.2.12-099-ACPI-resource-Add-Medion-S17413-to-IRQ-overrid.patch + patches.kernel.org/6.2.12-100-tracing-Add-trace_array_puts-to-write-into-ins.patch ######################################################## # Build fixes that apply to the vanilla kernel too.