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