hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/include/trace/trace_events.h
....@@ -2,7 +2,8 @@
22 /*
33 * Stage 1 of the trace events.
44 *
5
- * Override the macros in <trace/trace_events.h> to include the following:
5
+ * Override the macros in the event tracepoint header <trace/events/XXX.h>
6
+ * to include the following:
67 *
78 * struct trace_event_raw_<call> {
89 * struct trace_entry ent;
....@@ -44,7 +45,7 @@
4445 .eval_value = a \
4546 }; \
4647 static struct trace_eval_map __used \
47
- __attribute__((section("_ftrace_eval_map"))) \
48
+ __section("_ftrace_eval_map") \
4849 *TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
4950
5051 #undef TRACE_DEFINE_SIZEOF
....@@ -57,7 +58,7 @@
5758 .eval_value = sizeof(a) \
5859 }; \
5960 static struct trace_eval_map __used \
60
- __attribute__((section("_ftrace_eval_map"))) \
61
+ __section("_ftrace_eval_map") \
6162 *TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
6263
6364 /*
....@@ -209,8 +210,7 @@
209210 #define DEFINE_EVENT(template, name, proto, args)
210211
211212 #undef DEFINE_EVENT_PRINT
212
-#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
213
- DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
213
+#define DEFINE_EVENT_PRINT(template, name, proto, args, print)
214214
215215 #undef TRACE_EVENT_FLAGS
216216 #define TRACE_EVENT_FLAGS(event, flag)
....@@ -223,7 +223,8 @@
223223 /*
224224 * Stage 3 of the trace events.
225225 *
226
- * Override the macros in <trace/trace_events.h> to include the following:
226
+ * Override the macros in the event tracepoint header <trace/events/XXX.h>
227
+ * to include the following:
227228 *
228229 * enum print_line_t
229230 * trace_raw_output_<call>(struct trace_iterator *iter, int flags)
....@@ -340,6 +341,12 @@
340341 trace_print_array_seq(p, array, count, el_size); \
341342 })
342343
344
+#undef __print_hex_dump
345
+#define __print_hex_dump(prefix_str, prefix_type, \
346
+ rowsize, groupsize, buf, len, ascii) \
347
+ trace_print_hex_dump_seq(p, prefix_str, prefix_type, \
348
+ rowsize, groupsize, buf, len, ascii)
349
+
343350 #undef DECLARE_EVENT_CLASS
344351 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
345352 static notrace enum print_line_t \
....@@ -393,23 +400,19 @@
393400
394401 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
395402
403
+#define ALIGN_STRUCTFIELD(type) ((int)(__alignof__(struct {type b;})))
404
+
396405 #undef __field_ext
397
-#define __field_ext(type, item, filter_type) \
398
- ret = trace_define_field(event_call, #type, #item, \
399
- offsetof(typeof(field), item), \
400
- sizeof(field.item), \
401
- is_signed_type(type), filter_type); \
402
- if (ret) \
403
- return ret;
406
+#define __field_ext(_type, _item, _filter_type) { \
407
+ .type = #_type, .name = #_item, \
408
+ .size = sizeof(_type), .align = ALIGN_STRUCTFIELD(_type), \
409
+ .is_signed = is_signed_type(_type), .filter_type = _filter_type },
404410
405411 #undef __field_struct_ext
406
-#define __field_struct_ext(type, item, filter_type) \
407
- ret = trace_define_field(event_call, #type, #item, \
408
- offsetof(typeof(field), item), \
409
- sizeof(field.item), \
410
- 0, filter_type); \
411
- if (ret) \
412
- return ret;
412
+#define __field_struct_ext(_type, _item, _filter_type) { \
413
+ .type = #_type, .name = #_item, \
414
+ .size = sizeof(_type), .align = ALIGN_STRUCTFIELD(_type), \
415
+ 0, .filter_type = _filter_type },
413416
414417 #undef __field
415418 #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
....@@ -418,25 +421,16 @@
418421 #define __field_struct(type, item) __field_struct_ext(type, item, FILTER_OTHER)
419422
420423 #undef __array
421
-#define __array(type, item, len) \
422
- do { \
423
- char *type_str = #type"["__stringify(len)"]"; \
424
- BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
425
- BUILD_BUG_ON(len <= 0); \
426
- ret = trace_define_field(event_call, type_str, #item, \
427
- offsetof(typeof(field), item), \
428
- sizeof(field.item), \
429
- is_signed_type(type), FILTER_OTHER); \
430
- if (ret) \
431
- return ret; \
432
- } while (0);
424
+#define __array(_type, _item, _len) { \
425
+ .type = #_type"["__stringify(_len)"]", .name = #_item, \
426
+ .size = sizeof(_type[_len]), .align = ALIGN_STRUCTFIELD(_type), \
427
+ .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER },
433428
434429 #undef __dynamic_array
435
-#define __dynamic_array(type, item, len) \
436
- ret = trace_define_field(event_call, "__data_loc " #type "[]", #item, \
437
- offsetof(typeof(field), __data_loc_##item), \
438
- sizeof(field.__data_loc_##item), \
439
- is_signed_type(type), FILTER_OTHER);
430
+#define __dynamic_array(_type, _item, _len) { \
431
+ .type = "__data_loc " #_type "[]", .name = #_item, \
432
+ .size = 4, .align = 4, \
433
+ .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER },
440434
441435 #undef __string
442436 #define __string(item, src) __dynamic_array(char, item, -1)
....@@ -446,23 +440,12 @@
446440
447441 #undef DECLARE_EVENT_CLASS
448442 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
449
-static int notrace __init \
450
-trace_event_define_fields_##call(struct trace_event_call *event_call) \
451
-{ \
452
- struct trace_event_raw_##call field; \
453
- int ret; \
454
- \
455
- tstruct; \
456
- \
457
- return ret; \
458
-}
459
-
460
-#undef DEFINE_EVENT
461
-#define DEFINE_EVENT(template, name, proto, args)
443
+static struct trace_event_fields trace_event_fields_##call[] = { \
444
+ tstruct \
445
+ {} };
462446
463447 #undef DEFINE_EVENT_PRINT
464
-#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
465
- DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
448
+#define DEFINE_EVENT_PRINT(template, name, proto, args, print)
466449
467450 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
468451
....@@ -537,19 +520,13 @@
537520 return __data_size; \
538521 }
539522
540
-#undef DEFINE_EVENT
541
-#define DEFINE_EVENT(template, name, proto, args)
542
-
543
-#undef DEFINE_EVENT_PRINT
544
-#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
545
- DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
546
-
547523 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
548524
549525 /*
550526 * Stage 4 of the trace events.
551527 *
552
- * Override the macros in <trace/trace_events.h> to include the following:
528
+ * Override the macros in the event tracepoint header <trace/events/XXX.h>
529
+ * to include the following:
553530 *
554531 * For those macros defined with TRACE_EVENT:
555532 *
....@@ -564,7 +541,7 @@
564541 * enum event_trigger_type __tt = ETT_NONE;
565542 * struct ring_buffer_event *event;
566543 * struct trace_event_raw_<call> *entry; <-- defined in stage 1
567
- * struct ring_buffer *buffer;
544
+ * struct trace_buffer *buffer;
568545 * unsigned long irq_flags;
569546 * int __data_size;
570547 * int pc;
....@@ -613,7 +590,7 @@
613590 *
614591 * static struct trace_event_class __used event_class_<template> = {
615592 * .system = "<system>",
616
- * .define_fields = trace_event_define_fields_<call>,
593
+ * .fields_array = trace_event_fields_<call>,
617594 * .fields = LIST_HEAD_INIT(event_class_##call.fields),
618595 * .raw_init = trace_event_raw_init,
619596 * .probe = trace_event_raw_event_##call,
....@@ -632,7 +609,7 @@
632609 * // its only safe to use pointers when doing linker tricks to
633610 * // create an array.
634611 * static struct trace_event_call __used
635
- * __attribute__((section("_ftrace_events"))) *__event_<call> = &event_<call>;
612
+ * __section("_ftrace_events") *__event_<call> = &event_<call>;
636613 *
637614 */
638615
....@@ -734,9 +711,6 @@
734711 check_trace_callback_type_##call(trace_event_raw_event_##template); \
735712 }
736713
737
-#undef DEFINE_EVENT_PRINT
738
-#define DEFINE_EVENT_PRINT(template, name, proto, args, print)
739
-
740714 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
741715
742716 #undef __entry
....@@ -751,6 +725,7 @@
751725 #undef __get_str
752726 #undef __get_bitmask
753727 #undef __print_array
728
+#undef __print_hex_dump
754729
755730 #undef TP_printk
756731 #define TP_printk(fmt, args...) "\"" fmt "\", " __stringify(args)
....@@ -761,7 +736,7 @@
761736 static char print_fmt_##call[] = print; \
762737 static struct trace_event_class __used __refdata event_class_##call = { \
763738 .system = TRACE_SYSTEM_STRING, \
764
- .define_fields = trace_event_define_fields_##call, \
739
+ .fields_array = trace_event_fields_##call, \
765740 .fields = LIST_HEAD_INIT(event_class_##call.fields),\
766741 .raw_init = trace_event_raw_init, \
767742 .probe = trace_event_raw_event_##call, \
....@@ -782,7 +757,7 @@
782757 .flags = TRACE_EVENT_FL_TRACEPOINT, \
783758 }; \
784759 static struct trace_event_call __used \
785
-__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
760
+__section("_ftrace_events") *__event_##call = &event_##call
786761
787762 #undef DEFINE_EVENT_PRINT
788763 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
....@@ -799,6 +774,6 @@
799774 .flags = TRACE_EVENT_FL_TRACEPOINT, \
800775 }; \
801776 static struct trace_event_call __used \
802
-__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
777
+__section("_ftrace_events") *__event_##call = &event_##call
803778
804779 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)