18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci/* 48c2ecf20Sopenharmony_ci * If TRACE_SYSTEM is defined, that will be the directory created 58c2ecf20Sopenharmony_ci * in the ftrace directory under /sys/kernel/tracing/events/<system> 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * The define_trace.h below will also look for a file name of 88c2ecf20Sopenharmony_ci * TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here. 98c2ecf20Sopenharmony_ci * In this case, it would look for sample-trace.h 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * If the header name will be different than the system name 128c2ecf20Sopenharmony_ci * (as in this case), then you can override the header name that 138c2ecf20Sopenharmony_ci * define_trace.h will look up by defining TRACE_INCLUDE_FILE 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * This file is called sample-trace-array.h but we want the system 168c2ecf20Sopenharmony_ci * to be called "sample-subsystem". Therefore we must define the name of this 178c2ecf20Sopenharmony_ci * file: 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * #define TRACE_INCLUDE_FILE sample-trace-array 208c2ecf20Sopenharmony_ci * 218c2ecf20Sopenharmony_ci * As we do in the bottom of this file. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * Notice that TRACE_SYSTEM should be defined outside of #if 248c2ecf20Sopenharmony_ci * protection, just like TRACE_INCLUDE_FILE. 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ci#undef TRACE_SYSTEM 278c2ecf20Sopenharmony_ci#define TRACE_SYSTEM sample-subsystem 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* 308c2ecf20Sopenharmony_ci * TRACE_SYSTEM is expected to be a C valid variable (alpha-numeric 318c2ecf20Sopenharmony_ci * and underscore), although it may start with numbers. If for some 328c2ecf20Sopenharmony_ci * reason it is not, you need to add the following lines: 338c2ecf20Sopenharmony_ci */ 348c2ecf20Sopenharmony_ci#undef TRACE_SYSTEM_VAR 358c2ecf20Sopenharmony_ci#define TRACE_SYSTEM_VAR sample_subsystem 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* 388c2ecf20Sopenharmony_ci * But the above is only needed if TRACE_SYSTEM is not alpha-numeric 398c2ecf20Sopenharmony_ci * and underscored. By default, TRACE_SYSTEM_VAR will be equal to 408c2ecf20Sopenharmony_ci * TRACE_SYSTEM. As TRACE_SYSTEM_VAR must be alpha-numeric, if 418c2ecf20Sopenharmony_ci * TRACE_SYSTEM is not, then TRACE_SYSTEM_VAR must be defined with 428c2ecf20Sopenharmony_ci * only alpha-numeric and underscores. 438c2ecf20Sopenharmony_ci * 448c2ecf20Sopenharmony_ci * The TRACE_SYSTEM_VAR is only used internally and not visible to 458c2ecf20Sopenharmony_ci * user space. 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* 498c2ecf20Sopenharmony_ci * Notice that this file is not protected like a normal header. 508c2ecf20Sopenharmony_ci * We also must allow for rereading of this file. The 518c2ecf20Sopenharmony_ci * 528c2ecf20Sopenharmony_ci * || defined(TRACE_HEADER_MULTI_READ) 538c2ecf20Sopenharmony_ci * 548c2ecf20Sopenharmony_ci * serves this purpose. 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_ci#if !defined(_SAMPLE_TRACE_ARRAY_H) || defined(TRACE_HEADER_MULTI_READ) 578c2ecf20Sopenharmony_ci#define _SAMPLE_TRACE_ARRAY_H 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#include <linux/tracepoint.h> 608c2ecf20Sopenharmony_ciTRACE_EVENT(sample_event, 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci TP_PROTO(int count, unsigned long time), 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci TP_ARGS(count, time), 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci TP_STRUCT__entry( 678c2ecf20Sopenharmony_ci __field(int, count) 688c2ecf20Sopenharmony_ci __field(unsigned long, time) 698c2ecf20Sopenharmony_ci ), 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci TP_fast_assign( 728c2ecf20Sopenharmony_ci __entry->count = count; 738c2ecf20Sopenharmony_ci __entry->time = time; 748c2ecf20Sopenharmony_ci ), 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci TP_printk("count value=%d at jiffies=%lu", __entry->count, 778c2ecf20Sopenharmony_ci __entry->time) 788c2ecf20Sopenharmony_ci ); 798c2ecf20Sopenharmony_ci#endif 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_PATH 828c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_PATH . 838c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_FILE sample-trace-array 848c2ecf20Sopenharmony_ci#include <trace/define_trace.h> 85