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

perf/tracing: Use stage6 of tracing to not duplicate macros

The perf events are created by the same macro magic as tracefs trace
events are. But to hook into perf, it has its own code. It duplicates many
of the same macros as the tracefs macros and this is an issue because it
misses bug fixes as well as any new enhancements that come with the other
trace macros.

As the trace macros have been put into their own staging files, have perf
take advantage of this and use the tracefs stage 6 macros that the "fast
assign" portion of the trace event macro uses.

Link: https://lkml.kernel.org/r/20230124202515.716458410@goodmis.org
Link: https://lore.kernel.org/lkml/1671181385-5719-1-git-send-email-quic_linyyuan@quicinc.com/

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reported-by: Linyu Yuan <quic_linyyuan@quicinc.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+4 -45
+1 -45
include/trace/perf.h
··· 4 4 5 5 #ifdef CONFIG_PERF_EVENTS 6 6 7 - #undef __entry 8 - #define __entry entry 9 - 10 - #undef __get_dynamic_array 11 - #define __get_dynamic_array(field) \ 12 - ((void *)__entry + (__entry->__data_loc_##field & 0xffff)) 13 - 14 - #undef __get_dynamic_array_len 15 - #define __get_dynamic_array_len(field) \ 16 - ((__entry->__data_loc_##field >> 16) & 0xffff) 17 - 18 - #undef __get_str 19 - #define __get_str(field) ((char *)__get_dynamic_array(field)) 20 - 21 - #undef __get_bitmask 22 - #define __get_bitmask(field) (char *)__get_dynamic_array(field) 23 - 24 - #undef __get_cpumask 25 - #define __get_cpumask(field) (char *)__get_dynamic_array(field) 26 - 27 - #undef __get_sockaddr 28 - #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) 29 - 30 - #undef __get_rel_dynamic_array 31 - #define __get_rel_dynamic_array(field) \ 32 - ((void *)__entry + \ 33 - offsetof(typeof(*__entry), __rel_loc_##field) + \ 34 - sizeof(__entry->__rel_loc_##field) + \ 35 - (__entry->__rel_loc_##field & 0xffff)) 36 - 37 - #undef __get_rel_dynamic_array_len 38 - #define __get_rel_dynamic_array_len(field) \ 39 - ((__entry->__rel_loc_##field >> 16) & 0xffff) 40 - 41 - #undef __get_rel_str 42 - #define __get_rel_str(field) ((char *)__get_rel_dynamic_array(field)) 43 - 44 - #undef __get_rel_bitmask 45 - #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) 46 - 47 - #undef __get_rel_cpumask 48 - #define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) 49 - 50 - #undef __get_rel_sockaddr 51 - #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) 7 + #include "stages/stage6_event_callback.h" 52 8 53 9 #undef __perf_count 54 10 #define __perf_count(c) (__count = (c))
+3
include/trace/stages/stage6_event_callback.h
··· 2 2 3 3 /* Stage 6 definitions for creating trace events */ 4 4 5 + /* Reuse some of the stage 3 macros */ 6 + #include "stage3_trace_output.h" 7 + 5 8 #undef __entry 6 9 #define __entry entry 7 10