ftrace.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. /*
  2. * Stage 1 of the trace events.
  3. *
  4. * Override the macros in <trace/trace_events.h> to include the following:
  5. *
  6. * struct ftrace_raw_<call> {
  7. * struct trace_entry ent;
  8. * <type> <item>;
  9. * <type2> <item2>[<len>];
  10. * [...]
  11. * };
  12. *
  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.
  17. */
  18. #include <linux/ftrace_event.h>
  19. #undef __field
  20. #define __field(type, item) type item;
  21. #undef __array
  22. #define __array(type, item, len) type item[len];
  23. #undef __dynamic_array
  24. #define __dynamic_array(type, item, len) unsigned short __data_loc_##item;
  25. #undef __string
  26. #define __string(item, src) __dynamic_array(char, item, -1)
  27. #undef TP_STRUCT__entry
  28. #define TP_STRUCT__entry(args...) args
  29. #undef TRACE_EVENT
  30. #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
  31. struct ftrace_raw_##name { \
  32. struct trace_entry ent; \
  33. tstruct \
  34. char __data[0]; \
  35. }; \
  36. static struct ftrace_event_call event_##name
  37. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  38. /*
  39. * Stage 2 of the trace events.
  40. *
  41. * Include the following:
  42. *
  43. * struct ftrace_data_offsets_<call> {
  44. * int <item1>;
  45. * int <item2>;
  46. * [...]
  47. * };
  48. *
  49. * The __dynamic_array() macro will create each int <item>, this is
  50. * to keep the offset of each array from the beginning of the event.
  51. */
  52. #undef __field
  53. #define __field(type, item);
  54. #undef __array
  55. #define __array(type, item, len)
  56. #undef __dynamic_array
  57. #define __dynamic_array(type, item, len) int item;
  58. #undef __string
  59. #define __string(item, src) __dynamic_array(char, item, -1)
  60. #undef TRACE_EVENT
  61. #define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
  62. struct ftrace_data_offsets_##call { \
  63. tstruct; \
  64. };
  65. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  66. /*
  67. * Setup the showing format of trace point.
  68. *
  69. * int
  70. * ftrace_format_##call(struct trace_seq *s)
  71. * {
  72. * struct ftrace_raw_##call field;
  73. * int ret;
  74. *
  75. * ret = trace_seq_printf(s, #type " " #item ";"
  76. * " offset:%u; size:%u;\n",
  77. * offsetof(struct ftrace_raw_##call, item),
  78. * sizeof(field.type));
  79. *
  80. * }
  81. */
  82. #undef TP_STRUCT__entry
  83. #define TP_STRUCT__entry(args...) args
  84. #undef __field
  85. #define __field(type, item) \
  86. ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
  87. "offset:%u;\tsize:%u;\n", \
  88. (unsigned int)offsetof(typeof(field), item), \
  89. (unsigned int)sizeof(field.item)); \
  90. if (!ret) \
  91. return 0;
  92. #undef __array
  93. #define __array(type, item, len) \
  94. ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
  95. "offset:%u;\tsize:%u;\n", \
  96. (unsigned int)offsetof(typeof(field), item), \
  97. (unsigned int)sizeof(field.item)); \
  98. if (!ret) \
  99. return 0;
  100. #undef __dynamic_array
  101. #define __dynamic_array(type, item, len) \
  102. ret = trace_seq_printf(s, "\tfield:__data_loc " #item ";\t" \
  103. "offset:%u;\tsize:%u;\n", \
  104. (unsigned int)offsetof(typeof(field), \
  105. __data_loc_##item), \
  106. (unsigned int)sizeof(field.__data_loc_##item)); \
  107. if (!ret) \
  108. return 0;
  109. #undef __string
  110. #define __string(item, src) __dynamic_array(char, item, -1)
  111. #undef __entry
  112. #define __entry REC
  113. #undef __print_symbolic
  114. #undef __get_dynamic_array
  115. #undef __get_str
  116. #undef TP_printk
  117. #define TP_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)
  118. #undef TP_fast_assign
  119. #define TP_fast_assign(args...) args
  120. #undef TP_perf_assign
  121. #define TP_perf_assign(args...)
  122. #undef TRACE_EVENT
  123. #define TRACE_EVENT(call, proto, args, tstruct, func, print) \
  124. static int \
  125. ftrace_format_##call(struct trace_seq *s) \
  126. { \
  127. struct ftrace_raw_##call field __attribute__((unused)); \
  128. int ret = 0; \
  129. \
  130. tstruct; \
  131. \
  132. trace_seq_printf(s, "\nprint fmt: " print); \
  133. \
  134. return ret; \
  135. }
  136. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  137. /*
  138. * Stage 3 of the trace events.
  139. *
  140. * Override the macros in <trace/trace_events.h> to include the following:
  141. *
  142. * enum print_line_t
  143. * ftrace_raw_output_<call>(struct trace_iterator *iter, int flags)
  144. * {
  145. * struct trace_seq *s = &iter->seq;
  146. * struct ftrace_raw_<call> *field; <-- defined in stage 1
  147. * struct trace_entry *entry;
  148. * struct trace_seq *p;
  149. * int ret;
  150. *
  151. * entry = iter->ent;
  152. *
  153. * if (entry->type != event_<call>.id) {
  154. * WARN_ON_ONCE(1);
  155. * return TRACE_TYPE_UNHANDLED;
  156. * }
  157. *
  158. * field = (typeof(field))entry;
  159. *
  160. * p = get_cpu_var(ftrace_event_seq);
  161. * trace_seq_init(p);
  162. * ret = trace_seq_printf(s, <TP_printk> "\n");
  163. * put_cpu();
  164. * if (!ret)
  165. * return TRACE_TYPE_PARTIAL_LINE;
  166. *
  167. * return TRACE_TYPE_HANDLED;
  168. * }
  169. *
  170. * This is the method used to print the raw event to the trace
  171. * output format. Note, this is not needed if the data is read
  172. * in binary.
  173. */
  174. #undef __entry
  175. #define __entry field
  176. #undef TP_printk
  177. #define TP_printk(fmt, args...) fmt "\n", args
  178. #undef __get_dynamic_array
  179. #define __get_dynamic_array(field) \
  180. ((void *)__entry + __entry->__data_loc_##field)
  181. #undef __get_str
  182. #define __get_str(field) (char *)__get_dynamic_array(field)
  183. #undef __print_flags
  184. #define __print_flags(flag, delim, flag_array...) \
  185. ({ \
  186. static const struct trace_print_flags flags[] = \
  187. { flag_array, { -1, NULL }}; \
  188. ftrace_print_flags_seq(p, delim, flag, flags); \
  189. })
  190. #undef __print_symbolic
  191. #define __print_symbolic(value, symbol_array...) \
  192. ({ \
  193. static const struct trace_print_flags symbols[] = \
  194. { symbol_array, { -1, NULL }}; \
  195. ftrace_print_symbols_seq(p, value, symbols); \
  196. })
  197. #undef TRACE_EVENT
  198. #define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
  199. enum print_line_t \
  200. ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
  201. { \
  202. struct trace_seq *s = &iter->seq; \
  203. struct ftrace_raw_##call *field; \
  204. struct trace_entry *entry; \
  205. struct trace_seq *p; \
  206. int ret; \
  207. \
  208. entry = iter->ent; \
  209. \
  210. if (entry->type != event_##call.id) { \
  211. WARN_ON_ONCE(1); \
  212. return TRACE_TYPE_UNHANDLED; \
  213. } \
  214. \
  215. field = (typeof(field))entry; \
  216. \
  217. p = &get_cpu_var(ftrace_event_seq); \
  218. trace_seq_init(p); \
  219. ret = trace_seq_printf(s, #call ": " print); \
  220. put_cpu(); \
  221. if (!ret) \
  222. return TRACE_TYPE_PARTIAL_LINE; \
  223. \
  224. return TRACE_TYPE_HANDLED; \
  225. }
  226. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  227. #undef __field
  228. #define __field(type, item) \
  229. ret = trace_define_field(event_call, #type, #item, \
  230. offsetof(typeof(field), item), \
  231. sizeof(field.item), is_signed_type(type)); \
  232. if (ret) \
  233. return ret;
  234. #undef __array
  235. #define __array(type, item, len) \
  236. BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
  237. ret = trace_define_field(event_call, #type "[" #len "]", #item, \
  238. offsetof(typeof(field), item), \
  239. sizeof(field.item), 0); \
  240. if (ret) \
  241. return ret;
  242. #undef __dynamic_array
  243. #define __dynamic_array(type, item, len) \
  244. ret = trace_define_field(event_call, "__data_loc" "[" #type "]", #item,\
  245. offsetof(typeof(field), __data_loc_##item), \
  246. sizeof(field.__data_loc_##item), 0);
  247. #undef __string
  248. #define __string(item, src) __dynamic_array(char, item, -1)
  249. #undef TRACE_EVENT
  250. #define TRACE_EVENT(call, proto, args, tstruct, func, print) \
  251. int \
  252. ftrace_define_fields_##call(void) \
  253. { \
  254. struct ftrace_raw_##call field; \
  255. struct ftrace_event_call *event_call = &event_##call; \
  256. int ret; \
  257. \
  258. __common_field(int, type, 1); \
  259. __common_field(unsigned char, flags, 0); \
  260. __common_field(unsigned char, preempt_count, 0); \
  261. __common_field(int, pid, 1); \
  262. __common_field(int, tgid, 1); \
  263. \
  264. tstruct; \
  265. \
  266. return ret; \
  267. }
  268. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  269. /*
  270. * remember the offset of each array from the beginning of the event.
  271. */
  272. #undef __entry
  273. #define __entry entry
  274. #undef __field
  275. #define __field(type, item)
  276. #undef __array
  277. #define __array(type, item, len)
  278. #undef __dynamic_array
  279. #define __dynamic_array(type, item, len) \
  280. __data_offsets->item = __data_size + \
  281. offsetof(typeof(*entry), __data); \
  282. __data_size += (len) * sizeof(type);
  283. #undef __string
  284. #define __string(item, src) __dynamic_array(char, item, strlen(src) + 1) \
  285. #undef TRACE_EVENT
  286. #define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
  287. static inline int ftrace_get_offsets_##call( \
  288. struct ftrace_data_offsets_##call *__data_offsets, proto) \
  289. { \
  290. int __data_size = 0; \
  291. struct ftrace_raw_##call __maybe_unused *entry; \
  292. \
  293. tstruct; \
  294. \
  295. return __data_size; \
  296. }
  297. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  298. #ifdef CONFIG_EVENT_PROFILE
  299. /*
  300. * Generate the functions needed for tracepoint perf_counter support.
  301. *
  302. * NOTE: The insertion profile callback (ftrace_profile_<call>) is defined later
  303. *
  304. * static int ftrace_profile_enable_<call>(struct ftrace_event_call *event_call)
  305. * {
  306. * int ret = 0;
  307. *
  308. * if (!atomic_inc_return(&event_call->profile_count))
  309. * ret = register_trace_<call>(ftrace_profile_<call>);
  310. *
  311. * return ret;
  312. * }
  313. *
  314. * static void ftrace_profile_disable_<call>(struct ftrace_event_call *event_call)
  315. * {
  316. * if (atomic_add_negative(-1, &event->call->profile_count))
  317. * unregister_trace_<call>(ftrace_profile_<call>);
  318. * }
  319. *
  320. */
  321. #undef TRACE_EVENT
  322. #define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
  323. \
  324. static void ftrace_profile_##call(proto); \
  325. \
  326. static int ftrace_profile_enable_##call(struct ftrace_event_call *event_call) \
  327. { \
  328. int ret = 0; \
  329. \
  330. if (!atomic_inc_return(&event_call->profile_count)) \
  331. ret = register_trace_##call(ftrace_profile_##call); \
  332. \
  333. return ret; \
  334. } \
  335. \
  336. static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\
  337. { \
  338. if (atomic_add_negative(-1, &event_call->profile_count)) \
  339. unregister_trace_##call(ftrace_profile_##call); \
  340. }
  341. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  342. #endif
  343. /*
  344. * Stage 4 of the trace events.
  345. *
  346. * Override the macros in <trace/trace_events.h> to include the following:
  347. *
  348. * static void ftrace_event_<call>(proto)
  349. * {
  350. * event_trace_printk(_RET_IP_, "<call>: " <fmt>);
  351. * }
  352. *
  353. * static int ftrace_reg_event_<call>(void)
  354. * {
  355. * int ret;
  356. *
  357. * ret = register_trace_<call>(ftrace_event_<call>);
  358. * if (!ret)
  359. * pr_info("event trace: Could not activate trace point "
  360. * "probe to <call>");
  361. * return ret;
  362. * }
  363. *
  364. * static void ftrace_unreg_event_<call>(void)
  365. * {
  366. * unregister_trace_<call>(ftrace_event_<call>);
  367. * }
  368. *
  369. *
  370. * For those macros defined with TRACE_EVENT:
  371. *
  372. * static struct ftrace_event_call event_<call>;
  373. *
  374. * static void ftrace_raw_event_<call>(proto)
  375. * {
  376. * struct ring_buffer_event *event;
  377. * struct ftrace_raw_<call> *entry; <-- defined in stage 1
  378. * unsigned long irq_flags;
  379. * int pc;
  380. *
  381. * local_save_flags(irq_flags);
  382. * pc = preempt_count();
  383. *
  384. * event = trace_current_buffer_lock_reserve(event_<call>.id,
  385. * sizeof(struct ftrace_raw_<call>),
  386. * irq_flags, pc);
  387. * if (!event)
  388. * return;
  389. * entry = ring_buffer_event_data(event);
  390. *
  391. * <assign>; <-- Here we assign the entries by the __field and
  392. * __array macros.
  393. *
  394. * trace_current_buffer_unlock_commit(event, irq_flags, pc);
  395. * }
  396. *
  397. * static int ftrace_raw_reg_event_<call>(void)
  398. * {
  399. * int ret;
  400. *
  401. * ret = register_trace_<call>(ftrace_raw_event_<call>);
  402. * if (!ret)
  403. * pr_info("event trace: Could not activate trace point "
  404. * "probe to <call>");
  405. * return ret;
  406. * }
  407. *
  408. * static void ftrace_unreg_event_<call>(void)
  409. * {
  410. * unregister_trace_<call>(ftrace_raw_event_<call>);
  411. * }
  412. *
  413. * static struct trace_event ftrace_event_type_<call> = {
  414. * .trace = ftrace_raw_output_<call>, <-- stage 2
  415. * };
  416. *
  417. * static int ftrace_raw_init_event_<call>(void)
  418. * {
  419. * int id;
  420. *
  421. * id = register_ftrace_event(&ftrace_event_type_<call>);
  422. * if (!id)
  423. * return -ENODEV;
  424. * event_<call>.id = id;
  425. * return 0;
  426. * }
  427. *
  428. * static struct ftrace_event_call __used
  429. * __attribute__((__aligned__(4)))
  430. * __attribute__((section("_ftrace_events"))) event_<call> = {
  431. * .name = "<call>",
  432. * .system = "<system>",
  433. * .raw_init = ftrace_raw_init_event_<call>,
  434. * .regfunc = ftrace_reg_event_<call>,
  435. * .unregfunc = ftrace_unreg_event_<call>,
  436. * .show_format = ftrace_format_<call>,
  437. * }
  438. *
  439. */
  440. #undef TP_FMT
  441. #define TP_FMT(fmt, args...) fmt "\n", ##args
  442. #ifdef CONFIG_EVENT_PROFILE
  443. #define _TRACE_PROFILE_INIT(call) \
  444. .profile_count = ATOMIC_INIT(-1), \
  445. .profile_enable = ftrace_profile_enable_##call, \
  446. .profile_disable = ftrace_profile_disable_##call,
  447. #else
  448. #define _TRACE_PROFILE_INIT(call)
  449. #endif
  450. #undef __entry
  451. #define __entry entry
  452. #undef __field
  453. #define __field(type, item)
  454. #undef __array
  455. #define __array(type, item, len)
  456. #undef __dynamic_array
  457. #define __dynamic_array(type, item, len) \
  458. __entry->__data_loc_##item = __data_offsets.item;
  459. #undef __string
  460. #define __string(item, src) __dynamic_array(char, item, -1) \
  461. #undef __assign_str
  462. #define __assign_str(dst, src) \
  463. strcpy(__get_str(dst), src);
  464. #undef TRACE_EVENT
  465. #define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
  466. \
  467. static struct ftrace_event_call event_##call; \
  468. \
  469. static void ftrace_raw_event_##call(proto) \
  470. { \
  471. struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
  472. struct ftrace_event_call *event_call = &event_##call; \
  473. struct ring_buffer_event *event; \
  474. struct ftrace_raw_##call *entry; \
  475. unsigned long irq_flags; \
  476. int __data_size; \
  477. int pc; \
  478. \
  479. local_save_flags(irq_flags); \
  480. pc = preempt_count(); \
  481. \
  482. __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
  483. \
  484. event = trace_current_buffer_lock_reserve(event_##call.id, \
  485. sizeof(*entry) + __data_size, \
  486. irq_flags, pc); \
  487. if (!event) \
  488. return; \
  489. entry = ring_buffer_event_data(event); \
  490. \
  491. \
  492. tstruct \
  493. \
  494. { assign; } \
  495. \
  496. if (!filter_current_check_discard(event_call, entry, event)) \
  497. trace_nowake_buffer_unlock_commit(event, irq_flags, pc); \
  498. } \
  499. \
  500. static int ftrace_raw_reg_event_##call(void) \
  501. { \
  502. int ret; \
  503. \
  504. ret = register_trace_##call(ftrace_raw_event_##call); \
  505. if (ret) \
  506. pr_info("event trace: Could not activate trace point " \
  507. "probe to " #call "\n"); \
  508. return ret; \
  509. } \
  510. \
  511. static void ftrace_raw_unreg_event_##call(void) \
  512. { \
  513. unregister_trace_##call(ftrace_raw_event_##call); \
  514. } \
  515. \
  516. static struct trace_event ftrace_event_type_##call = { \
  517. .trace = ftrace_raw_output_##call, \
  518. }; \
  519. \
  520. static int ftrace_raw_init_event_##call(void) \
  521. { \
  522. int id; \
  523. \
  524. id = register_ftrace_event(&ftrace_event_type_##call); \
  525. if (!id) \
  526. return -ENODEV; \
  527. event_##call.id = id; \
  528. INIT_LIST_HEAD(&event_##call.fields); \
  529. init_preds(&event_##call); \
  530. return 0; \
  531. } \
  532. \
  533. static struct ftrace_event_call __used \
  534. __attribute__((__aligned__(4))) \
  535. __attribute__((section("_ftrace_events"))) event_##call = { \
  536. .name = #call, \
  537. .system = __stringify(TRACE_SYSTEM), \
  538. .event = &ftrace_event_type_##call, \
  539. .raw_init = ftrace_raw_init_event_##call, \
  540. .regfunc = ftrace_raw_reg_event_##call, \
  541. .unregfunc = ftrace_raw_unreg_event_##call, \
  542. .show_format = ftrace_format_##call, \
  543. .define_fields = ftrace_define_fields_##call, \
  544. _TRACE_PROFILE_INIT(call) \
  545. }
  546. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  547. /*
  548. * Define the insertion callback to profile events
  549. *
  550. * The job is very similar to ftrace_raw_event_<call> except that we don't
  551. * insert in the ring buffer but in a perf counter.
  552. *
  553. * static void ftrace_profile_<call>(proto)
  554. * {
  555. * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
  556. * struct ftrace_event_call *event_call = &event_<call>;
  557. * extern void perf_tpcounter_event(int, u64, u64, void *, int);
  558. * struct ftrace_raw_##call *entry;
  559. * u64 __addr = 0, __count = 1;
  560. * unsigned long irq_flags;
  561. * int __entry_size;
  562. * int __data_size;
  563. * int pc;
  564. *
  565. * local_save_flags(irq_flags);
  566. * pc = preempt_count();
  567. *
  568. * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args);
  569. * __entry_size = __data_size + sizeof(*entry);
  570. *
  571. * do {
  572. * char raw_data[__entry_size]; <- allocate our sample in the stack
  573. * struct trace_entry *ent;
  574. *
  575. * entry = (struct ftrace_raw_<call> *)raw_data;
  576. * ent = &entry->ent;
  577. * tracing_generic_entry_update(ent, irq_flags, pc);
  578. * ent->type = event_call->id;
  579. *
  580. * <tstruct> <- do some jobs with dynamic arrays
  581. *
  582. * <assign> <- affect our values
  583. *
  584. * perf_tpcounter_event(event_call->id, __addr, __count, entry,
  585. * __entry_size); <- submit them to perf counter
  586. * } while (0);
  587. *
  588. * }
  589. */
  590. #ifdef CONFIG_EVENT_PROFILE
  591. #undef __perf_addr
  592. #define __perf_addr(a) __addr = (a)
  593. #undef __perf_count
  594. #define __perf_count(c) __count = (c)
  595. #undef TRACE_EVENT
  596. #define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
  597. static void ftrace_profile_##call(proto) \
  598. { \
  599. struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
  600. struct ftrace_event_call *event_call = &event_##call; \
  601. extern void perf_tpcounter_event(int, u64, u64, void *, int); \
  602. struct ftrace_raw_##call *entry; \
  603. u64 __addr = 0, __count = 1; \
  604. unsigned long irq_flags; \
  605. int __entry_size; \
  606. int __data_size; \
  607. int pc; \
  608. \
  609. local_save_flags(irq_flags); \
  610. pc = preempt_count(); \
  611. \
  612. __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
  613. __entry_size = ALIGN(__data_size + sizeof(*entry), sizeof(u64));\
  614. \
  615. do { \
  616. char raw_data[__entry_size]; \
  617. struct trace_entry *ent; \
  618. \
  619. entry = (struct ftrace_raw_##call *)raw_data; \
  620. ent = &entry->ent; \
  621. tracing_generic_entry_update(ent, irq_flags, pc); \
  622. ent->type = event_call->id; \
  623. \
  624. tstruct \
  625. \
  626. { assign; } \
  627. \
  628. perf_tpcounter_event(event_call->id, __addr, __count, entry,\
  629. __entry_size); \
  630. } while (0); \
  631. \
  632. }
  633. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  634. #endif /* CONFIG_EVENT_PROFILE */
  635. #undef _TRACE_PROFILE_INIT