xref: /linux/include/linux/tracepoint.h (revision 7af08b57bcb9ebf78675c50069c54125c0a8b795)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _LINUX_TRACEPOINT_H
3 #define _LINUX_TRACEPOINT_H
4 
5 /*
6  * Kernel Tracepoint API.
7  *
8  * See Documentation/trace/tracepoints.rst.
9  *
10  * Copyright (C) 2008-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11  *
12  * Heavily inspired from the Linux Kernel Markers.
13  */
14 
15 #include <linux/smp.h>
16 #include <linux/srcu.h>
17 #include <linux/errno.h>
18 #include <linux/types.h>
19 #include <linux/rcupdate.h>
20 #include <linux/rcupdate_trace.h>
21 #include <linux/tracepoint-defs.h>
22 #include <linux/static_call.h>
23 
24 struct module;
25 struct tracepoint;
26 struct notifier_block;
27 
28 struct trace_eval_map {
29 	const char		*system;
30 	const char		*eval_string;
31 	unsigned long		eval_value;
32 };
33 
34 #define TRACEPOINT_DEFAULT_PRIO	10
35 
36 extern int
37 tracepoint_probe_register(struct tracepoint *tp, void *probe, void *data);
38 extern int
39 tracepoint_probe_register_prio(struct tracepoint *tp, void *probe, void *data,
40 			       int prio);
41 extern int
42 tracepoint_probe_register_prio_may_exist(struct tracepoint *tp, void *probe, void *data,
43 					 int prio);
44 extern int
45 tracepoint_probe_unregister(struct tracepoint *tp, void *probe, void *data);
46 static inline int
tracepoint_probe_register_may_exist(struct tracepoint * tp,void * probe,void * data)47 tracepoint_probe_register_may_exist(struct tracepoint *tp, void *probe,
48 				    void *data)
49 {
50 	return tracepoint_probe_register_prio_may_exist(tp, probe, data,
51 							TRACEPOINT_DEFAULT_PRIO);
52 }
53 extern void
54 for_each_kernel_tracepoint(void (*fct)(struct tracepoint *tp, void *priv),
55 		void *priv);
56 
57 #ifdef CONFIG_MODULES
58 struct tp_module {
59 	struct list_head list;
60 	struct module *mod;
61 };
62 
63 bool trace_module_has_bad_taint(struct module *mod);
64 extern int register_tracepoint_module_notifier(struct notifier_block *nb);
65 extern int unregister_tracepoint_module_notifier(struct notifier_block *nb);
66 void for_each_module_tracepoint(void (*fct)(struct tracepoint *,
67 					struct module *, void *),
68 				void *priv);
69 void for_each_tracepoint_in_module(struct module *,
70 				   void (*fct)(struct tracepoint *,
71 					struct module *, void *),
72 				   void *priv);
73 #else
trace_module_has_bad_taint(struct module * mod)74 static inline bool trace_module_has_bad_taint(struct module *mod)
75 {
76 	return false;
77 }
78 static inline
register_tracepoint_module_notifier(struct notifier_block * nb)79 int register_tracepoint_module_notifier(struct notifier_block *nb)
80 {
81 	return 0;
82 }
83 static inline
unregister_tracepoint_module_notifier(struct notifier_block * nb)84 int unregister_tracepoint_module_notifier(struct notifier_block *nb)
85 {
86 	return 0;
87 }
88 static inline
for_each_module_tracepoint(void (* fct)(struct tracepoint *,struct module *,void *),void * priv)89 void for_each_module_tracepoint(void (*fct)(struct tracepoint *,
90 					struct module *, void *),
91 				void *priv)
92 {
93 }
94 static inline
for_each_tracepoint_in_module(struct module * mod,void (* fct)(struct tracepoint *,struct module *,void *),void * priv)95 void for_each_tracepoint_in_module(struct module *mod,
96 				   void (*fct)(struct tracepoint *,
97 					struct module *, void *),
98 				   void *priv)
99 {
100 }
101 #endif /* CONFIG_MODULES */
102 
103 /*
104  * tracepoint_synchronize_unregister must be called between the last tracepoint
105  * probe unregistration and the end of module exit to make sure there is no
106  * caller executing a probe when it is freed.
107  *
108  * An alternative is to use the following for batch reclaim associated
109  * with a given tracepoint:
110  *
111  * - tracepoint_is_faultable() == false: call_rcu()
112  * - tracepoint_is_faultable() == true:  call_rcu_tasks_trace()
113  */
114 #ifdef CONFIG_TRACEPOINTS
tracepoint_synchronize_unregister(void)115 static inline void tracepoint_synchronize_unregister(void)
116 {
117 	synchronize_rcu_tasks_trace();
118 	synchronize_rcu();
119 }
tracepoint_is_faultable(struct tracepoint * tp)120 static inline bool tracepoint_is_faultable(struct tracepoint *tp)
121 {
122 	return tp->ext && tp->ext->faultable;
123 }
124 #else
tracepoint_synchronize_unregister(void)125 static inline void tracepoint_synchronize_unregister(void)
126 { }
tracepoint_is_faultable(struct tracepoint * tp)127 static inline bool tracepoint_is_faultable(struct tracepoint *tp)
128 {
129 	return false;
130 }
131 #endif
132 
133 #ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
134 extern int syscall_regfunc(void);
135 extern void syscall_unregfunc(void);
136 #endif /* CONFIG_HAVE_SYSCALL_TRACEPOINTS */
137 
138 #ifndef PARAMS
139 #define PARAMS(args...) args
140 #endif
141 
142 #define TRACE_DEFINE_ENUM(x)
143 #define TRACE_DEFINE_SIZEOF(x)
144 
145 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
tracepoint_ptr_deref(tracepoint_ptr_t * p)146 static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
147 {
148 	return offset_to_ptr(p);
149 }
150 
151 #define __TRACEPOINT_ENTRY(name)					\
152 	asm("	.section \"__tracepoints_ptrs\", \"a\"		\n"	\
153 	    "	.balign 4					\n"	\
154 	    "	.long 	__tracepoint_" #name " - .		\n"	\
155 	    "	.previous					\n")
156 #else
tracepoint_ptr_deref(tracepoint_ptr_t * p)157 static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
158 {
159 	return *p;
160 }
161 
162 #define __TRACEPOINT_ENTRY(name)					 \
163 	static tracepoint_ptr_t __tracepoint_ptr_##name __used		 \
164 	__section("__tracepoints_ptrs") = &__tracepoint_##name
165 #endif
166 
167 #endif /* _LINUX_TRACEPOINT_H */
168 
169 /*
170  * Note: we keep the TRACE_EVENT and DECLARE_TRACE outside the include
171  *  file ifdef protection.
172  *  This is due to the way trace events work. If a file includes two
173  *  trace event headers under one "CREATE_TRACE_POINTS" the first include
174  *  will override the TRACE_EVENT and break the second include.
175  */
176 
177 #ifndef DECLARE_TRACE
178 
179 #define TP_PROTO(args...)	args
180 #define TP_ARGS(args...)	args
181 #define TP_CONDITION(args...)	args
182 
183 /*
184  * Individual subsystem my have a separate configuration to
185  * enable their tracepoints. By default, this file will create
186  * the tracepoints if CONFIG_TRACEPOINTS is defined. If a subsystem
187  * wants to be able to disable its tracepoints from being created
188  * it can define NOTRACE before including the tracepoint headers.
189  */
190 #if defined(CONFIG_TRACEPOINTS) && !defined(NOTRACE)
191 #define TRACEPOINTS_ENABLED
192 #endif
193 
194 #ifdef TRACEPOINTS_ENABLED
195 
196 #ifdef CONFIG_HAVE_STATIC_CALL
197 #define __DO_TRACE_CALL(name, args)					\
198 	do {								\
199 		struct tracepoint_func *it_func_ptr;			\
200 		void *__data;						\
201 		it_func_ptr =						\
202 			rcu_dereference_raw((&__tracepoint_##name)->funcs); \
203 		if (it_func_ptr) {					\
204 			__data = (it_func_ptr)->data;			\
205 			static_call(tp_func_##name)(__data, args);	\
206 		}							\
207 	} while (0)
208 #else
209 #define __DO_TRACE_CALL(name, args)	__traceiter_##name(NULL, args)
210 #endif /* CONFIG_HAVE_STATIC_CALL */
211 
212 /*
213  * Declare an exported function that Rust code can call to trigger this
214  * tracepoint. This function does not include the static branch; that is done
215  * in Rust to avoid a function call when the tracepoint is disabled.
216  */
217 #define DEFINE_RUST_DO_TRACE(name, proto, args)
218 #define __DEFINE_RUST_DO_TRACE(name, proto, args)			\
219 	notrace void rust_do_trace_##name(proto)			\
220 	{								\
221 		__rust_do_trace_##name(args);				\
222 	}
223 
224 /*
225  * Make sure the alignment of the structure in the __tracepoints section will
226  * not add unwanted padding between the beginning of the section and the
227  * structure. Force alignment to the same alignment as the section start.
228  *
229  * When lockdep is enabled, we make sure to always test if RCU is
230  * "watching" regardless if the tracepoint is enabled or not. Tracepoints
231  * require RCU to be active, and it should always warn at the tracepoint
232  * site if it is not watching, as it will need to be active when the
233  * tracepoint is enabled.
234  */
235 #define __DECLARE_TRACE_COMMON(name, proto, args, data_proto)		\
236 	extern int __traceiter_##name(data_proto);			\
237 	DECLARE_STATIC_CALL(tp_func_##name, __traceiter_##name);	\
238 	extern struct tracepoint __tracepoint_##name;			\
239 	extern void rust_do_trace_##name(proto);			\
240 	static inline int						\
241 	register_trace_##name(void (*probe)(data_proto), void *data)	\
242 	{								\
243 		return tracepoint_probe_register(&__tracepoint_##name,	\
244 						(void *)probe, data);	\
245 	}								\
246 	static inline int						\
247 	register_trace_prio_##name(void (*probe)(data_proto), void *data,\
248 				   int prio)				\
249 	{								\
250 		return tracepoint_probe_register_prio(&__tracepoint_##name, \
251 					      (void *)probe, data, prio); \
252 	}								\
253 	static inline int						\
254 	unregister_trace_##name(void (*probe)(data_proto), void *data)	\
255 	{								\
256 		return tracepoint_probe_unregister(&__tracepoint_##name,\
257 						(void *)probe, data);	\
258 	}								\
259 	static inline void						\
260 	check_trace_callback_type_##name(void (*cb)(data_proto))	\
261 	{								\
262 	}								\
263 	static inline bool						\
264 	trace_##name##_enabled(void)					\
265 	{								\
266 		return static_branch_unlikely(&__tracepoint_##name.key);\
267 	}
268 
269 #define __DECLARE_TRACE(name, proto, args, cond, data_proto)		\
270 	__DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) \
271 	static inline void __rust_do_trace_##name(proto)		\
272 	{								\
273 		if (cond) {						\
274 			guard(preempt_notrace)();			\
275 			__DO_TRACE_CALL(name, TP_ARGS(args));		\
276 		}							\
277 	}								\
278 	static inline void trace_##name(proto)				\
279 	{								\
280 		if (static_branch_unlikely(&__tracepoint_##name.key)) { \
281 			if (cond) {					\
282 				guard(preempt_notrace)();		\
283 				__DO_TRACE_CALL(name, TP_ARGS(args));	\
284 			}						\
285 		}							\
286 		if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) {		\
287 			WARN_ONCE(!rcu_is_watching(),			\
288 				  "RCU not watching for tracepoint");	\
289 		}							\
290 	}
291 
292 #define __DECLARE_TRACE_SYSCALL(name, proto, args, data_proto)		\
293 	__DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) \
294 	static inline void __rust_do_trace_##name(proto)		\
295 	{								\
296 		guard(rcu_tasks_trace)();				\
297 		__DO_TRACE_CALL(name, TP_ARGS(args));			\
298 	}								\
299 	static inline void trace_##name(proto)				\
300 	{								\
301 		might_fault();						\
302 		if (static_branch_unlikely(&__tracepoint_##name.key)) {	\
303 			guard(rcu_tasks_trace)();			\
304 			__DO_TRACE_CALL(name, TP_ARGS(args));		\
305 		}							\
306 		if (IS_ENABLED(CONFIG_LOCKDEP)) {			\
307 			WARN_ONCE(!rcu_is_watching(),			\
308 				  "RCU not watching for tracepoint");	\
309 		}							\
310 	}
311 
312 /*
313  * We have no guarantee that gcc and the linker won't up-align the tracepoint
314  * structures, so we create an array of pointers that will be used for iteration
315  * on the tracepoints.
316  *
317  * it_func[0] is never NULL because there is at least one element in the array
318  * when the array itself is non NULL.
319  */
320 #define __DEFINE_TRACE_EXT(_name, _ext, proto, args)			\
321 	static const char __tpstrtab_##_name[]				\
322 	__section("__tracepoints_strings") = #_name;			\
323 	extern struct static_call_key STATIC_CALL_KEY(tp_func_##_name);	\
324 	int __traceiter_##_name(void *__data, proto);			\
325 	void __probestub_##_name(void *__data, proto);			\
326 	struct tracepoint __tracepoint_##_name	__used			\
327 	__section("__tracepoints") = {					\
328 		.name = __tpstrtab_##_name,				\
329 		.key = STATIC_KEY_FALSE_INIT,				\
330 		.static_call_key = &STATIC_CALL_KEY(tp_func_##_name),	\
331 		.static_call_tramp = STATIC_CALL_TRAMP_ADDR(tp_func_##_name), \
332 		.iterator = &__traceiter_##_name,			\
333 		.probestub = &__probestub_##_name,			\
334 		.funcs = NULL,						\
335 		.ext = _ext,						\
336 	};								\
337 	__TRACEPOINT_ENTRY(_name);					\
338 	int __traceiter_##_name(void *__data, proto)			\
339 	{								\
340 		struct tracepoint_func *it_func_ptr;			\
341 		void *it_func;						\
342 									\
343 		it_func_ptr =						\
344 			rcu_dereference_raw((&__tracepoint_##_name)->funcs); \
345 		if (it_func_ptr) {					\
346 			do {						\
347 				it_func = READ_ONCE((it_func_ptr)->func); \
348 				__data = (it_func_ptr)->data;		\
349 				((void(*)(void *, proto))(it_func))(__data, args); \
350 			} while ((++it_func_ptr)->func);		\
351 		}							\
352 		return 0;						\
353 	}								\
354 	void __probestub_##_name(void *__data, proto)			\
355 	{								\
356 	}								\
357 	DEFINE_STATIC_CALL(tp_func_##_name, __traceiter_##_name);	\
358 	DEFINE_RUST_DO_TRACE(_name, TP_PROTO(proto), TP_ARGS(args))
359 
360 #define DEFINE_TRACE_FN(_name, _reg, _unreg, _proto, _args)		\
361 	static struct tracepoint_ext __tracepoint_ext_##_name = {	\
362 		.regfunc = _reg,					\
363 		.unregfunc = _unreg,					\
364 		.faultable = false,					\
365 	};								\
366 	__DEFINE_TRACE_EXT(_name, &__tracepoint_ext_##_name, PARAMS(_proto), PARAMS(_args));
367 
368 #define DEFINE_TRACE_SYSCALL(_name, _reg, _unreg, _proto, _args)	\
369 	static struct tracepoint_ext __tracepoint_ext_##_name = {	\
370 		.regfunc = _reg,					\
371 		.unregfunc = _unreg,					\
372 		.faultable = true,					\
373 	};								\
374 	__DEFINE_TRACE_EXT(_name, &__tracepoint_ext_##_name, PARAMS(_proto), PARAMS(_args));
375 
376 #define DEFINE_TRACE(_name, _proto, _args)				\
377 	__DEFINE_TRACE_EXT(_name, NULL, PARAMS(_proto), PARAMS(_args));
378 
379 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)				\
380 	EXPORT_SYMBOL_GPL(__tracepoint_##name);				\
381 	EXPORT_SYMBOL_GPL(__traceiter_##name);				\
382 	EXPORT_STATIC_CALL_GPL(tp_func_##name)
383 #define EXPORT_TRACEPOINT_SYMBOL(name)					\
384 	EXPORT_SYMBOL(__tracepoint_##name);				\
385 	EXPORT_SYMBOL(__traceiter_##name);				\
386 	EXPORT_STATIC_CALL(tp_func_##name)
387 
388 
389 #else /* !TRACEPOINTS_ENABLED */
390 #define __DECLARE_TRACE_COMMON(name, proto, args, data_proto)		\
391 	static inline void trace_##name(proto)				\
392 	{ }								\
393 	static inline int						\
394 	register_trace_##name(void (*probe)(data_proto),		\
395 			      void *data)				\
396 	{								\
397 		return -ENOSYS;						\
398 	}								\
399 	static inline int						\
400 	unregister_trace_##name(void (*probe)(data_proto),		\
401 				void *data)				\
402 	{								\
403 		return -ENOSYS;						\
404 	}								\
405 	static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
406 	{								\
407 	}								\
408 	static inline bool						\
409 	trace_##name##_enabled(void)					\
410 	{								\
411 		return false;						\
412 	}
413 
414 #define __DECLARE_TRACE(name, proto, args, cond, data_proto)		\
415 	__DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto))
416 
417 #define __DECLARE_TRACE_SYSCALL(name, proto, args, data_proto)		\
418 	__DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto))
419 
420 #define DEFINE_TRACE_FN(name, reg, unreg, proto, args)
421 #define DEFINE_TRACE_SYSCALL(name, reg, unreg, proto, args)
422 #define DEFINE_TRACE(name, proto, args)
423 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
424 #define EXPORT_TRACEPOINT_SYMBOL(name)
425 
426 #endif /* TRACEPOINTS_ENABLED */
427 
428 #ifdef CONFIG_TRACING
429 /**
430  * tracepoint_string - register constant persistent string to trace system
431  * @str - a constant persistent string that will be referenced in tracepoints
432  *
433  * If constant strings are being used in tracepoints, it is faster and
434  * more efficient to just save the pointer to the string and reference
435  * that with a printf "%s" instead of saving the string in the ring buffer
436  * and wasting space and time.
437  *
438  * The problem with the above approach is that userspace tools that read
439  * the binary output of the trace buffers do not have access to the string.
440  * Instead they just show the address of the string which is not very
441  * useful to users.
442  *
443  * With tracepoint_string(), the string will be registered to the tracing
444  * system and exported to userspace via the debugfs/tracing/printk_formats
445  * file that maps the string address to the string text. This way userspace
446  * tools that read the binary buffers have a way to map the pointers to
447  * the ASCII strings they represent.
448  *
449  * The @str used must be a constant string and persistent as it would not
450  * make sense to show a string that no longer exists. But it is still fine
451  * to be used with modules, because when modules are unloaded, if they
452  * had tracepoints, the ring buffers are cleared too. As long as the string
453  * does not change during the life of the module, it is fine to use
454  * tracepoint_string() within a module.
455  */
456 #define tracepoint_string(str)						\
457 	({								\
458 		static const char *___tp_str __tracepoint_string = str; \
459 		___tp_str;						\
460 	})
461 #define __tracepoint_string	__used __section("__tracepoint_str")
462 #else
463 /*
464  * tracepoint_string() is used to save the string address for userspace
465  * tracing tools. When tracing isn't configured, there's no need to save
466  * anything.
467  */
468 # define tracepoint_string(str) str
469 # define __tracepoint_string
470 #endif
471 
472 #define DECLARE_TRACE(name, proto, args)				\
473 	__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),		\
474 			cpu_online(raw_smp_processor_id()),		\
475 			PARAMS(void *__data, proto))
476 
477 #define DECLARE_TRACE_CONDITION(name, proto, args, cond)		\
478 	__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),		\
479 			cpu_online(raw_smp_processor_id()) && (PARAMS(cond)), \
480 			PARAMS(void *__data, proto))
481 
482 #define DECLARE_TRACE_SYSCALL(name, proto, args)			\
483 	__DECLARE_TRACE_SYSCALL(name, PARAMS(proto), PARAMS(args),	\
484 				PARAMS(void *__data, proto))
485 
486 #define TRACE_EVENT_FLAGS(event, flag)
487 
488 #define TRACE_EVENT_PERF_PERM(event, expr...)
489 
490 #endif /* DECLARE_TRACE */
491 
492 #ifndef TRACE_EVENT
493 /*
494  * For use with the TRACE_EVENT macro:
495  *
496  * We define a tracepoint, its arguments, its printk format
497  * and its 'fast binary record' layout.
498  *
499  * Firstly, name your tracepoint via TRACE_EVENT(name : the
500  * 'subsystem_event' notation is fine.
501  *
502  * Think about this whole construct as the
503  * 'trace_sched_switch() function' from now on.
504  *
505  *
506  *  TRACE_EVENT(sched_switch,
507  *
508  *	*
509  *	* A function has a regular function arguments
510  *	* prototype, declare it via TP_PROTO():
511  *	*
512  *
513  *	TP_PROTO(struct rq *rq, struct task_struct *prev,
514  *		 struct task_struct *next),
515  *
516  *	*
517  *	* Define the call signature of the 'function'.
518  *	* (Design sidenote: we use this instead of a
519  *	*  TP_PROTO1/TP_PROTO2/TP_PROTO3 ugliness.)
520  *	*
521  *
522  *	TP_ARGS(rq, prev, next),
523  *
524  *	*
525  *	* Fast binary tracing: define the trace record via
526  *	* TP_STRUCT__entry(). You can think about it like a
527  *	* regular C structure local variable definition.
528  *	*
529  *	* This is how the trace record is structured and will
530  *	* be saved into the ring buffer. These are the fields
531  *	* that will be exposed to user-space in
532  *	* /sys/kernel/tracing/events/<*>/format.
533  *	*
534  *	* The declared 'local variable' is called '__entry'
535  *	*
536  *	* __field(pid_t, prev_pid) is equivalent to a standard declaration:
537  *	*
538  *	*	pid_t	prev_pid;
539  *	*
540  *	* __array(char, prev_comm, TASK_COMM_LEN) is equivalent to:
541  *	*
542  *	*	char	prev_comm[TASK_COMM_LEN];
543  *	*
544  *
545  *	TP_STRUCT__entry(
546  *		__array(	char,	prev_comm,	TASK_COMM_LEN	)
547  *		__field(	pid_t,	prev_pid			)
548  *		__field(	int,	prev_prio			)
549  *		__array(	char,	next_comm,	TASK_COMM_LEN	)
550  *		__field(	pid_t,	next_pid			)
551  *		__field(	int,	next_prio			)
552  *	),
553  *
554  *	*
555  *	* Assign the entry into the trace record, by embedding
556  *	* a full C statement block into TP_fast_assign(). You
557  *	* can refer to the trace record as '__entry' -
558  *	* otherwise you can put arbitrary C code in here.
559  *	*
560  *	* Note: this C code will execute every time a trace event
561  *	* happens, on an active tracepoint.
562  *	*
563  *
564  *	TP_fast_assign(
565  *		memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
566  *		__entry->prev_pid	= prev->pid;
567  *		__entry->prev_prio	= prev->prio;
568  *		memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
569  *		__entry->next_pid	= next->pid;
570  *		__entry->next_prio	= next->prio;
571  *	),
572  *
573  *	*
574  *	* Formatted output of a trace record via TP_printk().
575  *	* This is how the tracepoint will appear under ftrace
576  *	* plugins that make use of this tracepoint.
577  *	*
578  *	* (raw-binary tracing wont actually perform this step.)
579  *	*
580  *
581  *	TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
582  *		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
583  *		__entry->next_comm, __entry->next_pid, __entry->next_prio),
584  *
585  * );
586  *
587  * This macro construct is thus used for the regular printk format
588  * tracing setup, it is used to construct a function pointer based
589  * tracepoint callback (this is used by programmatic plugins and
590  * can also by used by generic instrumentation like SystemTap), and
591  * it is also used to expose a structured trace record in
592  * /sys/kernel/tracing/events/.
593  *
594  * A set of (un)registration functions can be passed to the variant
595  * TRACE_EVENT_FN to perform any (un)registration work.
596  */
597 
598 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
599 #define DEFINE_EVENT(template, name, proto, args)		\
600 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
601 #define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg)\
602 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
603 #define DEFINE_EVENT_PRINT(template, name, proto, args, print)	\
604 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
605 #define DEFINE_EVENT_CONDITION(template, name, proto,		\
606 			       args, cond)			\
607 	DECLARE_TRACE_CONDITION(name, PARAMS(proto),		\
608 				PARAMS(args), PARAMS(cond))
609 
610 #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
611 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
612 #define TRACE_EVENT_FN(name, proto, args, struct,		\
613 		assign, print, reg, unreg)			\
614 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
615 #define TRACE_EVENT_FN_COND(name, proto, args, cond, struct,		\
616 		assign, print, reg, unreg)			\
617 	DECLARE_TRACE_CONDITION(name, PARAMS(proto),	\
618 			PARAMS(args), PARAMS(cond))
619 #define TRACE_EVENT_CONDITION(name, proto, args, cond,		\
620 			      struct, assign, print)		\
621 	DECLARE_TRACE_CONDITION(name, PARAMS(proto),		\
622 				PARAMS(args), PARAMS(cond))
623 #define TRACE_EVENT_SYSCALL(name, proto, args, struct, assign,	\
624 			    print, reg, unreg)			\
625 	DECLARE_TRACE_SYSCALL(name, PARAMS(proto), PARAMS(args))
626 
627 #define TRACE_EVENT_FLAGS(event, flag)
628 
629 #define TRACE_EVENT_PERF_PERM(event, expr...)
630 
631 #define DECLARE_EVENT_NOP(name, proto, args)				\
632 	static inline void trace_##name(proto)				\
633 	{ }								\
634 	static inline bool trace_##name##_enabled(void)			\
635 	{								\
636 		return false;						\
637 	}
638 
639 #define TRACE_EVENT_NOP(name, proto, args, struct, assign, print)	\
640 	DECLARE_EVENT_NOP(name, PARAMS(proto), PARAMS(args))
641 
642 #define DECLARE_EVENT_CLASS_NOP(name, proto, args, tstruct, assign, print)
643 #define DEFINE_EVENT_NOP(template, name, proto, args)			\
644 	DECLARE_EVENT_NOP(name, PARAMS(proto), PARAMS(args))
645 
646 #endif /* ifdef TRACE_EVENT (see note above) */
647