sample-trace-array.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 sample-trace-array.h but we want the system
  15. * to be called "sample-subsystem". Therefore we must define the name of this
  16. * file:
  17. *
  18. * #define TRACE_INCLUDE_FILE sample-trace-array
  19. *
  20. * As we do in 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-subsystem
  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_subsystem
  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(_SAMPLE_TRACE_ARRAY_H) || defined(TRACE_HEADER_MULTI_READ)
  53. #define _SAMPLE_TRACE_ARRAY_H
  54. #include <linux/tracepoint.h>
  55. TRACE_EVENT(sample_event,
  56. TP_PROTO(int count, unsigned long time),
  57. TP_ARGS(count, time),
  58. TP_STRUCT__entry(
  59. __field(int, count)
  60. __field(unsigned long, time)
  61. ),
  62. TP_fast_assign(
  63. __entry->count = count;
  64. __entry->time = time;
  65. ),
  66. TP_printk("count value=%d at jiffies=%lu", __entry->count,
  67. __entry->time)
  68. );
  69. #endif
  70. #undef TRACE_INCLUDE_PATH
  71. #define TRACE_INCLUDE_PATH .
  72. #define TRACE_INCLUDE_FILE sample-trace-array
  73. #include <trace/define_trace.h>