perf.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_count
  16. #define __perf_count(c) (__count = (c))
  17. #undef __perf_task
  18. #define __perf_task(t) (__task = (t))
  19. #undef DECLARE_EVENT_CLASS
  20. #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
  21. static notrace void \
  22. perf_trace_##call(void *__data, proto) \
  23. { \
  24. struct trace_event_call *event_call = __data; \
  25. struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
  26. struct trace_event_raw_##call *entry; \
  27. struct bpf_prog *prog = event_call->prog; \
  28. struct pt_regs *__regs; \
  29. u64 __count = 1; \
  30. struct task_struct *__task = NULL; \
  31. struct hlist_head *head; \
  32. int __entry_size; \
  33. int __data_size; \
  34. int rctx; \
  35. \
  36. __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
  37. \
  38. head = this_cpu_ptr(event_call->perf_events); \
  39. if (!prog && __builtin_constant_p(!__task) && !__task && \
  40. hlist_empty(head)) \
  41. return; \
  42. \
  43. __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
  44. sizeof(u64)); \
  45. __entry_size -= sizeof(u32); \
  46. \
  47. entry = perf_trace_buf_alloc(__entry_size, &__regs, &rctx); \
  48. if (!entry) \
  49. return; \
  50. \
  51. perf_fetch_caller_regs(__regs); \
  52. \
  53. tstruct \
  54. \
  55. { assign; } \
  56. \
  57. perf_trace_run_bpf_submit(entry, __entry_size, rctx, \
  58. event_call, __count, __regs, \
  59. head, __task); \
  60. }
  61. /*
  62. * This part is compiled out, it is only here as a build time check
  63. * to make sure that if the tracepoint handling changes, the
  64. * perf probe will fail to compile unless it too is updated.
  65. */
  66. #undef DEFINE_EVENT
  67. #define DEFINE_EVENT(template, call, proto, args) \
  68. static inline void perf_test_probe_##call(void) \
  69. { \
  70. check_trace_callback_type_##call(perf_trace_##template); \
  71. }
  72. #undef DEFINE_EVENT_PRINT
  73. #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
  74. DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
  75. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  76. #endif /* CONFIG_PERF_EVENTS */