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