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