| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
|
| 3 |
/* |
| 4 |
* If TRACE_SYSTEM is defined, that will be the directory created |
| 5 |
* in the ftrace directory under /sys/kernel/tracing/events/<system> |
| 6 |
* |
| 7 |
* The define_trace.h below will also look for a file name of |
| 8 |
* TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here. |
| 9 |
* In this case, it would look for sample-trace.h |
| 10 |
* |
| 11 |
* If the header name will be different than the system name |
| 12 |
* (as in this case), then you can override the header name that |
| 13 |
* define_trace.h will look up by defining TRACE_INCLUDE_FILE |
| 14 |
* |
| 15 |
* This file is called sample-trace-array.h but we want the system |
| 16 |
* to be called "sample-subsystem". Therefore we must define the name of this |
| 17 |
* file: |
| 18 |
* |
| 19 |
* #define TRACE_INCLUDE_FILE sample-trace-array |
| 20 |
* |
| 21 |
* As we do in the bottom of this file. |
| 22 |
* |
| 23 |
* Notice that TRACE_SYSTEM should be defined outside of #if |
| 24 |
* protection, just like TRACE_INCLUDE_FILE. |
| 25 |
*/ |
| 26 |
#undef TRACE_SYSTEM |
| 27 |
#define TRACE_SYSTEM sample-subsystem |
| 28 |
|
| 29 |
/* |
| 30 |
* TRACE_SYSTEM is expected to be a C valid variable (alpha-numeric |
| 31 |
* and underscore), although it may start with numbers. If for some |
| 32 |
* reason it is not, you need to add the following lines: |
| 33 |
*/ |
| 34 |
#undef TRACE_SYSTEM_VAR |
| 35 |
#define TRACE_SYSTEM_VAR sample_subsystem |
| 36 |
|
| 37 |
/* |
| 38 |
* But the above is only needed if TRACE_SYSTEM is not alpha-numeric |
| 39 |
* and underscored. By default, TRACE_SYSTEM_VAR will be equal to |
| 40 |
* TRACE_SYSTEM. As TRACE_SYSTEM_VAR must be alpha-numeric, if |
| 41 |
* TRACE_SYSTEM is not, then TRACE_SYSTEM_VAR must be defined with |
| 42 |
* only alpha-numeric and underscores. |
| 43 |
* |
| 44 |
* The TRACE_SYSTEM_VAR is only used internally and not visible to |
| 45 |
* user space. |
| 46 |
*/ |
| 47 |
|
| 48 |
/* |
| 49 |
* Notice that this file is not protected like a normal header. |
| 50 |
* We also must allow for rereading of this file. The |
| 51 |
* |
| 52 |
* || defined(TRACE_HEADER_MULTI_READ) |
| 53 |
* |
| 54 |
* serves this purpose. |
| 55 |
*/ |
| 56 |
#if !defined(_SAMPLE_TRACE_ARRAY_H) || defined(TRACE_HEADER_MULTI_READ) |
| 57 |
#define _SAMPLE_TRACE_ARRAY_H |
| 58 |
|
| 59 |
#include <linux/tracepoint.h> |
| 60 |
TRACE_EVENT(sample_event, |
| 61 |
|
| 62 |
TP_PROTO(int count, unsigned long time), |
| 63 |
|
| 64 |
TP_ARGS(count, time), |
| 65 |
|
| 66 |
TP_STRUCT__entry( |
| 67 |
__field(int, count) |
| 68 |
__field(unsigned long, time) |
| 69 |
), |
| 70 |
|
| 71 |
TP_fast_assign( |
| 72 |
__entry->count = count; |
| 73 |
__entry->time = time; |
| 74 |
), |
| 75 |
|
| 76 |
TP_printk("count value=%d at jiffies=%lu", __entry->count, |
| 77 |
__entry->time) |
| 78 |
); |
| 79 |
#endif |
| 80 |
|
| 81 |
#undef TRACE_INCLUDE_PATH |
| 82 |
#define TRACE_INCLUDE_PATH . |
| 83 |
#define TRACE_INCLUDE_FILE sample-trace-array |
| 84 |
#include <trace/define_trace.h> |