perf.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #undef TRACE_SYSTEM_VAR
  2. #ifdef CONFIG_PERF_EVENTS
  3. #undef __entry
  4. #define __entry entry
  5. #undef __get_dynamic_array
  6. #define __get_dynamic_array(field) \
  7. ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
  8. #undef __get_dynamic_array_len
  9. #define __get_dynamic_array_len(field) \
  10. ((__entry->__data_loc_##field >> 16) & 0xffff)
  11. #undef __get_str
  12. #define __get_str(field) (char *)__get_dynamic_array(field)
  13. #undef __get_bitmask
  14. #define __get_bitmask(field) (char *)__get_dynamic_array(field)
  15. #undef __perf_addr
  16. #define __perf_addr(a) (__addr = (a))
  17. #undef __perf_count
  18. #define __perf_count(c) (__count = (c))
  19. #undef __perf_task
  20. #define __perf_task(t) (__task = (t))
  21. #undef DECLARE_EVENT_CLASS
  22. #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
  23. static notrace void \
  24. perf_trace_##call(void *__data, proto) \
  25. { \
  26. struct trace_event_call *event_call = __data; \
  27. struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
  28. struct trace_event_raw_##call *entry; \
  29. struct pt_regs *__regs; \
  30. u64 __addr = 0, __count = 1; \
  31. struct task_struct *__task = NULL; \
  32. struct hlist_head *head; \
  33. int __entry_size; \
  34. int __data_size; \
  35. int rctx; \
  36. \
  37. __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
  38. \
  39. head = this_cpu_ptr(event_call->perf_events); \
  40. if (__builtin_constant_p(!__task) && !__task && \
  41. hlist_empty(head)) \
  42. return; \
  43. \
  44. __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
  45. sizeof(u64)); \
  46. __entry_size -= sizeof(u32); \
  47. \
  48. entry = perf_trace_buf_prepare(__entry_size, \
  49. event_call->event.type, &__regs, &rctx); \
  50. if (!entry) \
  51. return; \
  52. \
  53. perf_fetch_caller_regs(__regs); \
  54. \
  55. tstruct \
  56. \
  57. { assign; } \
  58. \
  59. perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \
  60. __count, __regs, head, __task); \
  61. }
  62. /*
  63. * This part is compiled out, it is only here as a build time check
  64. * to make sure that if the tracepoint handling changes, the
  65. * perf probe will fail to compile unless it too is updated.
  66. */
  67. #undef DEFINE_EVENT
  68. #define DEFINE_EVENT(template, call, proto, args) \
  69. static inline void perf_test_probe_##call(void) \
  70. { \
  71. check_trace_callback_type_##call(perf_trace_##template); \
  72. }
  73. #undef DEFINE_EVENT_PRINT
  74. #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
  75. DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
  76. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  77. #endif /* CONFIG_PERF_EVENTS */