189ed4249SDivya Indi /* SPDX-License-Identifier: GPL-2.0 */ 289ed4249SDivya Indi 389ed4249SDivya Indi /* 489ed4249SDivya Indi * If TRACE_SYSTEM is defined, that will be the directory created 589ed4249SDivya Indi * in the ftrace directory under /sys/kernel/tracing/events/<system> 689ed4249SDivya Indi * 789ed4249SDivya Indi * The define_trace.h below will also look for a file name of 889ed4249SDivya Indi * TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here. 989ed4249SDivya Indi * In this case, it would look for sample-trace.h 1089ed4249SDivya Indi * 1189ed4249SDivya Indi * If the header name will be different than the system name 1289ed4249SDivya Indi * (as in this case), then you can override the header name that 1389ed4249SDivya Indi * define_trace.h will look up by defining TRACE_INCLUDE_FILE 1489ed4249SDivya Indi * 1589ed4249SDivya Indi * This file is called sample-trace-array.h but we want the system 1689ed4249SDivya Indi * to be called "sample-subsystem". Therefore we must define the name of this 1789ed4249SDivya Indi * file: 1889ed4249SDivya Indi * 1989ed4249SDivya Indi * #define TRACE_INCLUDE_FILE sample-trace-array 2089ed4249SDivya Indi * 2189ed4249SDivya Indi * As we do in the bottom of this file. 2289ed4249SDivya Indi * 2389ed4249SDivya Indi * Notice that TRACE_SYSTEM should be defined outside of #if 2489ed4249SDivya Indi * protection, just like TRACE_INCLUDE_FILE. 2589ed4249SDivya Indi */ 2689ed4249SDivya Indi #undef TRACE_SYSTEM 2789ed4249SDivya Indi #define TRACE_SYSTEM sample-subsystem 2889ed4249SDivya Indi 2989ed4249SDivya Indi /* 3089ed4249SDivya Indi * TRACE_SYSTEM is expected to be a C valid variable (alpha-numeric 3189ed4249SDivya Indi * and underscore), although it may start with numbers. If for some 3289ed4249SDivya Indi * reason it is not, you need to add the following lines: 3389ed4249SDivya Indi */ 3489ed4249SDivya Indi #undef TRACE_SYSTEM_VAR 3589ed4249SDivya Indi #define TRACE_SYSTEM_VAR sample_subsystem 3689ed4249SDivya Indi 3789ed4249SDivya Indi /* 3889ed4249SDivya Indi * But the above is only needed if TRACE_SYSTEM is not alpha-numeric 3989ed4249SDivya Indi * and underscored. By default, TRACE_SYSTEM_VAR will be equal to 4089ed4249SDivya Indi * TRACE_SYSTEM. As TRACE_SYSTEM_VAR must be alpha-numeric, if 4189ed4249SDivya Indi * TRACE_SYSTEM is not, then TRACE_SYSTEM_VAR must be defined with 4289ed4249SDivya Indi * only alpha-numeric and underscores. 4389ed4249SDivya Indi * 4489ed4249SDivya Indi * The TRACE_SYSTEM_VAR is only used internally and not visible to 4589ed4249SDivya Indi * user space. 4689ed4249SDivya Indi */ 4789ed4249SDivya Indi 4889ed4249SDivya Indi /* 4989ed4249SDivya Indi * Notice that this file is not protected like a normal header. 5089ed4249SDivya Indi * We also must allow for rereading of this file. The 5189ed4249SDivya Indi * 5289ed4249SDivya Indi * || defined(TRACE_HEADER_MULTI_READ) 5389ed4249SDivya Indi * 5489ed4249SDivya Indi * serves this purpose. 5589ed4249SDivya Indi */ 5689ed4249SDivya Indi #if !defined(_SAMPLE_TRACE_ARRAY_H) || defined(TRACE_HEADER_MULTI_READ) 5789ed4249SDivya Indi #define _SAMPLE_TRACE_ARRAY_H 5889ed4249SDivya Indi 5989ed4249SDivya Indi #include <linux/tracepoint.h> 6089ed4249SDivya Indi TRACE_EVENT(sample_event, 6189ed4249SDivya Indi 6289ed4249SDivya Indi TP_PROTO(int count, unsigned long time), 6389ed4249SDivya Indi 6489ed4249SDivya Indi TP_ARGS(count, time), 6589ed4249SDivya Indi 6689ed4249SDivya Indi TP_STRUCT__entry( 6789ed4249SDivya Indi __field(int, count) 6889ed4249SDivya Indi __field(unsigned long, time) 6989ed4249SDivya Indi ), 7089ed4249SDivya Indi 7189ed4249SDivya Indi TP_fast_assign( 7289ed4249SDivya Indi __entry->count = count; 7389ed4249SDivya Indi __entry->time = time; 7489ed4249SDivya Indi ), 7589ed4249SDivya Indi 7689ed4249SDivya Indi TP_printk("count value=%d at jiffies=%lu", __entry->count, 7789ed4249SDivya Indi __entry->time) 7889ed4249SDivya Indi ); 7989ed4249SDivya Indi #endif 8089ed4249SDivya Indi 8189ed4249SDivya Indi #undef TRACE_INCLUDE_PATH 8289ed4249SDivya Indi #define TRACE_INCLUDE_PATH . 8389ed4249SDivya Indi #define TRACE_INCLUDE_FILE sample-trace-array 8489ed4249SDivya Indi #include <trace/define_trace.h> 85