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