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