trace-events-sample.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * If TRACE_SYSTEM is defined, that will be the directory created
  4. * in the ftrace directory under /sys/kernel/tracing/events/<system>
  5. *
  6. * The define_trace.h below will also look for a file name of
  7. * TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here.
  8. * In this case, it would look for sample-trace.h
  9. *
  10. * If the header name will be different than the system name
  11. * (as in this case), then you can override the header name that
  12. * define_trace.h will look up by defining TRACE_INCLUDE_FILE
  13. *
  14. * This file is called trace-events-sample.h but we want the system
  15. * to be called "sample-trace". Therefore we must define the name of this
  16. * file:
  17. *
  18. * #define TRACE_INCLUDE_FILE trace-events-sample
  19. *
  20. * As we do an the bottom of this file.
  21. *
  22. * Notice that TRACE_SYSTEM should be defined outside of #if
  23. * protection, just like TRACE_INCLUDE_FILE.
  24. */
  25. #undef TRACE_SYSTEM
  26. #define TRACE_SYSTEM sample-trace
  27. /*
  28. * TRACE_SYSTEM is expected to be a C valid variable (alpha-numeric
  29. * and underscore), although it may start with numbers. If for some
  30. * reason it is not, you need to add the following lines:
  31. */
  32. #undef TRACE_SYSTEM_VAR
  33. #define TRACE_SYSTEM_VAR sample_trace
  34. /*
  35. * But the above is only needed if TRACE_SYSTEM is not alpha-numeric
  36. * and underscored. By default, TRACE_SYSTEM_VAR will be equal to
  37. * TRACE_SYSTEM. As TRACE_SYSTEM_VAR must be alpha-numeric, if
  38. * TRACE_SYSTEM is not, then TRACE_SYSTEM_VAR must be defined with
  39. * only alpha-numeric and underscores.
  40. *
  41. * The TRACE_SYSTEM_VAR is only used internally and not visible to
  42. * user space.
  43. */
  44. /*
  45. * Notice that this file is not protected like a normal header.
  46. * We also must allow for rereading of this file. The
  47. *
  48. * || defined(TRACE_HEADER_MULTI_READ)
  49. *
  50. * serves this purpose.
  51. */
  52. #if !defined(_TRACE_EVENT_SAMPLE_H) || defined(TRACE_HEADER_MULTI_READ)
  53. #define _TRACE_EVENT_SAMPLE_H
  54. /*
  55. * All trace headers should include tracepoint.h, until we finally
  56. * make it into a standard header.
  57. */
  58. #include <linux/tracepoint.h>
  59. /*
  60. * The TRACE_EVENT macro is broken up into 5 parts.
  61. *
  62. * name: name of the trace point. This is also how to enable the tracepoint.
  63. * A function called trace_foo_bar() will be created.
  64. *
  65. * proto: the prototype of the function trace_foo_bar()
  66. * Here it is trace_foo_bar(char *foo, int bar).
  67. *
  68. * args: must match the arguments in the prototype.
  69. * Here it is simply "foo, bar".
  70. *
  71. * struct: This defines the way the data will be stored in the ring buffer.
  72. * The items declared here become part of a special structure
  73. * called "__entry", which can be used in the fast_assign part of the
  74. * TRACE_EVENT macro.
  75. *
  76. * Here are the currently defined types you can use:
  77. *
  78. * __field : Is broken up into type and name. Where type can be any
  79. * primitive type (integer, long or pointer).
  80. *
  81. * __field(int, foo)
  82. *
  83. * __entry->foo = 5;
  84. *
  85. * __field_struct : This can be any static complex data type (struct, union
  86. * but not an array). Be careful using complex types, as each
  87. * event is limited in size, and copying large amounts of data
  88. * into the ring buffer can slow things down.
  89. *
  90. * __field_struct(struct bar, foo)
  91. *
  92. * __entry->bar.x = y;
  93. * __array: There are three fields (type, name, size). The type is the
  94. * type of elements in the array, the name is the name of the array.
  95. * size is the number of items in the array (not the total size).
  96. *
  97. * __array( char, foo, 10) is the same as saying: char foo[10];
  98. *
  99. * Assigning arrays can be done like any array:
  100. *
  101. * __entry->foo[0] = 'a';
  102. *
  103. * memcpy(__entry->foo, bar, 10);
  104. *
  105. * __dynamic_array: This is similar to array, but can vary its size from
  106. * instance to instance of the tracepoint being called.
  107. * Like __array, this too has three elements (type, name, size);
  108. * type is the type of the element, name is the name of the array.
  109. * The size is different than __array. It is not a static number,
  110. * but the algorithm to figure out the length of the array for the
  111. * specific instance of tracepoint. Again, size is the number of
  112. * items in the array, not the total length in bytes.
  113. *
  114. * __dynamic_array( int, foo, bar) is similar to: int foo[bar];
  115. *
  116. * Note, unlike arrays, you must use the __get_dynamic_array() macro
  117. * to access the array.
  118. *
  119. * memcpy(__get_dynamic_array(foo), bar, 10);
  120. *
  121. * Notice, that "__entry" is not needed here.
  122. *
  123. * __string: This is a special kind of __dynamic_array. It expects to
  124. * have a null terminated character array passed to it (it allows
  125. * for NULL too, which would be converted into "(null)"). __string
  126. * takes two parameter (name, src), where name is the name of
  127. * the string saved, and src is the string to copy into the
  128. * ring buffer.
  129. *
  130. * __string(foo, bar) is similar to: strcpy(foo, bar)
  131. *
  132. * To assign a string, use the helper macro __assign_str().
  133. *
  134. * __assign_str(foo);
  135. *
  136. * The __string() macro saves off the string that is passed into
  137. * the second parameter, and the __assign_str() will store than
  138. * saved string into the "foo" field.
  139. *
  140. * __vstring: This is similar to __string() but instead of taking a
  141. * dynamic length, it takes a variable list va_list 'va' variable.
  142. * Some event callers already have a message from parameters saved
  143. * in a va_list. Passing in the format and the va_list variable
  144. * will save just enough on the ring buffer for that string.
  145. * Note, the va variable used is a pointer to a va_list, not
  146. * to the va_list directly.
  147. *
  148. * (va_list *va)
  149. *
  150. * __vstring(foo, fmt, va) is similar to: vsnprintf(foo, fmt, va)
  151. *
  152. * To assign the string, use the helper macro __assign_vstr().
  153. *
  154. * __assign_vstr(foo, fmt, va);
  155. *
  156. * In most cases, the __assign_vstr() macro will take the same
  157. * parameters as the __vstring() macro had to declare the string.
  158. * Use __get_str() to retrieve the __vstring() just like it would for
  159. * __string().
  160. *
  161. * __string_len: This is a helper to a __dynamic_array, but it understands
  162. * that the array has characters in it, it will allocate 'len' + 1 bytes
  163. * in the ring buffer and add a '\0' to the string. This is
  164. * useful if the string being saved has no terminating '\0' byte.
  165. * It requires that the length of the string is known as it acts
  166. * like a memcpy().
  167. *
  168. * Declared with:
  169. *
  170. * __string_len(foo, bar, len)
  171. *
  172. * To assign this string, use the helper macro __assign_str().
  173. * The length is saved via the __string_len() and is retrieved in
  174. * __assign_str().
  175. *
  176. * __assign_str(foo);
  177. *
  178. * Then len + 1 is allocated to the ring buffer, and a nul terminating
  179. * byte is added. This is similar to:
  180. *
  181. * memcpy(__get_str(foo), bar, len);
  182. * __get_str(foo)[len] = 0;
  183. *
  184. * The advantage of using this over __dynamic_array, is that it
  185. * takes care of allocating the extra byte on the ring buffer
  186. * for the '\0' terminating byte, and __get_str(foo) can be used
  187. * in the TP_printk().
  188. *
  189. * __bitmask: This is another kind of __dynamic_array, but it expects
  190. * an array of longs, and the number of bits to parse. It takes
  191. * two parameters (name, nr_bits), where name is the name of the
  192. * bitmask to save, and the nr_bits is the number of bits to record.
  193. *
  194. * __bitmask(target_cpu, nr_cpumask_bits)
  195. *
  196. * To assign a bitmask, use the __assign_bitmask() helper macro.
  197. *
  198. * __assign_bitmask(target_cpus, cpumask_bits(bar), nr_cpumask_bits);
  199. *
  200. * __cpumask: This is pretty much the same as __bitmask but is specific for
  201. * CPU masks. The type displayed to the user via the format files will
  202. * be "cpumaks_t" such that user space may deal with them differently
  203. * if they choose to do so, and the bits is always set to nr_cpumask_bits.
  204. *
  205. * __cpumask(target_cpu)
  206. *
  207. * To assign a cpumask, use the __assign_cpumask() helper macro.
  208. *
  209. * __assign_cpumask(target_cpus, cpumask_bits(bar));
  210. *
  211. * fast_assign: This is a C like function that is used to store the items
  212. * into the ring buffer. A special variable called "__entry" will be the
  213. * structure that points into the ring buffer and has the same fields as
  214. * described by the struct part of TRACE_EVENT above.
  215. *
  216. * printk: This is a way to print out the data in pretty print. This is
  217. * useful if the system crashes and you are logging via a serial line,
  218. * the data can be printed to the console using this "printk" method.
  219. * This is also used to print out the data from the trace files.
  220. * Again, the __entry macro is used to access the data from the ring buffer.
  221. *
  222. * Note, __dynamic_array, __string, __bitmask and __cpumask require special
  223. * helpers to access the data.
  224. *
  225. * For __dynamic_array(int, foo, bar) use __get_dynamic_array(foo)
  226. * Use __get_dynamic_array_len(foo) to get the length of the array
  227. * saved. Note, __get_dynamic_array_len() returns the total allocated
  228. * length of the dynamic array; __print_array() expects the second
  229. * parameter to be the number of elements. To get that, the array length
  230. * needs to be divided by the element size.
  231. *
  232. * For __string(foo, bar) use __get_str(foo)
  233. *
  234. * For __bitmask(target_cpus, nr_cpumask_bits) use __get_bitmask(target_cpus)
  235. *
  236. * For __cpumask(target_cpus) use __get_cpumask(target_cpus)
  237. *
  238. *
  239. * Note, that for both the assign and the printk, __entry is the handler
  240. * to the data structure in the ring buffer, and is defined by the
  241. * TP_STRUCT__entry.
  242. */
  243. /*
  244. * It is OK to have helper functions in the file, but they need to be protected
  245. * from being defined more than once. Remember, this file gets included more
  246. * than once.
  247. */
  248. #ifndef __TRACE_EVENT_SAMPLE_HELPER_FUNCTIONS
  249. #define __TRACE_EVENT_SAMPLE_HELPER_FUNCTIONS
  250. static inline int __length_of(const int *list)
  251. {
  252. int i;
  253. if (!list)
  254. return 0;
  255. for (i = 0; list[i]; i++)
  256. ;
  257. return i;
  258. }
  259. enum {
  260. TRACE_SAMPLE_FOO = 2,
  261. TRACE_SAMPLE_BAR = 4,
  262. TRACE_SAMPLE_ZOO = 8,
  263. };
  264. #endif
  265. /*
  266. * If enums are used in the TP_printk(), their names will be shown in
  267. * format files and not their values. This can cause problems with user
  268. * space programs that parse the format files to know how to translate
  269. * the raw binary trace output into human readable text.
  270. *
  271. * To help out user space programs, any enum that is used in the TP_printk()
  272. * should be defined by TRACE_DEFINE_ENUM() macro. All that is needed to
  273. * be done is to add this macro with the enum within it in the trace
  274. * header file, and it will be converted in the output.
  275. */
  276. TRACE_DEFINE_ENUM(TRACE_SAMPLE_FOO);
  277. TRACE_DEFINE_ENUM(TRACE_SAMPLE_BAR);
  278. TRACE_DEFINE_ENUM(TRACE_SAMPLE_ZOO);
  279. TRACE_EVENT(foo_bar,
  280. TP_PROTO(const char *foo, int bar, const int *lst,
  281. const char *string, const struct cpumask *mask,
  282. const char *fmt, va_list *va),
  283. TP_ARGS(foo, bar, lst, string, mask, fmt, va),
  284. TP_STRUCT__entry(
  285. __array( char, foo, 10 )
  286. __field( int, bar )
  287. __dynamic_array(int, list, __length_of(lst))
  288. __string( str, string )
  289. __bitmask( cpus, num_possible_cpus() )
  290. __cpumask( cpum )
  291. __vstring( vstr, fmt, va )
  292. __string_len( lstr, foo, bar / 2 < strlen(foo) ? bar / 2 : strlen(foo) )
  293. ),
  294. TP_fast_assign(
  295. strscpy(__entry->foo, foo, 10);
  296. __entry->bar = bar;
  297. memcpy(__get_dynamic_array(list), lst,
  298. __length_of(lst) * sizeof(int));
  299. __assign_str(str);
  300. __assign_str(lstr);
  301. __assign_vstr(vstr, fmt, va);
  302. __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus());
  303. __assign_cpumask(cpum, cpumask_bits(mask));
  304. ),
  305. TP_printk("foo %s %d %s %s %s %s %s %s (%s) (%s) %s [%d] %*pbl",
  306. __entry->foo, __entry->bar,
  307. /*
  308. * Notice here the use of some helper functions. This includes:
  309. *
  310. * __print_symbolic( variable, { value, "string" }, ... ),
  311. *
  312. * The variable is tested against each value of the { } pair. If
  313. * the variable matches one of the values, then it will print the
  314. * string in that pair. If non are matched, it returns a string
  315. * version of the number (if __entry->bar == 7 then "7" is returned).
  316. */
  317. __print_symbolic(__entry->bar,
  318. { 0, "zero" },
  319. { TRACE_SAMPLE_FOO, "TWO" },
  320. { TRACE_SAMPLE_BAR, "FOUR" },
  321. { TRACE_SAMPLE_ZOO, "EIGHT" },
  322. { 10, "TEN" }
  323. ),
  324. /*
  325. * __print_flags( variable, "delim", { value, "flag" }, ... ),
  326. *
  327. * This is similar to __print_symbolic, except that it tests the bits
  328. * of the value. If ((FLAG & variable) == FLAG) then the string is
  329. * printed. If more than one flag matches, then each one that does is
  330. * also printed with delim in between them.
  331. * If not all bits are accounted for, then the not found bits will be
  332. * added in hex format: 0x506 will show BIT2|BIT4|0x500
  333. */
  334. __print_flags(__entry->bar, "|",
  335. { 1, "BIT1" },
  336. { 2, "BIT2" },
  337. { 4, "BIT3" },
  338. { 8, "BIT4" }
  339. ),
  340. /*
  341. * __print_array( array, len, element_size )
  342. *
  343. * This prints out the array that is defined by __array in a nice format.
  344. */
  345. __print_array(__get_dynamic_array(list),
  346. __get_dynamic_array_len(list) / sizeof(int),
  347. sizeof(int)),
  348. /* A shortcut is to use __print_dynamic_array for dynamic arrays */
  349. __print_dynamic_array(list, sizeof(int)),
  350. __get_str(str), __get_str(lstr),
  351. __get_bitmask(cpus), __get_cpumask(cpum),
  352. __get_str(vstr),
  353. __get_dynamic_array_len(cpus),
  354. __get_dynamic_array_len(cpus),
  355. __get_dynamic_array(cpus))
  356. );
  357. /*
  358. * There may be a case where a tracepoint should only be called if
  359. * some condition is set. Otherwise the tracepoint should not be called.
  360. * But to do something like:
  361. *
  362. * if (cond)
  363. * trace_foo();
  364. *
  365. * Would cause a little overhead when tracing is not enabled, and that
  366. * overhead, even if small, is not something we want. As tracepoints
  367. * use static branch (aka jump_labels), where no branch is taken to
  368. * skip the tracepoint when not enabled, and a jmp is placed to jump
  369. * to the tracepoint code when it is enabled, having a if statement
  370. * nullifies that optimization. It would be nice to place that
  371. * condition within the static branch. This is where TRACE_EVENT_CONDITION
  372. * comes in.
  373. *
  374. * TRACE_EVENT_CONDITION() is just like TRACE_EVENT, except it adds another
  375. * parameter just after args. Where TRACE_EVENT has:
  376. *
  377. * TRACE_EVENT(name, proto, args, struct, assign, printk)
  378. *
  379. * the CONDITION version has:
  380. *
  381. * TRACE_EVENT_CONDITION(name, proto, args, cond, struct, assign, printk)
  382. *
  383. * Everything is the same as TRACE_EVENT except for the new cond. Think
  384. * of the cond variable as:
  385. *
  386. * if (cond)
  387. * trace_foo_bar_with_cond();
  388. *
  389. * Except that the logic for the if branch is placed after the static branch.
  390. * That is, the if statement that processes the condition will not be
  391. * executed unless that traecpoint is enabled. Otherwise it still remains
  392. * a nop.
  393. */
  394. TRACE_EVENT_CONDITION(foo_bar_with_cond,
  395. TP_PROTO(const char *foo, int bar),
  396. TP_ARGS(foo, bar),
  397. TP_CONDITION(!(bar % 10)),
  398. TP_STRUCT__entry(
  399. __string( foo, foo )
  400. __field( int, bar )
  401. ),
  402. TP_fast_assign(
  403. __assign_str(foo);
  404. __entry->bar = bar;
  405. ),
  406. TP_printk("foo %s %d", __get_str(foo), __entry->bar)
  407. );
  408. int foo_bar_reg(void);
  409. void foo_bar_unreg(void);
  410. /*
  411. * Now in the case that some function needs to be called when the
  412. * tracepoint is enabled and/or when it is disabled, the
  413. * TRACE_EVENT_FN() serves this purpose. This is just like TRACE_EVENT()
  414. * but adds two more parameters at the end:
  415. *
  416. * TRACE_EVENT_FN( name, proto, args, struct, assign, printk, reg, unreg)
  417. *
  418. * reg and unreg are functions with the prototype of:
  419. *
  420. * void reg(void)
  421. *
  422. * The reg function gets called before the tracepoint is enabled, and
  423. * the unreg function gets called after the tracepoint is disabled.
  424. *
  425. * Note, reg and unreg are allowed to be NULL. If you only need to
  426. * call a function before enabling, or after disabling, just set one
  427. * function and pass in NULL for the other parameter.
  428. */
  429. TRACE_EVENT_FN(foo_bar_with_fn,
  430. TP_PROTO(const char *foo, int bar),
  431. TP_ARGS(foo, bar),
  432. TP_STRUCT__entry(
  433. __string( foo, foo )
  434. __field( int, bar )
  435. ),
  436. TP_fast_assign(
  437. __assign_str(foo);
  438. __entry->bar = bar;
  439. ),
  440. TP_printk("foo %s %d", __get_str(foo), __entry->bar),
  441. foo_bar_reg, foo_bar_unreg
  442. );
  443. /*
  444. * Each TRACE_EVENT macro creates several helper functions to produce
  445. * the code to add the tracepoint, create the files in the trace
  446. * directory, hook it to perf, assign the values and to print out
  447. * the raw data from the ring buffer. To prevent too much bloat,
  448. * if there are more than one tracepoint that uses the same format
  449. * for the proto, args, struct, assign and printk, and only the name
  450. * is different, it is highly recommended to use the DECLARE_EVENT_CLASS
  451. *
  452. * DECLARE_EVENT_CLASS() macro creates most of the functions for the
  453. * tracepoint. Then DEFINE_EVENT() is use to hook a tracepoint to those
  454. * functions. This DEFINE_EVENT() is an instance of the class and can
  455. * be enabled and disabled separately from other events (either TRACE_EVENT
  456. * or other DEFINE_EVENT()s).
  457. *
  458. * Note, TRACE_EVENT() itself is simply defined as:
  459. *
  460. * #define TRACE_EVENT(name, proto, args, tstruct, assign, printk) \
  461. * DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, printk); \
  462. * DEFINE_EVENT(name, name, proto, args)
  463. *
  464. * The DEFINE_EVENT() also can be declared with conditions and reg functions:
  465. *
  466. * DEFINE_EVENT_CONDITION(template, name, proto, args, cond);
  467. * DEFINE_EVENT_FN(template, name, proto, args, reg, unreg);
  468. */
  469. DECLARE_EVENT_CLASS(foo_template,
  470. TP_PROTO(const char *foo, int bar),
  471. TP_ARGS(foo, bar),
  472. TP_STRUCT__entry(
  473. __string( foo, foo )
  474. __field( int, bar )
  475. ),
  476. TP_fast_assign(
  477. __assign_str(foo);
  478. __entry->bar = bar;
  479. ),
  480. TP_printk("foo %s %d", __get_str(foo), __entry->bar)
  481. );
  482. /*
  483. * Here's a better way for the previous samples (except, the first
  484. * example had more fields and could not be used here).
  485. */
  486. DEFINE_EVENT(foo_template, foo_with_template_simple,
  487. TP_PROTO(const char *foo, int bar),
  488. TP_ARGS(foo, bar));
  489. DEFINE_EVENT_CONDITION(foo_template, foo_with_template_cond,
  490. TP_PROTO(const char *foo, int bar),
  491. TP_ARGS(foo, bar),
  492. TP_CONDITION(!(bar % 8)));
  493. DEFINE_EVENT_FN(foo_template, foo_with_template_fn,
  494. TP_PROTO(const char *foo, int bar),
  495. TP_ARGS(foo, bar),
  496. foo_bar_reg, foo_bar_unreg);
  497. /*
  498. * Anytime two events share basically the same values and have
  499. * the same output, use the DECLARE_EVENT_CLASS() and DEFINE_EVENT()
  500. * when ever possible.
  501. */
  502. /*
  503. * If the event is similar to the DECLARE_EVENT_CLASS, but you need
  504. * to have a different output, then use DEFINE_EVENT_PRINT() which
  505. * lets you override the TP_printk() of the class.
  506. */
  507. DEFINE_EVENT_PRINT(foo_template, foo_with_template_print,
  508. TP_PROTO(const char *foo, int bar),
  509. TP_ARGS(foo, bar),
  510. TP_printk("bar %s %d", __get_str(foo), __entry->bar));
  511. /*
  512. * There are yet another __rel_loc dynamic data attribute. If you
  513. * use __rel_dynamic_array() and __rel_string() etc. macros, you
  514. * can use this attribute. There is no difference from the viewpoint
  515. * of functionality with/without 'rel' but the encoding is a bit
  516. * different. This is expected to be used with user-space event,
  517. * there is no reason that the kernel event use this, but only for
  518. * testing.
  519. */
  520. TRACE_EVENT(foo_rel_loc,
  521. TP_PROTO(const char *foo, int bar, unsigned long *mask, const cpumask_t *cpus),
  522. TP_ARGS(foo, bar, mask, cpus),
  523. TP_STRUCT__entry(
  524. __rel_string( foo, foo )
  525. __field( int, bar )
  526. __rel_bitmask( bitmask,
  527. BITS_PER_BYTE * sizeof(unsigned long) )
  528. __rel_cpumask( cpumask )
  529. ),
  530. TP_fast_assign(
  531. __assign_rel_str(foo);
  532. __entry->bar = bar;
  533. __assign_rel_bitmask(bitmask, mask,
  534. BITS_PER_BYTE * sizeof(unsigned long));
  535. __assign_rel_cpumask(cpumask, cpus);
  536. ),
  537. TP_printk("foo_rel_loc %s, %d, %s, %s", __get_rel_str(foo), __entry->bar,
  538. __get_rel_bitmask(bitmask),
  539. __get_rel_cpumask(cpumask))
  540. );
  541. #endif
  542. /***** NOTICE! The #if protection ends here. *****/
  543. /*
  544. * There are several ways I could have done this. If I left out the
  545. * TRACE_INCLUDE_PATH, then it would default to the kernel source
  546. * include/trace/events directory.
  547. *
  548. * I could specify a path from the define_trace.h file back to this
  549. * file.
  550. *
  551. * #define TRACE_INCLUDE_PATH ../../samples/trace_events
  552. *
  553. * But the safest and easiest way to simply make it use the directory
  554. * that the file is in is to add in the Makefile:
  555. *
  556. * CFLAGS_trace-events-sample.o := -I$(src)
  557. *
  558. * This will make sure the current path is part of the include
  559. * structure for our file so that define_trace.h can find it.
  560. *
  561. * I could have made only the top level directory the include:
  562. *
  563. * CFLAGS_trace-events-sample.o := -I$(PWD)
  564. *
  565. * And then let the path to this directory be the TRACE_INCLUDE_PATH:
  566. *
  567. * #define TRACE_INCLUDE_PATH samples/trace_events
  568. *
  569. * But then if something defines "samples" or "trace_events" as a macro
  570. * then we could risk that being converted too, and give us an unexpected
  571. * result.
  572. */
  573. #undef TRACE_INCLUDE_PATH
  574. #undef TRACE_INCLUDE_FILE
  575. #define TRACE_INCLUDE_PATH .
  576. /*
  577. * TRACE_INCLUDE_FILE is not needed if the filename and TRACE_SYSTEM are equal
  578. */
  579. #define TRACE_INCLUDE_FILE trace-events-sample
  580. #include <trace/define_trace.h>