aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/trace/stages/stage6_event_callback.h
diff options
context:
space:
mode:
authorSteven Rostedt (Google) <rostedt@goodmis.org>2024-02-22 16:14:16 -0500
committerSteven Rostedt (Google) <rostedt@goodmis.org>2024-03-18 10:32:27 -0400
commitc1fa617caeb005e7e3db60826cff6dddebb0363f (patch)
tree2fd4efc532add8f79d5367d6122092ae30b51aa0 /include/trace/stages/stage6_event_callback.h
parentcxl/trace: Properly initialize cxl_poison region name (diff)
downloadwireguard-linux-c1fa617caeb005e7e3db60826cff6dddebb0363f.tar.xz
wireguard-linux-c1fa617caeb005e7e3db60826cff6dddebb0363f.zip
tracing: Rework __assign_str() and __string() to not duplicate getting the string
The TRACE_EVENT() macro handles dynamic strings by having: TP_PROTO(struct some_struct *s), TP_ARGS(s), TP_STRUCT__entry( __string(my_string, s->string) ), TP_fast_assign( __assign_str(my_string, s->string); ) TP_printk("%s", __get_str(my_string)) There's even some code that may call a function helper to find the s->string value. The problem with the above is that the work to get the s->string is done twice. Once at the __string() and again in the __assign_str(). But the __string() uses dynamic_array() which has a helper structure that is created holding the offsets and length of the string fields. Instead of finding the string twice, just save it off in another field from that helper structure, and have __assign_str() use that instead. Note, this also means that the second parameter of __assign_str() isn't even used anymore, and may be removed in the future. Link: https://lore.kernel.org/linux-trace-kernel/20240222211442.634192653@goodmis.org Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Diffstat (limited to '')
-rw-r--r--include/trace/stages/stage6_event_callback.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h
index 919b1a4da980..b3e2f321e787 100644
--- a/include/trace/stages/stage6_event_callback.h
+++ b/include/trace/stages/stage6_event_callback.h
@@ -32,12 +32,14 @@
#undef __assign_str
#define __assign_str(dst, src) \
- strcpy(__get_str(dst), (src) ? (const char *)(src) : "(null)");
+ strcpy(__get_str(dst), __data_offsets.dst##_ptr_ ? \
+ __data_offsets.dst##_ptr_ : "(null)")
#undef __assign_str_len
#define __assign_str_len(dst, src, len) \
do { \
- memcpy(__get_str(dst), (src), (len)); \
+ memcpy(__get_str(dst), __data_offsets.dst##_ptr_ ? \
+ __data_offsets.dst##_ptr_ : "(null)", len); \
__get_str(dst)[len] = '\0'; \
} while(0)
@@ -92,12 +94,14 @@
#undef __assign_rel_str
#define __assign_rel_str(dst, src) \
- strcpy(__get_rel_str(dst), (src) ? (const char *)(src) : "(null)");
+ strcpy(__get_rel_str(dst), __data_offsets.dst##_ptr_ ? \
+ __data_offsets.dst##_ptr_ : "(null)")
#undef __assign_rel_str_len
#define __assign_rel_str_len(dst, src, len) \
do { \
- memcpy(__get_rel_str(dst), (src), (len)); \
+ memcpy(__get_rel_str(dst), __data_offsets.dst##_ptr_ ? \
+ __data_offsets.dst##_ptr_ : "(null)", len); \
__get_rel_str(dst)[len] = '\0'; \
} while (0)