[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <173046126587.3137.17478186661563402818.tip-bot2@tip-bot2>
Date: Fri, 01 Nov 2024 11:41:05 -0000
From: "tip-bot2 for Steven Rostedt" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: "Steven Rostedt (Google)" <rostedt@...dmis.org>,
Avadhut Naik <avadhut.naik@....com>, "Borislav Petkov (AMD)" <bp@...en8.de>,
Qiuxu Zhuo <qiuxu.zhuo@...el.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: ras/core] tracing: Add __print_dynamic_array() helper
The following commit has been merged into the ras/core branch of tip:
Commit-ID: e52750fb1458ae9ea5860a08ed7a149185bc5b97
Gitweb: https://git.kernel.org/tip/e52750fb1458ae9ea5860a08ed7a149185bc5b97
Author: Steven Rostedt <rostedt@...dmis.org>
AuthorDate: Tue, 22 Oct 2024 19:36:28
Committer: Borislav Petkov (AMD) <bp@...en8.de>
CommitterDate: Wed, 30 Oct 2024 17:24:32 +01:00
tracing: Add __print_dynamic_array() helper
When printing a dynamic array in a trace event, the method is rather ugly.
It has the format of:
__print_array(__get_dynamic_array(array),
__get_dynmaic_array_len(array) / el_size, el_size)
Since dynamic arrays are known to the tracing infrastructure, create a
helper macro that does the above for you.
__print_dynamic_array(array, el_size)
Which would expand to the same output.
Signed-off-by: Steven Rostedt (Google) <rostedt@...dmis.org>
Signed-off-by: Avadhut Naik <avadhut.naik@....com>
Signed-off-by: Borislav Petkov (AMD) <bp@...en8.de>
Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@...el.com>
Link: https://lore.kernel.org/r/20241022194158.110073-3-avadhut.naik@amd.com
---
include/trace/stages/stage3_trace_output.h | 8 ++++++++
include/trace/stages/stage7_class_define.h | 1 +
samples/trace_events/trace-events-sample.h | 7 ++++++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h
index c1fb135..1e7b0be 100644
--- a/include/trace/stages/stage3_trace_output.h
+++ b/include/trace/stages/stage3_trace_output.h
@@ -119,6 +119,14 @@
trace_print_array_seq(p, array, count, el_size); \
})
+#undef __print_dynamic_array
+#define __print_dynamic_array(array, el_size) \
+ ({ \
+ __print_array(__get_dynamic_array(array), \
+ __get_dynamic_array_len(array) / (el_size), \
+ (el_size)); \
+ })
+
#undef __print_hex_dump
#define __print_hex_dump(prefix_str, prefix_type, \
rowsize, groupsize, buf, len, ascii) \
diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h
index bcb960d..fcd564a 100644
--- a/include/trace/stages/stage7_class_define.h
+++ b/include/trace/stages/stage7_class_define.h
@@ -22,6 +22,7 @@
#undef __get_rel_cpumask
#undef __get_rel_sockaddr
#undef __print_array
+#undef __print_dynamic_array
#undef __print_hex_dump
#undef __get_buf
diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h
index 55f9a3d..999f78d 100644
--- a/samples/trace_events/trace-events-sample.h
+++ b/samples/trace_events/trace-events-sample.h
@@ -319,7 +319,7 @@ TRACE_EVENT(foo_bar,
__assign_cpumask(cpum, cpumask_bits(mask));
),
- TP_printk("foo %s %d %s %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar,
+ TP_printk("foo %s %d %s %s %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar,
/*
* Notice here the use of some helper functions. This includes:
@@ -363,6 +363,11 @@ TRACE_EVENT(foo_bar,
__print_array(__get_dynamic_array(list),
__get_dynamic_array_len(list) / sizeof(int),
sizeof(int)),
+
+/* A shortcut is to use __print_dynamic_array for dynamic arrays */
+
+ __print_dynamic_array(list, sizeof(int)),
+
__get_str(str), __get_str(lstr),
__get_bitmask(cpus), __get_cpumask(cpum),
__get_str(vstr))
Powered by blists - more mailing lists