1# SPDX-License-Identifier: GPL-2.0-only 2# 3# Architectures that offer an FUNCTION_TRACER implementation should 4# select HAVE_FUNCTION_TRACER: 5# 6 7config USER_STACKTRACE_SUPPORT 8 bool 9 10config NOP_TRACER 11 bool 12 13config HAVE_RETHOOK 14 bool 15 16config RETHOOK 17 bool 18 depends on HAVE_RETHOOK 19 help 20 Enable generic return hooking feature. This is an internal 21 API, which will be used by other function-entry hooking 22 features like fprobe and kprobes. 23 24config HAVE_FUNCTION_TRACER 25 bool 26 help 27 See Documentation/trace/ftrace-design.rst 28 29config HAVE_FUNCTION_GRAPH_TRACER 30 bool 31 help 32 See Documentation/trace/ftrace-design.rst 33 34config HAVE_FUNCTION_GRAPH_FREGS 35 bool 36 37config HAVE_FTRACE_GRAPH_FUNC 38 bool 39 help 40 True if ftrace_graph_func() is defined. 41 42config HAVE_DYNAMIC_FTRACE 43 bool 44 help 45 See Documentation/trace/ftrace-design.rst 46 47config HAVE_DYNAMIC_FTRACE_WITH_REGS 48 bool 49 50config HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS 51 bool 52 53config HAVE_SINGLE_FTRACE_DIRECT_OPS 54 bool 55 56config HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS 57 bool 58 59config HAVE_EXTRA_IPI_TRACEPOINTS 60 bool 61 help 62 For architectures that use ipi_raise, ipi_entry and ipi_exit 63 tracepoints. 64 65config HAVE_DYNAMIC_FTRACE_WITH_ARGS 66 bool 67 help 68 If this is set, then arguments and stack can be found from 69 the ftrace_regs passed into the function callback regs parameter 70 by default, even without setting the REGS flag in the ftrace_ops. 71 This allows for use of ftrace_regs_get_argument() and 72 ftrace_regs_get_stack_pointer(). 73 74config HAVE_FTRACE_REGS_HAVING_PT_REGS 75 bool 76 help 77 If this is set, ftrace_regs has pt_regs, thus it can convert to 78 pt_regs without allocating memory. 79 80config HAVE_DYNAMIC_FTRACE_NO_PATCHABLE 81 bool 82 help 83 If the architecture generates __patchable_function_entries sections 84 but does not want them included in the ftrace locations. 85 86config HAVE_DYNAMIC_FTRACE_WITH_JMP 87 bool 88 help 89 If the architecture supports to replace the __fentry__ with a 90 "jmp" instruction. 91 92config HAVE_SYSCALL_TRACEPOINTS 93 bool 94 help 95 See Documentation/trace/ftrace-design.rst 96 97config HAVE_FENTRY 98 bool 99 help 100 Arch supports the gcc options -pg with -mfentry 101 102config HAVE_NOP_MCOUNT 103 bool 104 help 105 Arch supports the gcc options -pg with -mrecord-mcount and -nop-mcount 106 107config HAVE_OBJTOOL_MCOUNT 108 bool 109 help 110 Arch supports objtool --mcount 111 112config HAVE_OBJTOOL_NOP_MCOUNT 113 bool 114 help 115 Arch supports the objtool options --mcount with --mnop. 116 An architecture can select this if it wants to enable nop'ing 117 of ftrace locations. 118 119config HAVE_C_RECORDMCOUNT 120 bool 121 help 122 C version of recordmcount available? 123 124config HAVE_BUILDTIME_MCOUNT_SORT 125 bool 126 help 127 An architecture selects this if it sorts the mcount_loc section 128 at build time. 129 130config BUILDTIME_MCOUNT_SORT 131 bool 132 default y 133 depends on HAVE_BUILDTIME_MCOUNT_SORT && DYNAMIC_FTRACE 134 help 135 Sort the mcount_loc section at build time. 136 137config TRACER_MAX_TRACE 138 bool 139 select TRACER_SNAPSHOT 140 141config TRACE_CLOCK 142 bool 143 144config RING_BUFFER 145 bool 146 select TRACE_CLOCK 147 select IRQ_WORK 148 149config EVENT_TRACING 150 select CONTEXT_SWITCH_TRACER 151 select GLOB 152 bool 153 154config EVENT_TRACING_TEST 155 tristate "Test for event tracing" if !KUNIT_ALL_TESTS 156 depends on EVENT_TRACING 157 depends on KUNIT 158 default KUNIT_ALL_TESTS 159 help 160 KUnit test for the event tracing implementation. 161 162config CONTEXT_SWITCH_TRACER 163 bool 164 165config RING_BUFFER_ALLOW_SWAP 166 bool 167 help 168 Allow the use of ring_buffer_swap_cpu. 169 Adds a very slight overhead to tracing when enabled. 170 171config PREEMPTIRQ_TRACEPOINTS 172 bool 173 depends on TRACE_PREEMPT_TOGGLE || TRACE_IRQFLAGS 174 select TRACING 175 default y 176 help 177 Create preempt/irq toggle tracepoints if needed, so that other parts 178 of the kernel can use them to generate or add hooks to them. 179 180# All tracer options should select GENERIC_TRACER. For those options that are 181# enabled by all tracers (context switch and event tracer) they select TRACING. 182# This allows those options to appear when no other tracer is selected. But the 183# options do not appear when something else selects it. We need the two options 184# GENERIC_TRACER and TRACING to avoid circular dependencies to accomplish the 185# hiding of the automatic options. 186 187config TRACING 188 bool 189 select RING_BUFFER 190 select STACKTRACE if STACKTRACE_SUPPORT 191 select TRACEPOINTS 192 select NOP_TRACER 193 select BINARY_PRINTF 194 select EVENT_TRACING 195 select TRACE_CLOCK 196 select NEED_TASKS_RCU 197 198config GENERIC_TRACER 199 bool 200 select TRACING 201 202# 203# Minimum requirements an architecture has to meet for us to 204# be able to offer generic tracing facilities: 205# 206config TRACING_SUPPORT 207 bool 208 depends on TRACE_IRQFLAGS_SUPPORT 209 depends on STACKTRACE_SUPPORT 210 default y 211 212menuconfig FTRACE 213 bool "Tracers" 214 depends on TRACING_SUPPORT 215 default y if DEBUG_KERNEL 216 help 217 Enable the kernel tracing infrastructure. 218 219if FTRACE 220 221config TRACEFS_AUTOMOUNT_DEPRECATED 222 bool "Automount tracefs on debugfs [DEPRECATED]" 223 depends on TRACING 224 default y 225 help 226 The tracing interface was moved from /sys/kernel/debug/tracing 227 to /sys/kernel/tracing in 2015, but the tracing file system 228 was still automounted in /sys/kernel/debug for backward 229 compatibility with tooling. 230 231 The new interface has been around for more than 10 years and 232 the old debug mount will soon be removed. 233 234config BOOTTIME_TRACING 235 bool "Boot-time Tracing support" 236 depends on TRACING 237 select BOOT_CONFIG 238 help 239 Enable developer to setup ftrace subsystem via supplemental 240 kernel cmdline at boot time for debugging (tracing) driver 241 initialization and boot process. 242 243config FUNCTION_TRACER 244 bool "Kernel Function Tracer" 245 depends on HAVE_FUNCTION_TRACER 246 select KALLSYMS 247 select GENERIC_TRACER 248 select CONTEXT_SWITCH_TRACER 249 select GLOB 250 select NEED_TASKS_RCU 251 select TASKS_RUDE_RCU 252 help 253 Enable the kernel to trace every kernel function. This is done 254 by using a compiler feature to insert a small, 5-byte No-Operation 255 instruction at the beginning of every kernel function, which NOP 256 sequence is then dynamically patched into a tracer call when 257 tracing is enabled by the administrator. If it's runtime disabled 258 (the bootup default), then the overhead of the instructions is very 259 small and not measurable even in micro-benchmarks (at least on 260 x86, but may have impact on other architectures). 261 262config FUNCTION_GRAPH_TRACER 263 bool "Kernel Function Graph Tracer" 264 depends on HAVE_FUNCTION_GRAPH_TRACER 265 depends on FUNCTION_TRACER 266 depends on !X86_32 || !CC_OPTIMIZE_FOR_SIZE 267 default y 268 help 269 Enable the kernel to trace a function at both its return 270 and its entry. 271 Its first purpose is to trace the duration of functions and 272 draw a call graph for each thread with some information like 273 the return value. This is done by setting the current return 274 address on the current task structure into a stack of calls. 275 276config FUNCTION_GRAPH_RETVAL 277 bool "Kernel Function Graph Return Value" 278 depends on HAVE_FUNCTION_GRAPH_FREGS 279 depends on FUNCTION_GRAPH_TRACER 280 default n 281 help 282 Support recording and printing the function return value when 283 using function graph tracer. It can be helpful to locate functions 284 that return errors. This feature is off by default, and you can 285 enable it via the trace option funcgraph-retval. 286 See Documentation/trace/ftrace.rst 287 288config FUNCTION_GRAPH_RETADDR 289 bool "Kernel Function Graph Return Address" 290 depends on FUNCTION_GRAPH_TRACER 291 default n 292 help 293 Support recording and printing the function return address when 294 using function graph tracer. It can be helpful to locate code line that 295 the function is called. This feature is off by default, and you can 296 enable it via the trace option funcgraph-retaddr. 297 298config FUNCTION_TRACE_ARGS 299 bool 300 depends on PROBE_EVENTS_BTF_ARGS 301 default y 302 help 303 If supported with function argument access API and BTF, then 304 the function tracer and function graph tracer will support printing 305 of function arguments. This feature is off by default, and can be 306 enabled via the trace option func-args (for the function tracer) and 307 funcgraph-args (for the function graph tracer) 308 309config DYNAMIC_FTRACE 310 bool 311 depends on FUNCTION_TRACER 312 depends on HAVE_DYNAMIC_FTRACE 313 default y 314 help 315 This option will modify all the calls to function tracing 316 dynamically (will patch them out of the binary image and 317 replace them with a No-Op instruction) on boot up. During 318 compile time, a table is made of all the locations that ftrace 319 can function trace, and this table is linked into the kernel 320 image. When this is enabled, functions can be individually 321 enabled, and the functions not enabled will not affect 322 performance of the system. 323 324 See the files in /sys/kernel/tracing: 325 available_filter_functions 326 set_ftrace_filter 327 set_ftrace_notrace 328 329 This way a CONFIG_FUNCTION_TRACER kernel is slightly larger, but 330 otherwise has native performance as long as no tracing is active. 331 332config DYNAMIC_FTRACE_WITH_REGS 333 def_bool y 334 depends on DYNAMIC_FTRACE 335 depends on HAVE_DYNAMIC_FTRACE_WITH_REGS 336 337config DYNAMIC_FTRACE_WITH_DIRECT_CALLS 338 def_bool y 339 depends on DYNAMIC_FTRACE_WITH_REGS || DYNAMIC_FTRACE_WITH_ARGS 340 depends on HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS 341 342config DYNAMIC_FTRACE_WITH_CALL_OPS 343 def_bool y 344 depends on HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS 345 346config DYNAMIC_FTRACE_WITH_ARGS 347 def_bool y 348 depends on DYNAMIC_FTRACE 349 depends on HAVE_DYNAMIC_FTRACE_WITH_ARGS 350 351config DYNAMIC_FTRACE_WITH_JMP 352 def_bool y 353 depends on DYNAMIC_FTRACE 354 depends on DYNAMIC_FTRACE_WITH_DIRECT_CALLS 355 depends on HAVE_DYNAMIC_FTRACE_WITH_JMP 356 357config FUNCTION_SELF_TRACING 358 bool "Function trace tracing code" 359 depends on FUNCTION_TRACER 360 help 361 Normally all the tracing code is set to notrace, where the function 362 tracer will ignore all the tracing functions. Sometimes it is useful 363 for debugging to trace some of the tracing infratructure itself. 364 Enable this to allow some of the tracing infrastructure to be traced 365 by the function tracer. Note, this will likely add noise to function 366 tracing if events and other tracing features are enabled along with 367 function tracing. 368 369 If unsure, say N. 370 371config FPROBE 372 bool "Kernel Function Probe (fprobe)" 373 depends on HAVE_FUNCTION_GRAPH_FREGS && HAVE_FTRACE_GRAPH_FUNC 374 depends on DYNAMIC_FTRACE_WITH_ARGS 375 select FUNCTION_GRAPH_TRACER 376 default n 377 help 378 This option enables kernel function probe (fprobe) based on ftrace. 379 The fprobe is similar to kprobes, but probes only for kernel function 380 entries and exits. This also can probe multiple functions by one 381 fprobe. 382 383 If unsure, say N. 384 385config FUNCTION_PROFILER 386 bool "Kernel function profiler" 387 depends on FUNCTION_TRACER 388 default n 389 help 390 This option enables the kernel function profiler. A file is created 391 in debugfs called function_profile_enabled which defaults to zero. 392 When a 1 is echoed into this file profiling begins, and when a 393 zero is entered, profiling stops. A "functions" file is created in 394 the trace_stat directory; this file shows the list of functions that 395 have been hit and their counters. 396 397 If in doubt, say N. 398 399config STACK_TRACER 400 bool "Trace max stack" 401 depends on HAVE_FUNCTION_TRACER 402 select FUNCTION_TRACER 403 select STACKTRACE 404 select KALLSYMS 405 help 406 This special tracer records the maximum stack footprint of the 407 kernel and displays it in /sys/kernel/tracing/stack_trace. 408 409 This tracer works by hooking into every function call that the 410 kernel executes, and keeping a maximum stack depth value and 411 stack-trace saved. If this is configured with DYNAMIC_FTRACE 412 then it will not have any overhead while the stack tracer 413 is disabled. 414 415 To enable the stack tracer on bootup, pass in 'stacktrace' 416 on the kernel command line. 417 418 The stack tracer can also be enabled or disabled via the 419 sysctl kernel.stack_tracer_enabled 420 421 Say N if unsure. 422 423config TRACE_PREEMPT_TOGGLE 424 bool 425 help 426 Enables hooks which will be called when preemption is first disabled, 427 and last enabled. 428 429config IRQSOFF_TRACER 430 bool "Interrupts-off Latency Tracer" 431 default n 432 depends on TRACE_IRQFLAGS_SUPPORT 433 select TRACE_IRQFLAGS 434 select GENERIC_TRACER 435 select TRACER_MAX_TRACE 436 select RING_BUFFER_ALLOW_SWAP 437 select TRACER_SNAPSHOT_PER_CPU_SWAP 438 help 439 This option measures the time spent in irqs-off critical 440 sections, with microsecond accuracy. 441 442 The default measurement method is a maximum search, which is 443 disabled by default and can be runtime (re-)started 444 via: 445 446 echo 0 > /sys/kernel/tracing/tracing_max_latency 447 448 (Note that kernel size and overhead increase with this option 449 enabled. This option and the preempt-off timing option can be 450 used together or separately.) 451 452config PREEMPT_TRACER 453 bool "Preemption-off Latency Tracer" 454 default n 455 depends on PREEMPTION 456 select GENERIC_TRACER 457 select TRACER_MAX_TRACE 458 select RING_BUFFER_ALLOW_SWAP 459 select TRACER_SNAPSHOT_PER_CPU_SWAP 460 select TRACE_PREEMPT_TOGGLE 461 help 462 This option measures the time spent in preemption-off critical 463 sections, with microsecond accuracy. 464 465 The default measurement method is a maximum search, which is 466 disabled by default and can be runtime (re-)started 467 via: 468 469 echo 0 > /sys/kernel/tracing/tracing_max_latency 470 471 (Note that kernel size and overhead increase with this option 472 enabled. This option and the irqs-off timing option can be 473 used together or separately.) 474 475config SCHED_TRACER 476 bool "Scheduling Latency Tracer" 477 select GENERIC_TRACER 478 select CONTEXT_SWITCH_TRACER 479 select TRACER_MAX_TRACE 480 help 481 This tracer tracks the latency of the highest priority task 482 to be scheduled in, starting from the point it has woken up. 483 484config HWLAT_TRACER 485 bool "Tracer to detect hardware latencies (like SMIs)" 486 select GENERIC_TRACER 487 select TRACER_MAX_TRACE 488 help 489 This tracer, when enabled will create one or more kernel threads, 490 depending on what the cpumask file is set to, which each thread 491 spinning in a loop looking for interruptions caused by 492 something other than the kernel. For example, if a 493 System Management Interrupt (SMI) takes a noticeable amount of 494 time, this tracer will detect it. This is useful for testing 495 if a system is reliable for Real Time tasks. 496 497 Some files are created in the tracing directory when this 498 is enabled: 499 500 hwlat_detector/width - time in usecs for how long to spin for 501 hwlat_detector/window - time in usecs between the start of each 502 iteration 503 504 A kernel thread is created that will spin with interrupts disabled 505 for "width" microseconds in every "window" cycle. It will not spin 506 for "window - width" microseconds, where the system can 507 continue to operate. 508 509 The output will appear in the trace and trace_pipe files. 510 511 When the tracer is not running, it has no affect on the system, 512 but when it is running, it can cause the system to be 513 periodically non responsive. Do not run this tracer on a 514 production system. 515 516 To enable this tracer, echo in "hwlat" into the current_tracer 517 file. Every time a latency is greater than tracing_thresh, it will 518 be recorded into the ring buffer. 519 520config OSNOISE_TRACER 521 bool "OS Noise tracer" 522 select GENERIC_TRACER 523 select TRACER_MAX_TRACE 524 help 525 In the context of high-performance computing (HPC), the Operating 526 System Noise (osnoise) refers to the interference experienced by an 527 application due to activities inside the operating system. In the 528 context of Linux, NMIs, IRQs, SoftIRQs, and any other system thread 529 can cause noise to the system. Moreover, hardware-related jobs can 530 also cause noise, for example, via SMIs. 531 532 The osnoise tracer leverages the hwlat_detector by running a similar 533 loop with preemption, SoftIRQs and IRQs enabled, thus allowing all 534 the sources of osnoise during its execution. The osnoise tracer takes 535 note of the entry and exit point of any source of interferences, 536 increasing a per-cpu interference counter. It saves an interference 537 counter for each source of interference. The interference counter for 538 NMI, IRQs, SoftIRQs, and threads is increased anytime the tool 539 observes these interferences' entry events. When a noise happens 540 without any interference from the operating system level, the 541 hardware noise counter increases, pointing to a hardware-related 542 noise. In this way, osnoise can account for any source of 543 interference. At the end of the period, the osnoise tracer prints 544 the sum of all noise, the max single noise, the percentage of CPU 545 available for the thread, and the counters for the noise sources. 546 547 In addition to the tracer, a set of tracepoints were added to 548 facilitate the identification of the osnoise source. 549 550 The output will appear in the trace and trace_pipe files. 551 552 To enable this tracer, echo in "osnoise" into the current_tracer 553 file. 554 555config TIMERLAT_TRACER 556 bool "Timerlat tracer" 557 select OSNOISE_TRACER 558 select GENERIC_TRACER 559 help 560 The timerlat tracer aims to help the preemptive kernel developers 561 to find sources of wakeup latencies of real-time threads. 562 563 The tracer creates a per-cpu kernel thread with real-time priority. 564 The tracer thread sets a periodic timer to wakeup itself, and goes 565 to sleep waiting for the timer to fire. At the wakeup, the thread 566 then computes a wakeup latency value as the difference between 567 the current time and the absolute time that the timer was set 568 to expire. 569 570 The tracer prints two lines at every activation. The first is the 571 timer latency observed at the hardirq context before the 572 activation of the thread. The second is the timer latency observed 573 by the thread, which is the same level that cyclictest reports. The 574 ACTIVATION ID field serves to relate the irq execution to its 575 respective thread execution. 576 577 The tracer is build on top of osnoise tracer, and the osnoise: 578 events can be used to trace the source of interference from NMI, 579 IRQs and other threads. It also enables the capture of the 580 stacktrace at the IRQ context, which helps to identify the code 581 path that can cause thread delay. 582 583config MMIOTRACE 584 bool "Memory mapped IO tracing" 585 depends on HAVE_MMIOTRACE_SUPPORT && PCI 586 select GENERIC_TRACER 587 help 588 Mmiotrace traces Memory Mapped I/O access and is meant for 589 debugging and reverse engineering. It is called from the ioremap 590 implementation and works via page faults. Tracing is disabled by 591 default and can be enabled at run-time. 592 593 See Documentation/trace/mmiotrace.rst. 594 If you are not helping to develop drivers, say N. 595 596config ENABLE_DEFAULT_TRACERS 597 bool "Trace process context switches and events" 598 depends on !GENERIC_TRACER 599 select TRACING 600 help 601 This tracer hooks to various trace points in the kernel, 602 allowing the user to pick and choose which trace point they 603 want to trace. It also includes the sched_switch tracer plugin. 604 605config FTRACE_SYSCALLS 606 bool "Trace syscalls" 607 depends on HAVE_SYSCALL_TRACEPOINTS 608 select GENERIC_TRACER 609 select KALLSYMS 610 help 611 Basic tracer to catch the syscall entry and exit events. 612 613config TRACE_SYSCALL_BUF_SIZE_DEFAULT 614 int "System call user read max size" 615 range 0 165 616 default 63 617 depends on FTRACE_SYSCALLS 618 help 619 Some system call trace events will record the data from a user 620 space address that one of the parameters point to. The amount of 621 data per event is limited. That limit is set by this config and 622 this config also affects how much user space data perf can read. 623 624 For a tracing instance, this size may be changed by writing into 625 its syscall_user_buf_size file. 626 627config TRACER_SNAPSHOT 628 bool "Create a snapshot trace buffer" 629 help 630 Allow tracing users to take snapshot of the current buffer using the 631 ftrace interface, e.g.: 632 633 echo 1 > /sys/kernel/tracing/snapshot 634 cat snapshot 635 636 Note, the latency tracers select this option. To disable it, 637 all the latency tracers need to be disabled. 638 639config TRACER_SNAPSHOT_PER_CPU_SWAP 640 bool "Allow snapshot to swap per CPU" 641 depends on TRACER_SNAPSHOT 642 select RING_BUFFER_ALLOW_SWAP 643 help 644 Allow doing a snapshot of a single CPU buffer instead of a 645 full swap (all buffers). If this is set, then the following is 646 allowed: 647 648 echo 1 > /sys/kernel/tracing/per_cpu/cpu2/snapshot 649 650 After which, only the tracing buffer for CPU 2 was swapped with 651 the main tracing buffer, and the other CPU buffers remain the same. 652 653 When this is enabled, this adds a little more overhead to the 654 trace recording, as it needs to add some checks to synchronize 655 recording with swaps. But this does not affect the performance 656 of the overall system. This is enabled by default when the preempt 657 or irq latency tracers are enabled, as those need to swap as well 658 and already adds the overhead (plus a lot more). 659 660config TRACE_BRANCH_PROFILING 661 bool 662 select GENERIC_TRACER 663 664choice 665 prompt "Branch Profiling" 666 default BRANCH_PROFILE_NONE 667 help 668 The branch profiling is a software profiler. It will add hooks 669 into the C conditionals to test which path a branch takes. 670 671 The likely/unlikely profiler only looks at the conditions that 672 are annotated with a likely or unlikely macro. 673 674 The "all branch" profiler will profile every if-statement in the 675 kernel. This profiler will also enable the likely/unlikely 676 profiler. 677 678 Either of the above profilers adds a bit of overhead to the system. 679 If unsure, choose "No branch profiling". 680 681config BRANCH_PROFILE_NONE 682 bool "No branch profiling" 683 help 684 No branch profiling. Branch profiling adds a bit of overhead. 685 Only enable it if you want to analyse the branching behavior. 686 Otherwise keep it disabled. 687 688config PROFILE_ANNOTATED_BRANCHES 689 bool "Trace likely/unlikely profiler" 690 select TRACE_BRANCH_PROFILING 691 help 692 This tracer profiles all likely and unlikely macros 693 in the kernel. It will display the results in: 694 695 /sys/kernel/tracing/trace_stat/branch_annotated 696 697 Note: this will add a significant overhead; only turn this 698 on if you need to profile the system's use of these macros. 699 700config PROFILE_ALL_BRANCHES 701 bool "Profile all if conditionals" if !FORTIFY_SOURCE 702 select TRACE_BRANCH_PROFILING 703 help 704 This tracer profiles all branch conditions. Every if () 705 taken in the kernel is recorded whether it hit or miss. 706 The results will be displayed in: 707 708 /sys/kernel/tracing/trace_stat/branch_all 709 710 This option also enables the likely/unlikely profiler. 711 712 This configuration, when enabled, will impose a great overhead 713 on the system. This should only be enabled when the system 714 is to be analyzed in much detail. 715endchoice 716 717config TRACING_BRANCHES 718 bool 719 help 720 Selected by tracers that will trace the likely and unlikely 721 conditions. This prevents the tracers themselves from being 722 profiled. Profiling the tracing infrastructure can only happen 723 when the likelys and unlikelys are not being traced. 724 725config BRANCH_TRACER 726 bool "Trace likely/unlikely instances" 727 depends on TRACE_BRANCH_PROFILING 728 select TRACING_BRANCHES 729 help 730 This traces the events of likely and unlikely condition 731 calls in the kernel. The difference between this and the 732 "Trace likely/unlikely profiler" is that this is not a 733 histogram of the callers, but actually places the calling 734 events into a running trace buffer to see when and where the 735 events happened, as well as their results. 736 737 Say N if unsure. 738 739config BLK_DEV_IO_TRACE 740 bool "Support for tracing block IO actions" 741 depends on SYSFS 742 depends on BLOCK 743 select RELAY 744 select DEBUG_FS 745 select TRACEPOINTS 746 select GENERIC_TRACER 747 select STACKTRACE 748 help 749 Say Y here if you want to be able to trace the block layer actions 750 on a given queue. Tracing allows you to see any traffic happening 751 on a block device queue. For more information (and the userspace 752 support tools needed), fetch the blktrace tools from: 753 754 git://git.kernel.dk/blktrace.git 755 756 Tracing also is possible using the ftrace interface, e.g.: 757 758 echo 1 > /sys/block/sda/sda1/trace/enable 759 echo blk > /sys/kernel/tracing/current_tracer 760 cat /sys/kernel/tracing/trace_pipe 761 762 If unsure, say N. 763 764config FPROBE_EVENTS 765 depends on FPROBE 766 depends on HAVE_REGS_AND_STACK_ACCESS_API 767 bool "Enable fprobe-based dynamic events" 768 select TRACING 769 select PROBE_EVENTS 770 select DYNAMIC_EVENTS 771 default y 772 help 773 This allows user to add tracing events on the function entry and 774 exit via ftrace interface. The syntax is same as the kprobe events 775 and the kprobe events on function entry and exit will be 776 transparently converted to this fprobe events. 777 778config PROBE_EVENTS_BTF_ARGS 779 depends on HAVE_FUNCTION_ARG_ACCESS_API 780 depends on FPROBE_EVENTS || KPROBE_EVENTS 781 depends on DEBUG_INFO_BTF 782 bool "Support BTF function arguments for probe events" 783 default y 784 help 785 The user can specify the arguments of the probe event using the names 786 of the arguments of the probed function, when the probe location is a 787 kernel function entry or a tracepoint. 788 This is available only if BTF (BPF Type Format) support is enabled. 789 790config PROBE_EVENTS_DUMP_FETCHARG 791 bool "Dump of dynamic probe event fetch-arguments" 792 depends on PROBE_EVENTS 793 default n 794 help 795 This shows the dump of fetch-arguments of dynamic probe events 796 alongside their event definitions in the dynamic_events file 797 as comment lines. This is useful to debug the probe events. 798 Since this exposes the raw values in the dynamic_events file, 799 it might be a security risk. Only enable it if you need to debug 800 probe events themselves. 801 802config KPROBE_EVENTS 803 depends on KPROBES 804 depends on HAVE_REGS_AND_STACK_ACCESS_API 805 bool "Enable kprobes-based dynamic events" 806 select TRACING 807 select PROBE_EVENTS 808 select DYNAMIC_EVENTS 809 default y 810 help 811 This allows the user to add tracing events (similar to tracepoints) 812 on the fly via the ftrace interface. See 813 Documentation/trace/kprobetrace.rst for more details. 814 815 Those events can be inserted wherever kprobes can probe, and record 816 various register and memory values. 817 818 This option is also required by perf-probe subcommand of perf tools. 819 If you want to use perf tools, this option is strongly recommended. 820 821config KPROBE_EVENTS_ON_NOTRACE 822 bool "Do NOT protect notrace function from kprobe events" 823 depends on KPROBE_EVENTS 824 depends on DYNAMIC_FTRACE 825 default n 826 help 827 This is only for the developers who want to debug ftrace itself 828 using kprobe events. 829 830 If kprobes can use ftrace instead of breakpoint, ftrace related 831 functions are protected from kprobe-events to prevent an infinite 832 recursion or any unexpected execution path which leads to a kernel 833 crash. 834 835 This option disables such protection and allows you to put kprobe 836 events on ftrace functions for debugging ftrace by itself. 837 Note that this might let you shoot yourself in the foot. 838 839 If unsure, say N. 840 841config UPROBE_EVENTS 842 bool "Enable uprobes-based dynamic events" 843 depends on ARCH_SUPPORTS_UPROBES 844 depends on MMU 845 depends on PERF_EVENTS 846 select UPROBES 847 select PROBE_EVENTS 848 select DYNAMIC_EVENTS 849 select TRACING 850 default y 851 help 852 This allows the user to add tracing events on top of userspace 853 dynamic events (similar to tracepoints) on the fly via the trace 854 events interface. Those events can be inserted wherever uprobes 855 can probe, and record various registers. 856 This option is required if you plan to use perf-probe subcommand 857 of perf tools on user space applications. 858 859config EPROBE_EVENTS 860 bool "Enable event-based dynamic events" 861 depends on TRACING 862 depends on HAVE_REGS_AND_STACK_ACCESS_API 863 select PROBE_EVENTS 864 select DYNAMIC_EVENTS 865 default y 866 help 867 Eprobes are dynamic events that can be placed on other existing 868 events. It can be used to limit what fields are recorded in 869 an event or even dereference a field of an event. It can 870 convert the type of an event field. For example, turn an 871 address into a string. 872 873config BPF_EVENTS 874 depends on BPF_SYSCALL 875 depends on (KPROBE_EVENTS || UPROBE_EVENTS) && PERF_EVENTS 876 bool 877 default y 878 help 879 This allows the user to attach BPF programs to kprobe, uprobe, and 880 tracepoint events. 881 882config DYNAMIC_EVENTS 883 def_bool n 884 885config PROBE_EVENTS 886 def_bool n 887 888config BPF_KPROBE_OVERRIDE 889 bool "Enable BPF programs to override a kprobed function" 890 depends on BPF_EVENTS 891 depends on FUNCTION_ERROR_INJECTION 892 default n 893 help 894 Allows BPF to override the execution of a probed function and 895 set a different return value. This is used for error injection. 896 897config FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY 898 bool 899 depends on DYNAMIC_FTRACE 900 901config FTRACE_MCOUNT_USE_CC 902 def_bool y 903 depends on $(cc-option,-mrecord-mcount) 904 depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY 905 depends on DYNAMIC_FTRACE 906 907config FTRACE_MCOUNT_USE_OBJTOOL 908 def_bool y 909 depends on HAVE_OBJTOOL_MCOUNT 910 depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY 911 depends on !FTRACE_MCOUNT_USE_CC 912 depends on DYNAMIC_FTRACE 913 select OBJTOOL 914 915config FTRACE_MCOUNT_USE_RECORDMCOUNT 916 def_bool y 917 depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY 918 depends on !FTRACE_MCOUNT_USE_CC 919 depends on !FTRACE_MCOUNT_USE_OBJTOOL 920 depends on DYNAMIC_FTRACE 921 922config TRACING_MAP 923 bool 924 depends on ARCH_HAVE_NMI_SAFE_CMPXCHG 925 help 926 tracing_map is a special-purpose lock-free map for tracing, 927 separated out as a stand-alone facility in order to allow it 928 to be shared between multiple tracers. It isn't meant to be 929 generally used outside of that context, and is normally 930 selected by tracers that use it. 931 932config SYNTH_EVENTS 933 bool "Synthetic trace events" 934 select TRACING 935 select DYNAMIC_EVENTS 936 default n 937 help 938 Synthetic events are user-defined trace events that can be 939 used to combine data from other trace events or in fact any 940 data source. Synthetic events can be generated indirectly 941 via the trace() action of histogram triggers or directly 942 by way of an in-kernel API. 943 944 See Documentation/trace/events.rst or 945 Documentation/trace/histogram.rst for details and examples. 946 947 If in doubt, say N. 948 949config USER_EVENTS 950 bool "User trace events" 951 select TRACING 952 select DYNAMIC_EVENTS 953 help 954 User trace events are user-defined trace events that 955 can be used like an existing kernel trace event. User trace 956 events are generated by writing to a tracefs file. User 957 processes can determine if their tracing events should be 958 generated by registering a value and bit with the kernel 959 that reflects when it is enabled or not. 960 961 See Documentation/trace/user_events.rst. 962 If in doubt, say N. 963 964config HIST_TRIGGERS 965 bool "Histogram triggers" 966 depends on ARCH_HAVE_NMI_SAFE_CMPXCHG 967 select TRACING_MAP 968 select TRACING 969 select DYNAMIC_EVENTS 970 select SYNTH_EVENTS 971 default n 972 help 973 Hist triggers allow one or more arbitrary trace event fields 974 to be aggregated into hash tables and dumped to stdout by 975 reading a debugfs/tracefs file. They're useful for 976 gathering quick and dirty (though precise) summaries of 977 event activity as an initial guide for further investigation 978 using more advanced tools. 979 980 Inter-event tracing of quantities such as latencies is also 981 supported using hist triggers under this option. 982 983 See Documentation/trace/histogram.rst. 984 If in doubt, say N. 985 986config TRACE_EVENT_INJECT 987 bool "Trace event injection" 988 depends on TRACING 989 help 990 Allow user-space to inject a specific trace event into the ring 991 buffer. This is mainly used for testing purpose. 992 993 If unsure, say N. 994 995config TRACEPOINT_BENCHMARK 996 bool "Add tracepoint that benchmarks tracepoints" 997 help 998 This option creates the tracepoint "benchmark:benchmark_event". 999 When the tracepoint is enabled, it kicks off a kernel thread that 1000 goes into an infinite loop (calling cond_resched() to let other tasks 1001 run), and calls the tracepoint. Each iteration will record the time 1002 it took to write to the tracepoint and the next iteration that 1003 data will be passed to the tracepoint itself. That is, the tracepoint 1004 will report the time it took to do the previous tracepoint. 1005 The string written to the tracepoint is a static string of 128 bytes 1006 to keep the time the same. The initial string is simply a write of 1007 "START". The second string records the cold cache time of the first 1008 write which is not added to the rest of the calculations. 1009 1010 As it is a tight loop, it benchmarks as hot cache. That's fine because 1011 we care most about hot paths that are probably in cache already. 1012 1013 An example of the output: 1014 1015 START 1016 first=3672 [COLD CACHED] 1017 last=632 first=3672 max=632 min=632 avg=316 std=446 std^2=199712 1018 last=278 first=3672 max=632 min=278 avg=303 std=316 std^2=100337 1019 last=277 first=3672 max=632 min=277 avg=296 std=258 std^2=67064 1020 last=273 first=3672 max=632 min=273 avg=292 std=224 std^2=50411 1021 last=273 first=3672 max=632 min=273 avg=288 std=200 std^2=40389 1022 last=281 first=3672 max=632 min=273 avg=287 std=183 std^2=33666 1023 1024 1025config RING_BUFFER_BENCHMARK 1026 tristate "Ring buffer benchmark stress tester" 1027 depends on RING_BUFFER 1028 help 1029 This option creates a test to stress the ring buffer and benchmark it. 1030 It creates its own ring buffer such that it will not interfere with 1031 any other users of the ring buffer (such as ftrace). It then creates 1032 a producer and consumer that will run for 10 seconds and sleep for 1033 10 seconds. Each interval it will print out the number of events 1034 it recorded and give a rough estimate of how long each iteration took. 1035 1036 It does not disable interrupts or raise its priority, so it may be 1037 affected by processes that are running. 1038 1039 If unsure, say N. 1040 1041config TRACE_EVAL_MAP_FILE 1042 bool "Show eval mappings for trace events" 1043 depends on TRACING 1044 help 1045 The "print fmt" of the trace events will show the enum/sizeof names 1046 instead of their values. This can cause problems for user space tools 1047 that use this string to parse the raw data as user space does not know 1048 how to convert the string to its value. 1049 1050 To fix this, there's a special macro in the kernel that can be used 1051 to convert an enum/sizeof into its value. If this macro is used, then 1052 the print fmt strings will be converted to their values. 1053 1054 If something does not get converted properly, this option can be 1055 used to show what enums/sizeof the kernel tried to convert. 1056 1057 This option is for debugging the conversions. A file is created 1058 in the tracing directory called "eval_map" that will show the 1059 names matched with their values and what trace event system they 1060 belong too. 1061 1062 Normally, the mapping of the strings to values will be freed after 1063 boot up or module load. With this option, they will not be freed, as 1064 they are needed for the "eval_map" file. Enabling this option will 1065 increase the memory footprint of the running kernel. 1066 1067 If unsure, say N. 1068 1069config FTRACE_RECORD_RECURSION 1070 bool "Record functions that recurse in function tracing" 1071 depends on FUNCTION_TRACER 1072 help 1073 All callbacks that attach to the function tracing have some sort 1074 of protection against recursion. Even though the protection exists, 1075 it adds overhead. This option will create a file in the tracefs 1076 file system called "recursed_functions" that will list the functions 1077 that triggered a recursion. 1078 1079 This will add more overhead to cases that have recursion. 1080 1081 If unsure, say N 1082 1083config FTRACE_RECORD_RECURSION_SIZE 1084 int "Max number of recursed functions to record" 1085 default 128 1086 depends on FTRACE_RECORD_RECURSION 1087 help 1088 This defines the limit of number of functions that can be 1089 listed in the "recursed_functions" file, that lists all 1090 the functions that caused a recursion to happen. 1091 This file can be reset, but the limit can not change in 1092 size at runtime. 1093 1094config FTRACE_VALIDATE_RCU_IS_WATCHING 1095 bool "Validate RCU is on during ftrace execution" 1096 depends on FUNCTION_TRACER 1097 depends on ARCH_WANTS_NO_INSTR 1098 help 1099 All callbacks that attach to the function tracing have some sort of 1100 protection against recursion. This option is only to verify that 1101 ftrace (and other users of ftrace_test_recursion_trylock()) are not 1102 called outside of RCU, as if they are, it can cause a race. But it 1103 also has a noticeable overhead when enabled. 1104 1105 If unsure, say N 1106 1107config RING_BUFFER_RECORD_RECURSION 1108 bool "Record functions that recurse in the ring buffer" 1109 depends on FTRACE_RECORD_RECURSION 1110 # default y, because it is coupled with FTRACE_RECORD_RECURSION 1111 default y 1112 help 1113 The ring buffer has its own internal recursion. Although when 1114 recursion happens it won't cause harm because of the protection, 1115 but it does cause unwanted overhead. Enabling this option will 1116 place where recursion was detected into the ftrace "recursed_functions" 1117 file. 1118 1119 This will add more overhead to cases that have recursion. 1120 1121config GCOV_PROFILE_FTRACE 1122 bool "Enable GCOV profiling on ftrace subsystem" 1123 depends on GCOV_KERNEL 1124 help 1125 Enable GCOV profiling on ftrace subsystem for checking 1126 which functions/lines are tested. 1127 1128 If unsure, say N. 1129 1130 Note that on a kernel compiled with this config, ftrace will 1131 run significantly slower. 1132 1133config FTRACE_SELFTEST 1134 bool 1135 1136config FTRACE_STARTUP_TEST 1137 bool "Perform a startup test on ftrace" 1138 depends on GENERIC_TRACER 1139 select FTRACE_SELFTEST 1140 help 1141 This option performs a series of startup tests on ftrace. On bootup 1142 a series of tests are made to verify that the tracer is 1143 functioning properly. It will do tests on all the configured 1144 tracers of ftrace. 1145 1146config EVENT_TRACE_STARTUP_TEST 1147 bool "Run selftest on trace events" 1148 depends on FTRACE_STARTUP_TEST 1149 default y 1150 help 1151 This option performs a test on all trace events in the system. 1152 It basically just enables each event and runs some code that 1153 will trigger events (not necessarily the event it enables) 1154 This may take some time run as there are a lot of events. 1155 1156config EVENT_TRACE_TEST_SYSCALLS 1157 bool "Run selftest on syscall events" 1158 depends on EVENT_TRACE_STARTUP_TEST 1159 help 1160 This option will also enable testing every syscall event. 1161 It only enables the event and disables it and runs various loads 1162 with the event enabled. This adds a bit more time for kernel boot 1163 up since it runs this on every system call defined. 1164 1165 TBD - enable a way to actually call the syscalls as we test their 1166 events 1167 1168config FTRACE_SORT_STARTUP_TEST 1169 bool "Verify compile time sorting of ftrace functions" 1170 depends on DYNAMIC_FTRACE 1171 depends on BUILDTIME_MCOUNT_SORT 1172 help 1173 Sorting of the mcount_loc sections that is used to find the 1174 where the ftrace knows where to patch functions for tracing 1175 and other callbacks is done at compile time. But if the sort 1176 is not done correctly, it will cause non-deterministic failures. 1177 When this is set, the sorted sections will be verified that they 1178 are in deed sorted and will warn if they are not. 1179 1180 If unsure, say N 1181 1182config RING_BUFFER_STARTUP_TEST 1183 bool "Ring buffer startup self test" 1184 depends on RING_BUFFER 1185 help 1186 Run a simple self test on the ring buffer on boot up. Late in the 1187 kernel boot sequence, the test will start that kicks off 1188 a thread per cpu. Each thread will write various size events 1189 into the ring buffer. Another thread is created to send IPIs 1190 to each of the threads, where the IPI handler will also write 1191 to the ring buffer, to test/stress the nesting ability. 1192 If any anomalies are discovered, a warning will be displayed 1193 and all ring buffers will be disabled. 1194 1195 The test runs for 10 seconds. This will slow your boot time 1196 by at least 10 more seconds. 1197 1198 At the end of the test, statistics and more checks are done. 1199 It will output the stats of each per cpu buffer: What 1200 was written, the sizes, what was read, what was lost, and 1201 other similar details. 1202 1203 If unsure, say N 1204 1205config RING_BUFFER_VALIDATE_TIME_DELTAS 1206 bool "Verify ring buffer time stamp deltas" 1207 depends on RING_BUFFER 1208 help 1209 This will audit the time stamps on the ring buffer sub 1210 buffer to make sure that all the time deltas for the 1211 events on a sub buffer matches the current time stamp. 1212 This audit is performed for every event that is not 1213 interrupted, or interrupting another event. A check 1214 is also made when traversing sub buffers to make sure 1215 that all the deltas on the previous sub buffer do not 1216 add up to be greater than the current time stamp. 1217 1218 NOTE: This adds significant overhead to recording of events, 1219 and should only be used to test the logic of the ring buffer. 1220 Do not use it on production systems. 1221 1222 Only say Y if you understand what this does, and you 1223 still want it enabled. Otherwise say N 1224 1225config RING_BUFFER_PERSISTENT_INJECT 1226 bool "Enable persistent ring buffer error injection test" 1227 depends on RING_BUFFER 1228 help 1229 This option will have the kernel check if the persistent ring 1230 buffer is named "ptracingtest". and if so, it will corrupt some 1231 of its pages on a kernel panic. This is used to test if the 1232 persistent ring buffer can recover from some of its sub-buffers 1233 being corrupted. 1234 To use this, boot a kernel with a "ptracingtest" persistent 1235 ring buffer, e.g. 1236 1237 reserve_mem=20M:2M:trace trace_instance=ptracingtest@trace panic=1 1238 1239 And after the 1st boot, run the following commands: 1240 1241 cd /sys/kernel/tracing/instances/ptracingtest 1242 echo 1 > events/enable 1243 echo 1 > tracing_on 1244 sleep 3 1245 echo c > /proc/sysrq-trigger 1246 1247 After the panic message, the kernel will reboot and will show 1248 the test results in the console output. 1249 1250 Note that events for the test ring buffer needs to be enabled 1251 prior to crashing the kernel so that the ring buffer has content 1252 that the test will corrupt. 1253 As the test will corrupt events in the "ptracingtest" persistent 1254 ring buffer, it should not be used for any other purpose other 1255 than this test. 1256 1257 If unsure, say N 1258 1259config MMIOTRACE_TEST 1260 tristate "Test module for mmiotrace" 1261 depends on MMIOTRACE && m 1262 help 1263 This is a dumb module for testing mmiotrace. It is very dangerous 1264 as it will write garbage to IO memory starting at a given address. 1265 However, it should be safe to use on e.g. unused portion of VRAM. 1266 1267 Say N, unless you absolutely know what you are doing. 1268 1269config PREEMPTIRQ_DELAY_TEST 1270 tristate "Test module to create a preempt / IRQ disable delay thread to test latency tracers" 1271 depends on m 1272 help 1273 Select this option to build a test module that can help test latency 1274 tracers by executing a preempt or irq disable section with a user 1275 configurable delay. The module busy waits for the duration of the 1276 critical section. 1277 1278 For example, the following invocation generates a burst of three 1279 irq-disabled critical sections for 500us: 1280 modprobe preemptirq_delay_test test_mode=irq delay=500 burst_size=3 1281 1282 What's more, if you want to attach the test on the cpu which the latency 1283 tracer is running on, specify cpu_affinity=cpu_num at the end of the 1284 command. 1285 1286 If unsure, say N 1287 1288config SYNTH_EVENT_GEN_TEST 1289 tristate "Test module for in-kernel synthetic event generation" 1290 depends on SYNTH_EVENTS && m 1291 help 1292 This option creates a test module to check the base 1293 functionality of in-kernel synthetic event definition and 1294 generation. 1295 1296 To test, insert the module, and then check the trace buffer 1297 for the generated sample events. 1298 1299 If unsure, say N. 1300 1301config KPROBE_EVENT_GEN_TEST 1302 tristate "Test module for in-kernel kprobe event generation" 1303 depends on KPROBE_EVENTS && m 1304 help 1305 This option creates a test module to check the base 1306 functionality of in-kernel kprobe event definition. 1307 1308 To test, insert the module, and then check the trace buffer 1309 for the generated kprobe events. 1310 1311 If unsure, say N. 1312 1313config HIST_TRIGGERS_DEBUG 1314 bool "Hist trigger debug support" 1315 depends on HIST_TRIGGERS 1316 help 1317 Add "hist_debug" file for each event, which when read will 1318 dump out a bunch of internal details about the hist triggers 1319 defined on that event. 1320 1321 The hist_debug file serves a couple of purposes: 1322 1323 - Helps developers verify that nothing is broken. 1324 1325 - Provides educational information to support the details 1326 of the hist trigger internals as described by 1327 Documentation/trace/histogram-design.rst. 1328 1329 The hist_debug output only covers the data structures 1330 related to the histogram definitions themselves and doesn't 1331 display the internals of map buckets or variable values of 1332 running histograms. 1333 1334 If unsure, say N. 1335 1336source "kernel/trace/rv/Kconfig" 1337 1338config TRACE_REMOTE 1339 bool 1340 1341config SIMPLE_RING_BUFFER 1342 bool 1343 1344config TRACE_REMOTE_TEST 1345 tristate "Test module for remote tracing" 1346 select TRACE_REMOTE 1347 select SIMPLE_RING_BUFFER 1348 help 1349 This trace remote includes a ring-buffer writer implementation using 1350 "simple_ring_buffer". This is solely intending for testing. 1351 1352endif # FTRACE 1353