padata: Remove padata_get_cpumask
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / trace / ftrace.h
blob88c59c13ea7bdfd58edb7ec715fe8764288366ae
1 /*
2 * Stage 1 of the trace events.
4 * Override the macros in <trace/trace_events.h> to include the following:
6 * struct ftrace_raw_<call> {
7 * struct trace_entry ent;
8 * <type> <item>;
9 * <type2> <item2>[<len>];
10 * [...]
11 * };
13 * The <type> <item> is created by the __field(type, item) macro or
14 * the __array(type2, item2, len) macro.
15 * We simply do "type item;", and that will create the fields
16 * in the structure.
19 #include <linux/ftrace_event.h>
22 * DECLARE_EVENT_CLASS can be used to add a generic function
23 * handlers for events. That is, if all events have the same
24 * parameters and just have distinct trace points.
25 * Each tracepoint can be defined with DEFINE_EVENT and that
26 * will map the DECLARE_EVENT_CLASS to the tracepoint.
28 * TRACE_EVENT is a one to one mapping between tracepoint and template.
30 #undef TRACE_EVENT
31 #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
32 DECLARE_EVENT_CLASS(name, \
33 PARAMS(proto), \
34 PARAMS(args), \
35 PARAMS(tstruct), \
36 PARAMS(assign), \
37 PARAMS(print)); \
38 DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));
41 #undef __field
42 #define __field(type, item) type item;
44 #undef __field_ext
45 #define __field_ext(type, item, filter_type) type item;
47 #undef __array
48 #define __array(type, item, len) type item[len];
50 #undef __dynamic_array
51 #define __dynamic_array(type, item, len) u32 __data_loc_##item;
53 #undef __string
54 #define __string(item, src) __dynamic_array(char, item, -1)
56 #undef TP_STRUCT__entry
57 #define TP_STRUCT__entry(args...) args
59 #undef DECLARE_EVENT_CLASS
60 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) \
61 struct ftrace_raw_##name { \
62 struct trace_entry ent; \
63 tstruct \
64 char __data[0]; \
66 #undef DEFINE_EVENT
67 #define DEFINE_EVENT(template, name, proto, args) \
68 static struct ftrace_event_call \
69 __attribute__((__aligned__(4))) event_##name
71 #undef DEFINE_EVENT_PRINT
72 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
73 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
75 #undef __cpparg
76 #define __cpparg(arg...) arg
78 /* Callbacks are meaningless to ftrace. */
79 #undef TRACE_EVENT_FN
80 #define TRACE_EVENT_FN(name, proto, args, tstruct, \
81 assign, print, reg, unreg) \
82 TRACE_EVENT(name, __cpparg(proto), __cpparg(args), \
83 __cpparg(tstruct), __cpparg(assign), __cpparg(print)) \
85 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
89 * Stage 2 of the trace events.
91 * Include the following:
93 * struct ftrace_data_offsets_<call> {
94 * u32 <item1>;
95 * u32 <item2>;
96 * [...]
97 * };
99 * The __dynamic_array() macro will create each u32 <item>, this is
100 * to keep the offset of each array from the beginning of the event.
101 * The size of an array is also encoded, in the higher 16 bits of <item>.
104 #undef __field
105 #define __field(type, item)
107 #undef __field_ext
108 #define __field_ext(type, item, filter_type)
110 #undef __array
111 #define __array(type, item, len)
113 #undef __dynamic_array
114 #define __dynamic_array(type, item, len) u32 item;
116 #undef __string
117 #define __string(item, src) __dynamic_array(char, item, -1)
119 #undef DECLARE_EVENT_CLASS
120 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
121 struct ftrace_data_offsets_##call { \
122 tstruct; \
125 #undef DEFINE_EVENT
126 #define DEFINE_EVENT(template, name, proto, args)
128 #undef DEFINE_EVENT_PRINT
129 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
130 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
132 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
135 * Stage 3 of the trace events.
137 * Override the macros in <trace/trace_events.h> to include the following:
139 * enum print_line_t
140 * ftrace_raw_output_<call>(struct trace_iterator *iter, int flags)
142 * struct trace_seq *s = &iter->seq;
143 * struct ftrace_raw_<call> *field; <-- defined in stage 1
144 * struct trace_entry *entry;
145 * struct trace_seq *p;
146 * int ret;
148 * entry = iter->ent;
150 * if (entry->type != event_<call>.id) {
151 * WARN_ON_ONCE(1);
152 * return TRACE_TYPE_UNHANDLED;
155 * field = (typeof(field))entry;
157 * p = &get_cpu_var(ftrace_event_seq);
158 * trace_seq_init(p);
159 * ret = trace_seq_printf(s, "%s: ", <call>);
160 * if (ret)
161 * ret = trace_seq_printf(s, <TP_printk> "\n");
162 * put_cpu();
163 * if (!ret)
164 * return TRACE_TYPE_PARTIAL_LINE;
166 * return TRACE_TYPE_HANDLED;
169 * This is the method used to print the raw event to the trace
170 * output format. Note, this is not needed if the data is read
171 * in binary.
174 #undef __entry
175 #define __entry field
177 #undef TP_printk
178 #define TP_printk(fmt, args...) fmt "\n", args
180 #undef __get_dynamic_array
181 #define __get_dynamic_array(field) \
182 ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
184 #undef __get_str
185 #define __get_str(field) (char *)__get_dynamic_array(field)
187 #undef __print_flags
188 #define __print_flags(flag, delim, flag_array...) \
189 ({ \
190 static const struct trace_print_flags __flags[] = \
191 { flag_array, { -1, NULL }}; \
192 ftrace_print_flags_seq(p, delim, flag, __flags); \
195 #undef __print_symbolic
196 #define __print_symbolic(value, symbol_array...) \
197 ({ \
198 static const struct trace_print_flags symbols[] = \
199 { symbol_array, { -1, NULL }}; \
200 ftrace_print_symbols_seq(p, value, symbols); \
203 #undef __print_hex
204 #define __print_hex(buf, buf_len) ftrace_print_hex_seq(p, buf, buf_len)
206 #undef DECLARE_EVENT_CLASS
207 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
208 static notrace enum print_line_t \
209 ftrace_raw_output_id_##call(int event_id, const char *name, \
210 struct trace_iterator *iter, int flags) \
212 struct trace_seq *s = &iter->seq; \
213 struct ftrace_raw_##call *field; \
214 struct trace_entry *entry; \
215 struct trace_seq *p; \
216 int ret; \
218 entry = iter->ent; \
220 if (entry->type != event_id) { \
221 WARN_ON_ONCE(1); \
222 return TRACE_TYPE_UNHANDLED; \
225 field = (typeof(field))entry; \
227 p = &get_cpu_var(ftrace_event_seq); \
228 trace_seq_init(p); \
229 ret = trace_seq_printf(s, "%s: ", name); \
230 if (ret) \
231 ret = trace_seq_printf(s, print); \
232 put_cpu(); \
233 if (!ret) \
234 return TRACE_TYPE_PARTIAL_LINE; \
236 return TRACE_TYPE_HANDLED; \
239 #undef DEFINE_EVENT
240 #define DEFINE_EVENT(template, name, proto, args) \
241 static notrace enum print_line_t \
242 ftrace_raw_output_##name(struct trace_iterator *iter, int flags) \
244 return ftrace_raw_output_id_##template(event_##name.id, \
245 #name, iter, flags); \
248 #undef DEFINE_EVENT_PRINT
249 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
250 static notrace enum print_line_t \
251 ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
253 struct trace_seq *s = &iter->seq; \
254 struct ftrace_raw_##template *field; \
255 struct trace_entry *entry; \
256 struct trace_seq *p; \
257 int ret; \
259 entry = iter->ent; \
261 if (entry->type != event_##call.id) { \
262 WARN_ON_ONCE(1); \
263 return TRACE_TYPE_UNHANDLED; \
266 field = (typeof(field))entry; \
268 p = &get_cpu_var(ftrace_event_seq); \
269 trace_seq_init(p); \
270 ret = trace_seq_printf(s, "%s: ", #call); \
271 if (ret) \
272 ret = trace_seq_printf(s, print); \
273 put_cpu(); \
274 if (!ret) \
275 return TRACE_TYPE_PARTIAL_LINE; \
277 return TRACE_TYPE_HANDLED; \
280 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
282 #undef __field_ext
283 #define __field_ext(type, item, filter_type) \
284 ret = trace_define_field(event_call, #type, #item, \
285 offsetof(typeof(field), item), \
286 sizeof(field.item), \
287 is_signed_type(type), filter_type); \
288 if (ret) \
289 return ret;
291 #undef __field
292 #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
294 #undef __array
295 #define __array(type, item, len) \
296 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
297 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
298 offsetof(typeof(field), item), \
299 sizeof(field.item), \
300 is_signed_type(type), FILTER_OTHER); \
301 if (ret) \
302 return ret;
304 #undef __dynamic_array
305 #define __dynamic_array(type, item, len) \
306 ret = trace_define_field(event_call, "__data_loc " #type "[]", #item, \
307 offsetof(typeof(field), __data_loc_##item), \
308 sizeof(field.__data_loc_##item), \
309 is_signed_type(type), FILTER_OTHER);
311 #undef __string
312 #define __string(item, src) __dynamic_array(char, item, -1)
314 #undef DECLARE_EVENT_CLASS
315 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
316 static int notrace \
317 ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
319 struct ftrace_raw_##call field; \
320 int ret; \
322 tstruct; \
324 return ret; \
327 #undef DEFINE_EVENT
328 #define DEFINE_EVENT(template, name, proto, args)
330 #undef DEFINE_EVENT_PRINT
331 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
332 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
334 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
337 * remember the offset of each array from the beginning of the event.
340 #undef __entry
341 #define __entry entry
343 #undef __field
344 #define __field(type, item)
346 #undef __field_ext
347 #define __field_ext(type, item, filter_type)
349 #undef __array
350 #define __array(type, item, len)
352 #undef __dynamic_array
353 #define __dynamic_array(type, item, len) \
354 __data_offsets->item = __data_size + \
355 offsetof(typeof(*entry), __data); \
356 __data_offsets->item |= (len * sizeof(type)) << 16; \
357 __data_size += (len) * sizeof(type);
359 #undef __string
360 #define __string(item, src) __dynamic_array(char, item, strlen(src) + 1)
362 #undef DECLARE_EVENT_CLASS
363 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
364 static inline notrace int ftrace_get_offsets_##call( \
365 struct ftrace_data_offsets_##call *__data_offsets, proto) \
367 int __data_size = 0; \
368 struct ftrace_raw_##call __maybe_unused *entry; \
370 tstruct; \
372 return __data_size; \
375 #undef DEFINE_EVENT
376 #define DEFINE_EVENT(template, name, proto, args)
378 #undef DEFINE_EVENT_PRINT
379 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
380 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
382 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
384 #ifdef CONFIG_PERF_EVENTS
387 * Generate the functions needed for tracepoint perf_event support.
389 * NOTE: The insertion profile callback (ftrace_profile_<call>) is defined later
391 * static int ftrace_profile_enable_<call>(void)
393 * return register_trace_<call>(ftrace_profile_<call>);
396 * static void ftrace_profile_disable_<call>(void)
398 * unregister_trace_<call>(ftrace_profile_<call>);
403 #undef DECLARE_EVENT_CLASS
404 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)
406 #undef DEFINE_EVENT
407 #define DEFINE_EVENT(template, name, proto, args) \
409 static void perf_trace_##name(proto); \
411 static notrace int \
412 perf_trace_enable_##name(struct ftrace_event_call *unused) \
414 return register_trace_##name(perf_trace_##name); \
417 static notrace void \
418 perf_trace_disable_##name(struct ftrace_event_call *unused) \
420 unregister_trace_##name(perf_trace_##name); \
423 #undef DEFINE_EVENT_PRINT
424 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
425 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
427 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
429 #endif /* CONFIG_PERF_EVENTS */
432 * Stage 4 of the trace events.
434 * Override the macros in <trace/trace_events.h> to include the following:
436 * static void ftrace_event_<call>(proto)
438 * event_trace_printk(_RET_IP_, "<call>: " <fmt>);
441 * static int ftrace_reg_event_<call>(struct ftrace_event_call *unused)
443 * return register_trace_<call>(ftrace_event_<call>);
446 * static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused)
448 * unregister_trace_<call>(ftrace_event_<call>);
452 * For those macros defined with TRACE_EVENT:
454 * static struct ftrace_event_call event_<call>;
456 * static void ftrace_raw_event_<call>(proto)
458 * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
459 * struct ring_buffer_event *event;
460 * struct ftrace_raw_<call> *entry; <-- defined in stage 1
461 * struct ring_buffer *buffer;
462 * unsigned long irq_flags;
463 * int __data_size;
464 * int pc;
466 * local_save_flags(irq_flags);
467 * pc = preempt_count();
469 * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args);
471 * event = trace_current_buffer_lock_reserve(&buffer,
472 * event_<call>.id,
473 * sizeof(*entry) + __data_size,
474 * irq_flags, pc);
475 * if (!event)
476 * return;
477 * entry = ring_buffer_event_data(event);
479 * { <assign>; } <-- Here we assign the entries by the __field and
480 * __array macros.
482 * if (!filter_current_check_discard(buffer, event_call, entry, event))
483 * trace_current_buffer_unlock_commit(buffer,
484 * event, irq_flags, pc);
487 * static int ftrace_raw_reg_event_<call>(struct ftrace_event_call *unused)
489 * return register_trace_<call>(ftrace_raw_event_<call>);
492 * static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused)
494 * unregister_trace_<call>(ftrace_raw_event_<call>);
497 * static struct trace_event ftrace_event_type_<call> = {
498 * .trace = ftrace_raw_output_<call>, <-- stage 2
499 * };
501 * static const char print_fmt_<call>[] = <TP_printk>;
503 * static struct ftrace_event_call __used
504 * __attribute__((__aligned__(4)))
505 * __attribute__((section("_ftrace_events"))) event_<call> = {
506 * .name = "<call>",
507 * .system = "<system>",
508 * .raw_init = trace_event_raw_init,
509 * .regfunc = ftrace_reg_event_<call>,
510 * .unregfunc = ftrace_unreg_event_<call>,
511 * .print_fmt = print_fmt_<call>,
512 * .define_fields = ftrace_define_fields_<call>,
517 #ifdef CONFIG_PERF_EVENTS
519 #define _TRACE_PERF_INIT(call) \
520 .perf_event_enable = perf_trace_enable_##call, \
521 .perf_event_disable = perf_trace_disable_##call,
523 #else
524 #define _TRACE_PERF_INIT(call)
525 #endif /* CONFIG_PERF_EVENTS */
527 #undef __entry
528 #define __entry entry
530 #undef __field
531 #define __field(type, item)
533 #undef __array
534 #define __array(type, item, len)
536 #undef __dynamic_array
537 #define __dynamic_array(type, item, len) \
538 __entry->__data_loc_##item = __data_offsets.item;
540 #undef __string
541 #define __string(item, src) __dynamic_array(char, item, -1) \
543 #undef __assign_str
544 #define __assign_str(dst, src) \
545 strcpy(__get_str(dst), src);
547 #undef TP_fast_assign
548 #define TP_fast_assign(args...) args
550 #undef TP_perf_assign
551 #define TP_perf_assign(args...)
553 #undef DECLARE_EVENT_CLASS
554 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
556 static notrace void \
557 ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \
558 proto) \
560 struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
561 struct ring_buffer_event *event; \
562 struct ftrace_raw_##call *entry; \
563 struct ring_buffer *buffer; \
564 unsigned long irq_flags; \
565 int __data_size; \
566 int pc; \
568 local_save_flags(irq_flags); \
569 pc = preempt_count(); \
571 __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
573 event = trace_current_buffer_lock_reserve(&buffer, \
574 event_call->id, \
575 sizeof(*entry) + __data_size, \
576 irq_flags, pc); \
577 if (!event) \
578 return; \
579 entry = ring_buffer_event_data(event); \
581 tstruct \
583 { assign; } \
585 if (!filter_current_check_discard(buffer, event_call, entry, event)) \
586 trace_nowake_buffer_unlock_commit(buffer, \
587 event, irq_flags, pc); \
590 #undef DEFINE_EVENT
591 #define DEFINE_EVENT(template, call, proto, args) \
593 static notrace void ftrace_raw_event_##call(proto) \
595 ftrace_raw_event_id_##template(&event_##call, args); \
598 static notrace int \
599 ftrace_raw_reg_event_##call(struct ftrace_event_call *unused) \
601 return register_trace_##call(ftrace_raw_event_##call); \
604 static notrace void \
605 ftrace_raw_unreg_event_##call(struct ftrace_event_call *unused) \
607 unregister_trace_##call(ftrace_raw_event_##call); \
610 static struct trace_event ftrace_event_type_##call = { \
611 .trace = ftrace_raw_output_##call, \
614 #undef DEFINE_EVENT_PRINT
615 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
616 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
618 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
620 #undef __entry
621 #define __entry REC
623 #undef __print_flags
624 #undef __print_symbolic
625 #undef __get_dynamic_array
626 #undef __get_str
628 #undef TP_printk
629 #define TP_printk(fmt, args...) "\"" fmt "\", " __stringify(args)
631 #undef DECLARE_EVENT_CLASS
632 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
633 static const char print_fmt_##call[] = print;
635 #undef DEFINE_EVENT
636 #define DEFINE_EVENT(template, call, proto, args) \
638 static struct ftrace_event_call __used \
639 __attribute__((__aligned__(4))) \
640 __attribute__((section("_ftrace_events"))) event_##call = { \
641 .name = #call, \
642 .system = __stringify(TRACE_SYSTEM), \
643 .event = &ftrace_event_type_##call, \
644 .raw_init = trace_event_raw_init, \
645 .regfunc = ftrace_raw_reg_event_##call, \
646 .unregfunc = ftrace_raw_unreg_event_##call, \
647 .print_fmt = print_fmt_##template, \
648 .define_fields = ftrace_define_fields_##template, \
649 _TRACE_PERF_INIT(call) \
652 #undef DEFINE_EVENT_PRINT
653 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
655 static const char print_fmt_##call[] = print; \
657 static struct ftrace_event_call __used \
658 __attribute__((__aligned__(4))) \
659 __attribute__((section("_ftrace_events"))) event_##call = { \
660 .name = #call, \
661 .system = __stringify(TRACE_SYSTEM), \
662 .event = &ftrace_event_type_##call, \
663 .raw_init = trace_event_raw_init, \
664 .regfunc = ftrace_raw_reg_event_##call, \
665 .unregfunc = ftrace_raw_unreg_event_##call, \
666 .print_fmt = print_fmt_##call, \
667 .define_fields = ftrace_define_fields_##template, \
668 _TRACE_PERF_INIT(call) \
671 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
674 * Define the insertion callback to perf events
676 * The job is very similar to ftrace_raw_event_<call> except that we don't
677 * insert in the ring buffer but in a perf counter.
679 * static void ftrace_perf_<call>(proto)
681 * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
682 * struct ftrace_event_call *event_call = &event_<call>;
683 * extern void perf_tp_event(int, u64, u64, void *, int);
684 * struct ftrace_raw_##call *entry;
685 * struct perf_trace_buf *trace_buf;
686 * u64 __addr = 0, __count = 1;
687 * unsigned long irq_flags;
688 * struct trace_entry *ent;
689 * int __entry_size;
690 * int __data_size;
691 * int __cpu
692 * int pc;
694 * pc = preempt_count();
696 * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args);
698 * // Below we want to get the aligned size by taking into account
699 * // the u32 field that will later store the buffer size
700 * __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),
701 * sizeof(u64));
702 * __entry_size -= sizeof(u32);
704 * // Protect the non nmi buffer
705 * // This also protects the rcu read side
706 * local_irq_save(irq_flags);
707 * __cpu = smp_processor_id();
709 * if (in_nmi())
710 * trace_buf = rcu_dereference_sched(perf_trace_buf_nmi);
711 * else
712 * trace_buf = rcu_dereference_sched(perf_trace_buf);
714 * if (!trace_buf)
715 * goto end;
717 * trace_buf = per_cpu_ptr(trace_buf, __cpu);
719 * // Avoid recursion from perf that could mess up the buffer
720 * if (trace_buf->recursion++)
721 * goto end_recursion;
723 * raw_data = trace_buf->buf;
725 * // Make recursion update visible before entering perf_tp_event
726 * // so that we protect from perf recursions.
728 * barrier();
730 * //zero dead bytes from alignment to avoid stack leak to userspace:
731 * *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL;
732 * entry = (struct ftrace_raw_<call> *)raw_data;
733 * ent = &entry->ent;
734 * tracing_generic_entry_update(ent, irq_flags, pc);
735 * ent->type = event_call->id;
737 * <tstruct> <- do some jobs with dynamic arrays
739 * <assign> <- affect our values
741 * perf_tp_event(event_call->id, __addr, __count, entry,
742 * __entry_size); <- submit them to perf counter
747 #ifdef CONFIG_PERF_EVENTS
749 #undef __entry
750 #define __entry entry
752 #undef __get_dynamic_array
753 #define __get_dynamic_array(field) \
754 ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
756 #undef __get_str
757 #define __get_str(field) (char *)__get_dynamic_array(field)
759 #undef __perf_addr
760 #define __perf_addr(a) __addr = (a)
762 #undef __perf_count
763 #define __perf_count(c) __count = (c)
765 #undef DECLARE_EVENT_CLASS
766 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
767 static notrace void \
768 perf_trace_templ_##call(struct ftrace_event_call *event_call, \
769 struct pt_regs *__regs, proto) \
771 struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
772 struct ftrace_raw_##call *entry; \
773 u64 __addr = 0, __count = 1; \
774 unsigned long irq_flags; \
775 int __entry_size; \
776 int __data_size; \
777 int rctx; \
779 __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
780 __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
781 sizeof(u64)); \
782 __entry_size -= sizeof(u32); \
784 if (WARN_ONCE(__entry_size > PERF_MAX_TRACE_SIZE, \
785 "profile buffer not large enough")) \
786 return; \
787 entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \
788 __entry_size, event_call->id, &rctx, &irq_flags); \
789 if (!entry) \
790 return; \
791 tstruct \
793 { assign; } \
795 perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \
796 __count, irq_flags, __regs); \
799 #undef DEFINE_EVENT
800 #define DEFINE_EVENT(template, call, proto, args) \
801 static notrace void perf_trace_##call(proto) \
803 struct ftrace_event_call *event_call = &event_##call; \
804 struct pt_regs *__regs = &get_cpu_var(perf_trace_regs); \
806 perf_fetch_caller_regs(__regs, 1); \
808 perf_trace_templ_##template(event_call, __regs, args); \
810 put_cpu_var(perf_trace_regs); \
813 #undef DEFINE_EVENT_PRINT
814 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
815 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
817 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
818 #endif /* CONFIG_PERF_EVENTS */
820 #undef _TRACE_PROFILE_INIT