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