Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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@goodmis.org>
Signed-off-by: Avadhut Naik <avadhut.naik@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Link: https://lore.kernel.org/r/20241022194158.110073-3-avadhut.naik@amd.com

authored by

Steven Rostedt and committed by
Borislav Petkov (AMD)
e52750fb 750fd239

+15 -1
+8
include/trace/stages/stage3_trace_output.h
··· 119 119 trace_print_array_seq(p, array, count, el_size); \ 120 120 }) 121 121 122 + #undef __print_dynamic_array 123 + #define __print_dynamic_array(array, el_size) \ 124 + ({ \ 125 + __print_array(__get_dynamic_array(array), \ 126 + __get_dynamic_array_len(array) / (el_size), \ 127 + (el_size)); \ 128 + }) 129 + 122 130 #undef __print_hex_dump 123 131 #define __print_hex_dump(prefix_str, prefix_type, \ 124 132 rowsize, groupsize, buf, len, ascii) \
+1
include/trace/stages/stage7_class_define.h
··· 22 22 #undef __get_rel_cpumask 23 23 #undef __get_rel_sockaddr 24 24 #undef __print_array 25 + #undef __print_dynamic_array 25 26 #undef __print_hex_dump 26 27 #undef __get_buf 27 28
+6 -1
samples/trace_events/trace-events-sample.h
··· 319 319 __assign_cpumask(cpum, cpumask_bits(mask)); 320 320 ), 321 321 322 - TP_printk("foo %s %d %s %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, 322 + TP_printk("foo %s %d %s %s %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, 323 323 324 324 /* 325 325 * Notice here the use of some helper functions. This includes: ··· 363 363 __print_array(__get_dynamic_array(list), 364 364 __get_dynamic_array_len(list) / sizeof(int), 365 365 sizeof(int)), 366 + 367 + /* A shortcut is to use __print_dynamic_array for dynamic arrays */ 368 + 369 + __print_dynamic_array(list, sizeof(int)), 370 + 366 371 __get_str(str), __get_str(lstr), 367 372 __get_bitmask(cpus), __get_cpumask(cpum), 368 373 __get_str(vstr))