1 /* SPDX-License-Identifier: GPL-2.0 */
3 #undef TRACE_SYSTEM_VAR
5 #ifdef CONFIG_PERF_EVENTS
10 #undef __get_dynamic_array
11 #define __get_dynamic_array(field) \
12 ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
14 #undef __get_dynamic_array_len
15 #define __get_dynamic_array_len(field) \
16 ((__entry->__data_loc_##field >> 16) & 0xffff)
19 #define __get_str(field) ((char *)__get_dynamic_array(field))
22 #define __get_bitmask(field) (char *)__get_dynamic_array(field)
25 #define __get_cpumask(field) (char *)__get_dynamic_array(field)
28 #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field))
30 #undef __get_rel_dynamic_array
31 #define __get_rel_dynamic_array(field) \
33 offsetof(typeof(*__entry), __rel_loc_##field) + \
34 sizeof(__entry->__rel_loc_##field) + \
35 (__entry->__rel_loc_##field & 0xffff))
37 #undef __get_rel_dynamic_array_len
38 #define __get_rel_dynamic_array_len(field) \
39 ((__entry->__rel_loc_##field >> 16) & 0xffff)
42 #define __get_rel_str(field) ((char *)__get_rel_dynamic_array(field))
44 #undef __get_rel_bitmask
45 #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field)
47 #undef __get_rel_cpumask
48 #define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field)
50 #undef __get_rel_sockaddr
51 #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field))
54 #define __perf_count(c) (__count = (c))
57 #define __perf_task(t) (__task = (t))
59 #undef DECLARE_EVENT_CLASS
60 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
62 perf_trace_##call(void *__data, proto) \
64 struct trace_event_call *event_call = __data; \
65 struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
66 struct trace_event_raw_##call *entry; \
67 struct pt_regs *__regs; \
69 struct task_struct *__task = NULL; \
70 struct hlist_head *head; \
75 __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
77 head = this_cpu_ptr(event_call->perf_events); \
78 if (!bpf_prog_array_valid(event_call) && \
79 __builtin_constant_p(!__task) && !__task && \
83 __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
85 __entry_size -= sizeof(u32); \
87 entry = perf_trace_buf_alloc(__entry_size, &__regs, &rctx); \
91 perf_fetch_caller_regs(__regs); \
97 perf_trace_run_bpf_submit(entry, __entry_size, rctx, \
98 event_call, __count, __regs, \
103 * This part is compiled out, it is only here as a build time check
104 * to make sure that if the tracepoint handling changes, the
105 * perf probe will fail to compile unless it too is updated.
108 #define DEFINE_EVENT(template, call, proto, args) \
109 static inline void perf_test_probe_##call(void) \
111 check_trace_callback_type_##call(perf_trace_##template); \
115 #undef DEFINE_EVENT_PRINT
116 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
117 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
119 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
120 #endif /* CONFIG_PERF_EVENTS */