xref: /linux/lib/Kconfig.debug (revision 8341c989ac77d712c7d6e2bce29e8a4bcb2eeae4)
1# SPDX-License-Identifier: GPL-2.0-only
2menu "Kernel hacking"
3
4menu "printk and dmesg options"
5
6config PRINTK_TIME
7	bool "Show timing information on printks"
8	depends on PRINTK
9	help
10	  Selecting this option causes time stamps of the printk()
11	  messages to be added to the output of the syslog() system
12	  call and at the console.
13
14	  The timestamp is always recorded internally, and exported
15	  to /dev/kmsg. This flag just specifies if the timestamp should
16	  be included, not that the timestamp is recorded.
17
18	  The behavior is also controlled by the kernel command line
19	  parameter printk.time=1. See Documentation/admin-guide/kernel-parameters.rst
20
21config PRINTK_CALLER
22	bool "Show caller information on printks"
23	depends on PRINTK
24	help
25	  Selecting this option causes printk() to add a caller "thread id" (if
26	  in task context) or a caller "processor id" (if not in task context)
27	  to every message.
28
29	  This option is intended for environments where multiple threads
30	  concurrently call printk() for many times, for it is difficult to
31	  interpret without knowing where these lines (or sometimes individual
32	  line which was divided into multiple lines due to race) came from.
33
34	  Since toggling after boot makes the code racy, currently there is
35	  no option to enable/disable at the kernel command line parameter or
36	  sysfs interface.
37
38config PRINTK_EXECUTION_CTX
39	bool
40	depends on PRINTK
41	help
42	  This option extends struct printk_info to include extra execution
43	  context in printk, such as task name and CPU number from where the
44	  message originated. This is useful for correlating printk messages
45	  with specific execution contexts.
46
47	  This is automatically enabled when a console driver that supports
48	  execution context is selected.
49
50config STACKTRACE_BUILD_ID
51	bool "Show build ID information in stacktraces"
52	depends on PRINTK
53	help
54	  Selecting this option adds build ID information for symbols in
55	  stacktraces printed with the printk format '%p[SR]b'.
56
57	  This option is intended for distros where debuginfo is not easily
58	  accessible but can be downloaded given the build ID of the vmlinux or
59	  kernel module where the function is located.
60
61config CONSOLE_LOGLEVEL_DEFAULT
62	int "Default console loglevel (1-15)"
63	range 1 15
64	default "7"
65	help
66	  Default loglevel to determine what will be printed on the console.
67
68	  Setting a default here is equivalent to passing in loglevel=<x> in
69	  the kernel bootargs. loglevel=<x> continues to override whatever
70	  value is specified here as well.
71
72	  Note: This does not affect the log level of un-prefixed printk()
73	  usage in the kernel. That is controlled by the MESSAGE_LOGLEVEL_DEFAULT
74	  option.
75
76config CONSOLE_LOGLEVEL_QUIET
77	int "quiet console loglevel (1-15)"
78	range 1 15
79	default "4"
80	help
81	  loglevel to use when "quiet" is passed on the kernel commandline.
82
83	  When "quiet" is passed on the kernel commandline this loglevel
84	  will be used as the loglevel. IOW passing "quiet" will be the
85	  equivalent of passing "loglevel=<CONSOLE_LOGLEVEL_QUIET>"
86
87config MESSAGE_LOGLEVEL_DEFAULT
88	int "Default message log level (1-7)"
89	range 1 7
90	default "4"
91	help
92	  Default log level for printk statements with no specified priority.
93
94	  This was hard-coded to KERN_WARNING since at least 2.6.10 but folks
95	  that are auditing their logs closely may want to set it to a lower
96	  priority.
97
98	  Note: This does not affect what message level gets printed on the console
99	  by default. To change that, use loglevel=<x> in the kernel bootargs,
100	  or pick a different CONSOLE_LOGLEVEL_DEFAULT configuration value.
101
102config BOOT_PRINTK_DELAY
103	bool "Delay each boot printk message by N milliseconds"
104	depends on DEBUG_KERNEL && PRINTK && GENERIC_CALIBRATE_DELAY
105	help
106	  This build option allows you to read kernel boot messages
107	  by inserting a short delay after each one.  The delay is
108	  specified in milliseconds on the kernel command line,
109	  using "boot_delay=N".
110
111	  It is likely that you would also need to use "lpj=M" to preset
112	  the "loops per jiffy" value.
113	  See a previous boot log for the "lpj" value to use for your
114	  system, and then set "lpj=M" before setting "boot_delay=N".
115	  NOTE:  Using this option may adversely affect SMP systems.
116	  I.e., processors other than the first one may not boot up.
117	  BOOT_PRINTK_DELAY also may cause LOCKUP_DETECTOR to detect
118	  what it believes to be lockup conditions.
119
120config DYNAMIC_DEBUG
121	bool "Enable dynamic printk() support"
122	default n
123	depends on PRINTK
124	depends on (DEBUG_FS || PROC_FS)
125	select DYNAMIC_DEBUG_CORE
126	help
127
128	  Compiles debug level messages into the kernel, which would not
129	  otherwise be available at runtime. These messages can then be
130	  enabled/disabled based on various levels of scope - per source file,
131	  function, module, format string, and line number. This mechanism
132	  implicitly compiles in all pr_debug() and dev_dbg() calls, which
133	  enlarges the kernel text size by about 2%.
134
135	  If a source file is compiled with DEBUG flag set, any
136	  pr_debug() calls in it are enabled by default, but can be
137	  disabled at runtime as below.  Note that DEBUG flag is
138	  turned on by many CONFIG_*DEBUG* options.
139
140	  Usage:
141
142	  Dynamic debugging is controlled via the 'dynamic_debug/control' file,
143	  which is contained in the 'debugfs' filesystem or procfs.
144	  Thus, the debugfs or procfs filesystem must first be mounted before
145	  making use of this feature.
146	  We refer the control file as: <debugfs>/dynamic_debug/control. This
147	  file contains a list of the debug statements that can be enabled. The
148	  format for each line of the file is:
149
150		filename:lineno [module]function flags format
151
152	  filename : source file of the debug statement
153	  lineno : line number of the debug statement
154	  module : module that contains the debug statement
155	  function : function that contains the debug statement
156	  flags : '=p' means the line is turned 'on' for printing
157	  format : the format used for the debug statement
158
159	  From a live system:
160
161		nullarbor:~ # cat <debugfs>/dynamic_debug/control
162		# filename:lineno [module]function flags format
163		fs/aio.c:222 [aio]__put_ioctx =_ "__put_ioctx:\040freeing\040%p\012"
164		fs/aio.c:248 [aio]ioctx_alloc =_ "ENOMEM:\040nr_events\040too\040high\012"
165		fs/aio.c:1770 [aio]sys_io_cancel =_ "calling\040cancel\012"
166
167	  Example usage:
168
169		// enable the message at line 1603 of file svcsock.c
170		nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
171						<debugfs>/dynamic_debug/control
172
173		// enable all the messages in file svcsock.c
174		nullarbor:~ # echo -n 'file svcsock.c +p' >
175						<debugfs>/dynamic_debug/control
176
177		// enable all the messages in the NFS server module
178		nullarbor:~ # echo -n 'module nfsd +p' >
179						<debugfs>/dynamic_debug/control
180
181		// enable all 12 messages in the function svc_process()
182		nullarbor:~ # echo -n 'func svc_process +p' >
183						<debugfs>/dynamic_debug/control
184
185		// disable all 12 messages in the function svc_process()
186		nullarbor:~ # echo -n 'func svc_process -p' >
187						<debugfs>/dynamic_debug/control
188
189	  See Documentation/admin-guide/dynamic-debug-howto.rst for additional
190	  information.
191
192config DYNAMIC_DEBUG_CORE
193	bool "Enable core function of dynamic debug support"
194	depends on PRINTK
195	depends on (DEBUG_FS || PROC_FS)
196	help
197	  Enable core functional support of dynamic debug. It is useful
198	  when you want to tie dynamic debug to your kernel modules with
199	  DYNAMIC_DEBUG_MODULE defined for each of them, especially for
200	  the case of embedded system where the kernel image size is
201	  sensitive for people.
202
203config SYMBOLIC_ERRNAME
204	bool "Support symbolic error names in printf"
205	default y if PRINTK
206	help
207	  If you say Y here, the kernel's printf implementation will
208	  be able to print symbolic error names such as ENOSPC instead
209	  of the number 28. It makes the kernel image slightly larger
210	  (about 3KB), but can make the kernel logs easier to read.
211
212config DEBUG_BUGVERBOSE
213	bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EXPERT
214	depends on BUG && (GENERIC_BUG || HAVE_DEBUG_BUGVERBOSE)
215	default y
216	help
217	  Say Y here to make BUG() panics output the file name and line number
218	  of the BUG call as well as the EIP and oops trace.  This aids
219	  debugging but costs about 70-100K of memory.
220
221config DEBUG_BUGVERBOSE_DETAILED
222	bool "Verbose WARN_ON_ONCE() reporting (adds 100K)" if DEBUG_BUGVERBOSE
223	help
224	  Say Y here to make WARN_ON_ONCE() output the condition string of the
225	  warning, in addition to the file name and line number.
226	  This helps debugging, but costs about 100K of memory.
227
228	  Say N if unsure.
229
230
231endmenu # "printk and dmesg options"
232
233config DEBUG_KERNEL
234	bool "Kernel debugging"
235	help
236	  Say Y here if you are developing drivers or trying to debug and
237	  identify kernel problems.
238
239config DEBUG_MISC
240	bool "Miscellaneous debug code"
241	default DEBUG_KERNEL
242	depends on DEBUG_KERNEL
243	help
244	  Say Y here if you need to enable miscellaneous debug code that should
245	  be under a more specific debug option but isn't.
246
247menu "Compile-time checks and compiler options"
248
249config DEBUG_INFO
250	bool
251	help
252	  A kernel debug info option other than "None" has been selected
253	  in the "Debug information" choice below, indicating that debug
254	  information will be generated for build targets.
255
256# Clang generates .uleb128 with label differences for DWARF v5, a feature that
257# older binutils ports do not support when utilizing RISC-V style linker
258# relaxation: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
259config AS_HAS_NON_CONST_ULEB128
260	def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:)
261
262choice
263	prompt "Debug information"
264	depends on DEBUG_KERNEL
265	help
266	  Selecting something other than "None" results in a kernel image
267	  that will include debugging info resulting in a larger kernel image.
268	  This adds debug symbols to the kernel and modules (gcc -g), and
269	  is needed if you intend to use kernel crashdump or binary object
270	  tools like crash, kgdb, LKCD, gdb, etc on the kernel.
271
272	  Choose which version of DWARF debug info to emit. If unsure,
273	  select "Toolchain default".
274
275config DEBUG_INFO_NONE
276	bool "Disable debug information"
277	help
278	  Do not build the kernel with debugging information, which will
279	  result in a faster and smaller build.
280
281config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
282	bool "Rely on the toolchain's implicit default DWARF version"
283	select DEBUG_INFO
284	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
285	help
286	  The implicit default version of DWARF debug info produced by a
287	  toolchain changes over time.
288
289	  This can break consumers of the debug info that haven't upgraded to
290	  support newer revisions, and prevent testing newer versions, but
291	  those should be less common scenarios.
292
293config DEBUG_INFO_DWARF4
294	bool "Generate DWARF Version 4 debuginfo"
295	select DEBUG_INFO
296	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
297	help
298	  Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
299	  if using clang without clang's integrated assembler, and gdb 7.0+.
300
301	  If you have consumers of DWARF debug info that are not ready for
302	  newer revisions of DWARF, you may wish to choose this or have your
303	  config select this.
304
305config DEBUG_INFO_DWARF5
306	bool "Generate DWARF Version 5 debuginfo"
307	select DEBUG_INFO
308	depends on !ARCH_HAS_BROKEN_DWARF5
309	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
310	help
311	  Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
312	  5.0+ accepts the -gdwarf-5 flag but only had partial support for some
313	  draft features until 7.0), and gdb 8.0+.
314
315	  Changes to the structure of debug info in Version 5 allow for around
316	  15-18% savings in resulting image and debug info section sizes as
317	  compared to DWARF Version 4. DWARF Version 5 standardizes previous
318	  extensions such as accelerators for symbol indexing and the format
319	  for fission (.dwo/.dwp) files. Users may not want to select this
320	  config if they rely on tooling that has not yet been updated to
321	  support DWARF Version 5.
322
323endchoice # "Debug information"
324
325if DEBUG_INFO
326
327config DEBUG_INFO_REDUCED
328	bool "Reduce debugging information"
329	help
330	  If you say Y here gcc is instructed to generate less debugging
331	  information for structure types. This means that tools that
332	  need full debugging information (like kgdb or systemtap) won't
333	  be happy. But if you merely need debugging information to
334	  resolve line numbers there is no loss. Advantage is that
335	  build directory object sizes shrink dramatically over a full
336	  DEBUG_INFO build and compile times are reduced too.
337	  Only works with newer gcc versions.
338
339choice
340	prompt "Compressed Debug information"
341	help
342	  Compress the resulting debug info. Results in smaller debug info sections,
343	  but requires that consumers are able to decompress the results.
344
345	  If unsure, choose DEBUG_INFO_COMPRESSED_NONE.
346
347config DEBUG_INFO_COMPRESSED_NONE
348	bool "Don't compress debug information"
349	help
350	  Don't compress debug info sections.
351
352config DEBUG_INFO_COMPRESSED_ZLIB
353	bool "Compress debugging information with zlib"
354	depends on $(cc-option,-gz=zlib)
355	depends on $(ld-option,--compress-debug-sections=zlib)
356	help
357	  Compress the debug information using zlib.
358
359	  Users of dpkg-deb via debian/rules may find an increase in
360	  size of their debug .deb packages with this config set, due to the
361	  debug info being compressed with zlib, then the object files being
362	  recompressed with a different compression scheme. But this is still
363	  preferable to setting KDEB_COMPRESS or DPKG_DEB_COMPRESSOR_TYPE to
364	  "none" which would be even larger.
365
366config DEBUG_INFO_COMPRESSED_ZSTD
367	bool "Compress debugging information with zstd"
368	depends on $(cc-option,-gz=zstd)
369	depends on $(ld-option,--compress-debug-sections=zstd)
370	help
371	  Compress the debug information using zstd.  This may provide better
372	  compression than zlib, for about the same time costs, but requires newer
373	  toolchain support.  Requires GCC 13.0+ or Clang 16.0+, binutils 2.40+, and
374	  zstd.
375
376endchoice # "Compressed Debug information"
377
378config DEBUG_INFO_SPLIT
379	bool "Produce split debuginfo in .dwo files"
380	depends on $(cc-option,-gsplit-dwarf)
381	# RISC-V linker relaxation + -gsplit-dwarf has issues with LLVM and GCC
382	# prior to 12.x:
383	# https://github.com/llvm/llvm-project/issues/56642
384	# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99090
385	depends on !RISCV || GCC_VERSION >= 120000
386	help
387	  Generate debug info into separate .dwo files. This significantly
388	  reduces the build directory size for builds with DEBUG_INFO,
389	  because it stores the information only once on disk in .dwo
390	  files instead of multiple times in object files and executables.
391	  In addition the debug information is also compressed.
392
393	  Requires recent gcc (4.7+) and recent gdb/binutils.
394	  Any tool that packages or reads debug information would need
395	  to know about the .dwo files and include them.
396	  Incompatible with older versions of ccache.
397
398config DEBUG_INFO_BTF
399	bool "Generate BTF type information"
400	depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
401	depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
402	depends on BPF_SYSCALL
403	depends on PAHOLE_VERSION >= 122
404	# pahole uses elfutils, which does not have support for Hexagon relocations
405	depends on !HEXAGON
406	help
407	  Generate deduplicated BTF type information from DWARF debug info.
408	  Turning this on requires pahole v1.22 or later, which will convert
409	  DWARF type info into equivalent deduplicated BTF type info.
410
411config PAHOLE_HAS_BTF_TAG
412	def_bool PAHOLE_VERSION >= 123
413	depends on CC_IS_CLANG
414	help
415	  Decide whether pahole emits btf_tag attributes (btf_type_tag and
416	  btf_decl_tag) or not. Currently only clang compiler implements
417	  these attributes, so make the config depend on CC_IS_CLANG.
418
419config PAHOLE_HAS_LANG_EXCLUDE
420	def_bool PAHOLE_VERSION >= 124
421	help
422	  Support for the --lang_exclude flag which makes pahole exclude
423	  compilation units from the supplied language. Used in Kbuild to
424	  omit Rust CUs which are not supported in version 1.24 of pahole,
425	  otherwise it would emit malformed kernel and module binaries when
426	  using DEBUG_INFO_BTF_MODULES.
427
428config DEBUG_INFO_BTF_MODULES
429	bool "Generate BTF type information for kernel modules"
430	default y
431	depends on DEBUG_INFO_BTF && MODULES
432	help
433	  Generate compact split BTF type information for kernel modules.
434
435config MODULE_ALLOW_BTF_MISMATCH
436	bool "Allow loading modules with non-matching BTF type info"
437	depends on DEBUG_INFO_BTF_MODULES
438	help
439	  For modules whose split BTF does not match vmlinux, load without
440	  BTF rather than refusing to load. The default behavior with
441	  module BTF enabled is to reject modules with such mismatches;
442	  this option will still load module BTF where possible but ignore
443	  it when a mismatch is found.
444
445config GDB_SCRIPTS
446	bool "Provide GDB scripts for kernel debugging"
447	help
448	  This creates the required links to GDB helper scripts in the
449	  build directory. If you load vmlinux into gdb, the helper
450	  scripts will be automatically imported by gdb as well, and
451	  additional functions are available to analyze a Linux kernel
452	  instance. See Documentation/process/debugging/gdb-kernel-debugging.rst
453	  for further details.
454
455endif # DEBUG_INFO
456
457config FRAME_WARN
458	int "Warn for stack frames larger than"
459	range 0 8192
460	default 0 if KMSAN
461	default 2048 if GCC_PLUGIN_LATENT_ENTROPY
462	default 2048 if PARISC
463	default 1536 if (!64BIT && XTENSA)
464	default 1280 if !64BIT
465	default 2048 if 64BIT
466	help
467	  Tell the compiler to warn at build time for stack frames larger than this.
468	  Setting this too low will cause a lot of warnings.
469	  Setting it to 0 disables the warning.
470
471config STRIP_ASM_SYMS
472	bool "Strip assembler-generated symbols during link"
473	default n
474	help
475	  Strip internal assembler-generated symbols during a link (symbols
476	  that look like '.Lxxx') so they don't pollute the output of
477	  get_wchan() and suchlike.
478
479config READABLE_ASM
480	bool "Generate readable assembler code"
481	depends on DEBUG_KERNEL
482	depends on CC_IS_GCC
483	help
484	  Disable some compiler optimizations that tend to generate human unreadable
485	  assembler output. This may make the kernel slightly slower, but it helps
486	  to keep kernel developers who have to stare a lot at assembler listings
487	  sane.
488
489config HEADERS_INSTALL
490	bool "Install uapi headers to usr/include"
491	help
492	  This option will install uapi headers (headers exported to user-space)
493	  into the usr/include directory for use during the kernel build.
494	  This is unneeded for building the kernel itself, but needed for some
495	  user-space program samples. It is also needed by some features such
496	  as uapi header sanity checks.
497
498config DEBUG_SECTION_MISMATCH
499	bool "Enable full Section mismatch analysis"
500	depends on CC_IS_GCC
501	help
502	  The section mismatch analysis checks if there are illegal references
503	  from one section to another. During linktime or runtime, some
504	  sections are dropped; any use of code/data previously in these
505	  sections would most likely result in an oops.
506
507	  In the code, functions and variables are annotated with __init,
508	  __initdata, and so on (see the full list in include/linux/init.h).
509	  This directs the toolchain to place code/data in specific sections.
510
511	  The section mismatch analysis is always performed after a full
512	  kernel build, and enabling this option causes the option
513	  -fno-inline-functions-called-once to be added to gcc commands.
514
515	  However, when inlining a function annotated with __init in
516	  a non-init function, we would lose the section information and thus
517	  the analysis would not catch the illegal reference.  This option
518	  tells gcc to inline less (but it does result in a larger kernel).
519
520config SECTION_MISMATCH_WARN_ONLY
521	bool "Make section mismatch errors non-fatal"
522	default y
523	help
524	  If you say N here, the build process will fail if there are any
525	  section mismatch, instead of just throwing warnings.
526
527	  If unsure, say Y.
528
529config DEBUG_FORCE_FUNCTION_ALIGN_64B
530	bool "Force all function address 64B aligned"
531	depends on EXPERT && (X86_64 || ARM64 || PPC32 || PPC64 || ARC || RISCV || S390)
532	select FUNCTION_ALIGNMENT_64B
533	help
534	  There are cases that a commit from one domain changes the function
535	  address alignment of other domains, and cause magic performance
536	  bump (regression or improvement). Enable this option will help to
537	  verify if the bump is caused by function alignment changes, while
538	  it will slightly increase the kernel size and affect icache usage.
539
540	  It is mainly for debug and performance tuning use.
541
542#
543# Select this config option from the architecture Kconfig, if it
544# is preferred to always offer frame pointers as a config
545# option on the architecture (regardless of KERNEL_DEBUG):
546#
547config ARCH_WANT_FRAME_POINTERS
548	bool
549
550config FRAME_POINTER
551	bool "Compile the kernel with frame pointers"
552	depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS
553	default y if (DEBUG_INFO && UML) || ARCH_WANT_FRAME_POINTERS
554	help
555	  If you say Y here the resulting kernel image will be slightly
556	  larger and slower, but it gives very useful debugging information
557	  in case of kernel bugs. (precise oopses/stacktraces/warnings)
558
559config OBJTOOL
560	bool
561
562config OBJTOOL_WERROR
563	bool "Upgrade objtool warnings to errors"
564	depends on OBJTOOL && !COMPILE_TEST
565	help
566	  Fail the build on objtool warnings.
567
568	  Objtool warnings can indicate kernel instability, including boot
569	  failures.  This option is highly recommended.
570
571	  If unsure, say Y.
572
573config STACK_VALIDATION
574	bool "Compile-time stack metadata validation"
575	depends on HAVE_STACK_VALIDATION && UNWINDER_FRAME_POINTER
576	select OBJTOOL
577	default n
578	help
579	  Validate frame pointer rules at compile-time.  This helps ensure that
580	  runtime stack traces are more reliable.
581
582	  For more information, see
583	  tools/objtool/Documentation/objtool.txt.
584
585config NOINSTR_VALIDATION
586	bool
587	depends on HAVE_NOINSTR_VALIDATION && DEBUG_ENTRY
588	select OBJTOOL
589	default y
590
591config VMLINUX_MAP
592	bool "Generate vmlinux.map file when linking"
593	depends on EXPERT
594	help
595	  Selecting this option will pass "-Map=vmlinux.map" to ld
596	  when linking vmlinux. That file can be useful for verifying
597	  and debugging magic section games, and for seeing which
598	  pieces of code get eliminated with
599	  CONFIG_LD_DEAD_CODE_DATA_ELIMINATION.
600
601config BUILTIN_MODULE_RANGES
602	bool "Generate address range information for builtin modules"
603	depends on !LTO
604	depends on VMLINUX_MAP
605	help
606	 When modules are built into the kernel, there will be no module name
607	 associated with its symbols in /proc/kallsyms.  Tracers may want to
608	 identify symbols by module name and symbol name regardless of whether
609	 the module is configured as loadable or not.
610
611	 This option generates modules.builtin.ranges in the build tree with
612	 offset ranges (per ELF section) for the module(s) they belong to.
613	 It also records an anchor symbol to determine the load address of the
614	 section.
615
616config DEBUG_FORCE_WEAK_PER_CPU
617	bool "Force weak per-cpu definitions"
618	depends on DEBUG_KERNEL
619	help
620	  s390 and alpha require percpu variables in modules to be
621	  defined weak to work around addressing range issue which
622	  puts the following two restrictions on percpu variable
623	  definitions.
624
625	  1. percpu symbols must be unique whether static or not
626	  2. percpu variables can't be defined inside a function
627
628	  To ensure that generic code follows the above rules, this
629	  option forces all percpu variables to be defined as weak.
630
631config WARN_CONTEXT_ANALYSIS
632	bool "Compiler context-analysis warnings"
633	depends on CC_IS_CLANG && CLANG_VERSION >= 220000
634	# Branch profiling re-defines "if", which messes with the compiler's
635	# ability to analyze __cond_acquires(..), resulting in false positives.
636	depends on !TRACE_BRANCH_PROFILING
637	default y
638	help
639	  Context Analysis is a language extension, which enables statically
640	  checking that required contexts are active (or inactive) by acquiring
641	  and releasing user-definable "context locks".
642
643	  Clang's name of the feature is "Thread Safety Analysis". Requires
644	  Clang 22 or later.
645
646	  Produces warnings by default. Select CONFIG_WERROR if you wish to
647	  turn these warnings into errors.
648
649	  For more details, see Documentation/dev-tools/context-analysis.rst.
650
651config WARN_CONTEXT_ANALYSIS_ALL
652	bool "Enable context analysis for all source files"
653	depends on WARN_CONTEXT_ANALYSIS
654	depends on EXPERT && !COMPILE_TEST
655	help
656	  Enable tree-wide context analysis. This is likely to produce a
657	  large number of false positives - enable at your own risk.
658
659	  If unsure, say N.
660
661endmenu # "Compiler options"
662
663menu "Generic Kernel Debugging Instruments"
664
665config MAGIC_SYSRQ
666	bool "Magic SysRq key"
667	depends on !UML
668	help
669	  If you say Y here, you will have some control over the system even
670	  if the system crashes for example during kernel debugging (e.g., you
671	  will be able to flush the buffer cache to disk, reboot the system
672	  immediately or dump some status information). This is accomplished
673	  by pressing various keys while holding SysRq (Alt+PrintScreen). It
674	  also works on a serial console (on PC hardware at least), if you
675	  send a BREAK and then within 5 seconds a command keypress. The
676	  keys are documented in <file:Documentation/admin-guide/sysrq.rst>.
677	  Don't say Y unless you really know what this hack does.
678
679config MAGIC_SYSRQ_DEFAULT_ENABLE
680	hex "Enable magic SysRq key functions by default"
681	depends on MAGIC_SYSRQ
682	default 0x1
683	help
684	  Specifies which SysRq key functions are enabled by default.
685	  This may be set to 1 or 0 to enable or disable them all, or
686	  to a bitmask as described in Documentation/admin-guide/sysrq.rst.
687
688config MAGIC_SYSRQ_SERIAL
689	bool "Enable magic SysRq key over serial"
690	depends on MAGIC_SYSRQ
691	default y
692	help
693	  Many embedded boards have a disconnected TTL level serial which can
694	  generate some garbage that can lead to spurious false sysrq detects.
695	  This option allows you to decide whether you want to enable the
696	  magic SysRq key.
697
698config MAGIC_SYSRQ_SERIAL_SEQUENCE
699	string "Char sequence that enables magic SysRq over serial"
700	depends on MAGIC_SYSRQ_SERIAL
701	default ""
702	help
703	  Specifies a sequence of characters that can follow BREAK to enable
704	  SysRq on a serial console.
705
706	  If unsure, leave an empty string and the option will not be enabled.
707
708config DEBUG_FS
709	bool "Debug Filesystem"
710	help
711	  debugfs is a virtual file system that kernel developers use to put
712	  debugging files into.  Enable this option to be able to read and
713	  write to these files.
714
715	  For detailed documentation on the debugfs API, see
716	  Documentation/filesystems/.
717
718	  If unsure, say N.
719
720choice
721	prompt "Debugfs default access"
722	depends on DEBUG_FS
723	default DEBUG_FS_ALLOW_ALL
724	help
725	  This selects the default access restrictions for debugfs.
726	  It can be overridden with kernel command line option
727	  debugfs=[on,off]. The restrictions apply for API access
728	  and filesystem registration.
729
730config DEBUG_FS_ALLOW_ALL
731	bool "Access normal"
732	help
733	  No restrictions apply. Both API and filesystem registration
734	  is on. This is the normal default operation.
735
736config DEBUG_FS_ALLOW_NONE
737	bool "No access"
738	help
739	  Access is off. Clients get -PERM when trying to create nodes in
740	  debugfs tree and debugfs is not registered as a filesystem.
741	  Client can then back-off or continue without debugfs access.
742
743endchoice
744
745source "lib/Kconfig.kgdb"
746source "lib/Kconfig.ubsan"
747source "lib/Kconfig.kcsan"
748
749endmenu
750
751menu "Networking Debugging"
752
753source "net/Kconfig.debug"
754
755endmenu # "Networking Debugging"
756
757menu "Memory Debugging"
758
759source "mm/Kconfig.debug"
760
761config DEBUG_OBJECTS
762	bool "Debug object operations"
763	depends on DEBUG_KERNEL
764	help
765	  If you say Y here, additional code will be inserted into the
766	  kernel to track the life time of various objects and validate
767	  the operations on those objects.
768
769config DEBUG_OBJECTS_SELFTEST
770	bool "Debug objects selftest"
771	depends on DEBUG_OBJECTS
772	help
773	  This enables the selftest of the object debug code.
774
775config DEBUG_OBJECTS_FREE
776	bool "Debug objects in freed memory"
777	depends on DEBUG_OBJECTS
778	help
779	  This enables checks whether a k/v free operation frees an area
780	  which contains an object which has not been deactivated
781	  properly. This can make kmalloc/kfree-intensive workloads
782	  much slower.
783
784config DEBUG_OBJECTS_TIMERS
785	bool "Debug timer objects"
786	depends on DEBUG_OBJECTS
787	help
788	  If you say Y here, additional code will be inserted into the
789	  timer routines to track the life time of timer objects and
790	  validate the timer operations.
791
792config DEBUG_OBJECTS_WORK
793	bool "Debug work objects"
794	depends on DEBUG_OBJECTS
795	help
796	  If you say Y here, additional code will be inserted into the
797	  work queue routines to track the life time of work objects and
798	  validate the work operations.
799
800config DEBUG_OBJECTS_RCU_HEAD
801	bool "Debug RCU callbacks objects"
802	depends on DEBUG_OBJECTS
803	help
804	  Enable this to turn on debugging of RCU list heads (call_rcu() usage).
805
806config DEBUG_OBJECTS_PERCPU_COUNTER
807	bool "Debug percpu counter objects"
808	depends on DEBUG_OBJECTS
809	help
810	  If you say Y here, additional code will be inserted into the
811	  percpu counter routines to track the life time of percpu counter
812	  objects and validate the percpu counter operations.
813
814config DEBUG_OBJECTS_ENABLE_DEFAULT
815	int "debug_objects bootup default value (0-1)"
816	range 0 1
817	default "1"
818	depends on DEBUG_OBJECTS
819	help
820	  Debug objects boot parameter default value
821
822config SHRINKER_DEBUG
823	bool "Enable shrinker debugging support"
824	depends on DEBUG_FS
825	help
826	  Say Y to enable the shrinker debugfs interface which provides
827	  visibility into the kernel memory shrinkers subsystem.
828	  Disable it to avoid an extra memory footprint.
829
830config DEBUG_STACK_USAGE
831	bool "Stack utilization instrumentation"
832	depends on DEBUG_KERNEL
833	help
834	  Enables the display of the minimum amount of free stack which each
835	  task has ever had available in the sysrq-T and sysrq-P debug output.
836	  Also emits a message to dmesg when a process exits if that process
837	  used more stack space than previously exiting processes.
838
839	  This option will slow down process creation somewhat.
840
841config SCHED_STACK_END_CHECK
842	bool "Detect stack corruption on calls to schedule()"
843	depends on DEBUG_KERNEL
844	default n
845	help
846	  This option checks for a stack overrun on calls to schedule().
847	  If the stack end location is found to be over written always panic as
848	  the content of the corrupted region can no longer be trusted.
849	  This is to ensure no erroneous behaviour occurs which could result in
850	  data corruption or a sporadic crash at a later stage once the region
851	  is examined. The runtime overhead introduced is minimal.
852
853config ARCH_HAS_DEBUG_VM_PGTABLE
854	bool
855	help
856	  An architecture should select this when it can successfully
857	  build and run DEBUG_VM_PGTABLE.
858
859config DEBUG_VFS
860	bool "Debug VFS"
861	depends on DEBUG_KERNEL
862	help
863	  Enable this to turn on extended checks in the VFS layer that may impact
864	  performance.
865
866	  If unsure, say N.
867
868config DEBUG_VM_IRQSOFF
869	def_bool DEBUG_VM && !PREEMPT_RT
870
871config DEBUG_VM
872	bool "Debug VM"
873	depends on DEBUG_KERNEL
874	help
875	  Enable this to turn on extended checks in the virtual-memory system
876	  that may impact performance.
877
878	  If unsure, say N.
879
880config DEBUG_VM_SHOOT_LAZIES
881	bool "Debug MMU_LAZY_TLB_SHOOTDOWN implementation"
882	depends on DEBUG_VM
883	depends on MMU_LAZY_TLB_SHOOTDOWN
884	help
885	  Enable additional IPIs that ensure lazy tlb mm references are removed
886	  before the mm is freed.
887
888	  If unsure, say N.
889
890config DEBUG_VM_MAPLE_TREE
891	bool "Debug VM maple trees"
892	depends on DEBUG_VM
893	select DEBUG_MAPLE_TREE
894	help
895	  Enable VM maple tree debugging information and extra validations.
896
897	  If unsure, say N.
898
899config DEBUG_VM_RB
900	bool "Debug VM red-black trees"
901	depends on DEBUG_VM
902	help
903	  Enable VM red-black tree debugging information and extra validations.
904
905	  If unsure, say N.
906
907config DEBUG_VM_PGFLAGS
908	bool "Debug page-flags operations"
909	depends on DEBUG_VM
910	help
911	  Enables extra validation on page flags operations.
912
913	  If unsure, say N.
914
915config DEBUG_VM_PGTABLE
916	bool "Debug arch page table for semantics compliance"
917	depends on MMU
918	depends on ARCH_HAS_DEBUG_VM_PGTABLE
919	default y if DEBUG_VM
920	help
921	  This option provides a debug method which can be used to test
922	  architecture page table helper functions on various platforms in
923	  verifying if they comply with expected generic MM semantics. This
924	  will help architecture code in making sure that any changes or
925	  new additions of these helpers still conform to expected
926	  semantics of the generic MM. Platforms will have to opt in for
927	  this through ARCH_HAS_DEBUG_VM_PGTABLE.
928
929	  If unsure, say N.
930
931config ARCH_HAS_DEBUG_VIRTUAL
932	bool
933
934config DEBUG_VIRTUAL
935	bool "Debug VM translations"
936	depends on DEBUG_KERNEL && ARCH_HAS_DEBUG_VIRTUAL
937	help
938	  Enable some costly sanity checks in virtual to page code. This can
939	  catch mistakes with virt_to_page() and friends.
940
941	  If unsure, say N.
942
943config DEBUG_NOMMU_REGIONS
944	bool "Debug the global anon/private NOMMU mapping region tree"
945	depends on DEBUG_KERNEL && !MMU
946	help
947	  This option causes the global tree of anonymous and private mapping
948	  regions to be regularly checked for invalid topology.
949
950config DEBUG_MEMORY_INIT
951	bool "Debug memory initialisation" if EXPERT
952	default !EXPERT
953	help
954	  Enable this for additional checks during memory initialisation.
955	  The sanity checks verify aspects of the VM such as the memory model
956	  and other information provided by the architecture. Verbose
957	  information will be printed at KERN_DEBUG loglevel depending
958	  on the mminit_loglevel= command-line option.
959
960	  If unsure, say Y
961
962config MEMORY_NOTIFIER_ERROR_INJECT
963	tristate "Memory hotplug notifier error injection module"
964	depends on MEMORY_HOTPLUG && NOTIFIER_ERROR_INJECTION
965	help
966	  This option provides the ability to inject artificial errors to
967	  memory hotplug notifier chain callbacks.  It is controlled through
968	  debugfs interface under /sys/kernel/debug/notifier-error-inject/memory
969
970	  If the notifier call chain should be failed with some events
971	  notified, write the error code to "actions/<notifier event>/error".
972
973	  Example: Inject memory hotplug offline error (-12 == -ENOMEM)
974
975	  # cd /sys/kernel/debug/notifier-error-inject/memory
976	  # echo -12 > actions/MEM_GOING_OFFLINE/error
977	  # echo offline > /sys/devices/system/memory/memoryXXX/state
978	  bash: echo: write error: Cannot allocate memory
979
980	  To compile this code as a module, choose M here: the module will
981	  be called memory-notifier-error-inject.
982
983	  If unsure, say N.
984
985config DEBUG_PER_CPU_MAPS
986	bool "Debug access to per_cpu maps"
987	depends on DEBUG_KERNEL
988	depends on SMP
989	help
990	  Say Y to verify that the per_cpu map being accessed has
991	  been set up. This adds a fair amount of code to kernel memory
992	  and decreases performance.
993
994	  Say N if unsure.
995
996config DEBUG_KMAP_LOCAL
997	bool "Debug kmap_local temporary mappings"
998	depends on DEBUG_KERNEL && KMAP_LOCAL
999	help
1000	  This option enables additional error checking for the kmap_local
1001	  infrastructure.  Disable for production use.
1002
1003config ARCH_SUPPORTS_KMAP_LOCAL_FORCE_MAP
1004	bool
1005
1006config DEBUG_KMAP_LOCAL_FORCE_MAP
1007	bool "Enforce kmap_local temporary mappings"
1008	depends on DEBUG_KERNEL && ARCH_SUPPORTS_KMAP_LOCAL_FORCE_MAP
1009	select KMAP_LOCAL
1010	select DEBUG_KMAP_LOCAL
1011	help
1012	  This option enforces temporary mappings through the kmap_local
1013	  mechanism for non-highmem pages and on non-highmem systems.
1014	  Disable this for production systems!
1015
1016config DEBUG_HIGHMEM
1017	bool "Highmem debugging"
1018	depends on DEBUG_KERNEL && HIGHMEM
1019	select DEBUG_KMAP_LOCAL_FORCE_MAP if ARCH_SUPPORTS_KMAP_LOCAL_FORCE_MAP
1020	select DEBUG_KMAP_LOCAL
1021	help
1022	  This option enables additional error checking for high memory
1023	  systems.  Disable for production systems.
1024
1025config HAVE_DEBUG_STACKOVERFLOW
1026	bool
1027
1028config DEBUG_STACKOVERFLOW
1029	bool "Check for stack overflows"
1030	depends on DEBUG_KERNEL && HAVE_DEBUG_STACKOVERFLOW
1031	help
1032	  Say Y here if you want to check for overflows of kernel, IRQ
1033	  and exception stacks (if your architecture uses them). This
1034	  option will show detailed messages if free stack space drops
1035	  below a certain limit.
1036
1037	  These kinds of bugs usually occur when call-chains in the
1038	  kernel get too deep, especially when interrupts are
1039	  involved.
1040
1041	  Use this in cases where you see apparently random memory
1042	  corruption, especially if it appears in 'struct thread_info'
1043
1044	  If in doubt, say "N".
1045
1046config CODE_TAGGING
1047	bool
1048	select KALLSYMS
1049
1050config MEM_ALLOC_PROFILING
1051	bool "Enable memory allocation profiling"
1052	default n
1053	depends on MMU
1054	depends on PROC_FS
1055	depends on !DEBUG_FORCE_WEAK_PER_CPU
1056	select CODE_TAGGING
1057	select PAGE_EXTENSION
1058	select SLAB_OBJ_EXT
1059	help
1060	  Track allocation source code and record total allocation size
1061	  initiated at that code location. The mechanism can be used to track
1062	  memory leaks with a low performance and memory impact.
1063
1064config MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT
1065	bool "Enable memory allocation profiling by default"
1066	default y
1067	depends on MEM_ALLOC_PROFILING
1068
1069config MEM_ALLOC_PROFILING_DEBUG
1070	bool "Memory allocation profiler debugging"
1071	default n
1072	depends on MEM_ALLOC_PROFILING
1073	select MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT
1074	help
1075	  Adds warnings with helpful error messages for memory allocation
1076	  profiling.
1077
1078source "lib/Kconfig.kasan"
1079source "lib/Kconfig.kfence"
1080source "lib/Kconfig.kmsan"
1081
1082endmenu # "Memory Debugging"
1083
1084config DEBUG_SHIRQ
1085	bool "Debug shared IRQ handlers"
1086	depends on DEBUG_KERNEL
1087	help
1088	  Enable this to generate a spurious interrupt just before a shared
1089	  interrupt handler is deregistered (generating one when registering
1090	  is currently disabled). Drivers need to handle this correctly. Some
1091	  don't and need to be caught.
1092
1093menu "Debug Oops, Lockups and Hangs"
1094
1095config PANIC_ON_OOPS
1096	bool "Panic on Oops"
1097	help
1098	  Say Y here to enable the kernel to panic when it oopses. This
1099	  has the same effect as setting oops=panic on the kernel command
1100	  line.
1101
1102	  This feature is useful to ensure that the kernel does not do
1103	  anything erroneous after an oops which could result in data
1104	  corruption or other issues.
1105
1106	  Say N if unsure.
1107
1108config PANIC_TIMEOUT
1109	int "panic timeout"
1110	default 0
1111	help
1112	  Set the timeout value (in seconds) until a reboot occurs when
1113	  the kernel panics. If n = 0, then we wait forever. A timeout
1114	  value n > 0 will wait n seconds before rebooting, while a timeout
1115	  value n < 0 will reboot immediately. This setting can be overridden
1116	  with the kernel command line option panic=, and from userspace via
1117	  /proc/sys/kernel/panic.
1118
1119config LOCKUP_DETECTOR
1120	bool
1121
1122config SOFTLOCKUP_DETECTOR
1123	bool "Detect Soft Lockups"
1124	depends on DEBUG_KERNEL && !S390
1125	select LOCKUP_DETECTOR
1126	help
1127	  Say Y here to enable the kernel to act as a watchdog to detect
1128	  soft lockups.
1129
1130	  Softlockups are bugs that cause the kernel to loop in kernel
1131	  mode for more than 20 seconds, without giving other tasks a
1132	  chance to run.  The current stack trace is displayed upon
1133	  detection and the system will stay locked up.
1134
1135config SOFTLOCKUP_DETECTOR_INTR_STORM
1136	bool "Detect Interrupt Storm in Soft Lockups"
1137	depends on SOFTLOCKUP_DETECTOR && IRQ_TIME_ACCOUNTING
1138	select GENERIC_IRQ_STAT_SNAPSHOT
1139	default y if NR_CPUS <= 128
1140	help
1141	  Say Y here to enable the kernel to detect interrupt storm
1142	  during "soft lockups".
1143
1144	  "soft lockups" can be caused by a variety of reasons. If one is
1145	  caused by an interrupt storm, then the storming interrupts will not
1146	  be on the callstack. To detect this case, it is necessary to report
1147	  the CPU stats and the interrupt counts during the "soft lockups".
1148
1149config BOOTPARAM_SOFTLOCKUP_PANIC
1150	int "Panic (Reboot) On Soft Lockups"
1151	depends on SOFTLOCKUP_DETECTOR
1152	default 0
1153	help
1154	  Set to a non-zero value N to enable the kernel to panic on "soft
1155	  lockups", which are bugs that cause the kernel to loop in kernel
1156	  mode for more than (N * 20 seconds) (configurable using the
1157	  watchdog_thresh sysctl), without giving other tasks a chance to run.
1158
1159	  The panic can be used in combination with panic_timeout,
1160	  to cause the system to reboot automatically after a
1161	  lockup has been detected. This feature is useful for
1162	  high-availability systems that have uptime guarantees and
1163	  where a lockup must be resolved ASAP.
1164
1165	  Say 0 if unsure.
1166
1167config HAVE_HARDLOCKUP_DETECTOR_BUDDY
1168	bool
1169	depends on SMP
1170	default y
1171
1172#
1173# Global switch whether to build a hardlockup detector at all. It is available
1174# only when the architecture supports at least one implementation. There are
1175# two exceptions. The hardlockup detector is never enabled on:
1176#
1177#	s390: it reported many false positives there
1178#
1179#	sparc64: has a custom implementation which is not using the common
1180#		hardlockup command line options and sysctl interface.
1181#
1182config HARDLOCKUP_DETECTOR
1183	bool "Detect Hard Lockups"
1184	depends on DEBUG_KERNEL && !S390 && !HARDLOCKUP_DETECTOR_SPARC64
1185	depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY || HAVE_HARDLOCKUP_DETECTOR_ARCH
1186	imply HARDLOCKUP_DETECTOR_PERF
1187	imply HARDLOCKUP_DETECTOR_BUDDY
1188	imply HARDLOCKUP_DETECTOR_ARCH
1189	select LOCKUP_DETECTOR
1190
1191	help
1192	  Say Y here to enable the kernel to act as a watchdog to detect
1193	  hard lockups.
1194
1195	  Hardlockups are bugs that cause the CPU to loop in kernel mode
1196	  for more than 10 seconds, without letting other interrupts have a
1197	  chance to run.  The current stack trace is displayed upon detection
1198	  and the system will stay locked up.
1199
1200#
1201# Note that arch-specific variants are always preferred.
1202#
1203config HARDLOCKUP_DETECTOR_PREFER_BUDDY
1204	bool "Prefer the buddy CPU hardlockup detector"
1205	depends on HARDLOCKUP_DETECTOR
1206	depends on HAVE_HARDLOCKUP_DETECTOR_PERF && HAVE_HARDLOCKUP_DETECTOR_BUDDY
1207	depends on !HAVE_HARDLOCKUP_DETECTOR_ARCH
1208	help
1209	  Say Y here to prefer the buddy hardlockup detector over the perf one.
1210
1211	  With the buddy detector, each CPU uses its softlockup hrtimer
1212	  to check that the next CPU is processing hrtimer interrupts by
1213	  verifying that a counter is increasing.
1214
1215	  This hardlockup detector is useful on systems that don't have
1216	  an arch-specific hardlockup detector or if resources needed
1217	  for the hardlockup detector are better used for other things.
1218
1219config HARDLOCKUP_DETECTOR_PERF
1220	bool
1221	depends on HARDLOCKUP_DETECTOR
1222	depends on HAVE_HARDLOCKUP_DETECTOR_PERF && !HARDLOCKUP_DETECTOR_PREFER_BUDDY
1223	depends on !HAVE_HARDLOCKUP_DETECTOR_ARCH
1224	select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER
1225
1226config HARDLOCKUP_DETECTOR_BUDDY
1227	bool
1228	depends on HARDLOCKUP_DETECTOR
1229	depends on HAVE_HARDLOCKUP_DETECTOR_BUDDY
1230	depends on !HAVE_HARDLOCKUP_DETECTOR_PERF || HARDLOCKUP_DETECTOR_PREFER_BUDDY
1231	depends on !HAVE_HARDLOCKUP_DETECTOR_ARCH
1232	select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER
1233
1234config HARDLOCKUP_DETECTOR_ARCH
1235	bool
1236	depends on HARDLOCKUP_DETECTOR
1237	depends on HAVE_HARDLOCKUP_DETECTOR_ARCH
1238	help
1239	  The arch-specific implementation of the hardlockup detector will
1240	  be used.
1241
1242#
1243# Both the "perf" and "buddy" hardlockup detectors count hrtimer
1244# interrupts. This config enables functions managing this common code.
1245#
1246config HARDLOCKUP_DETECTOR_COUNTS_HRTIMER
1247	bool
1248	select SOFTLOCKUP_DETECTOR
1249
1250#
1251# Enables a timestamp based low pass filter to compensate for perf based
1252# hard lockup detection which runs too fast due to turbo modes.
1253#
1254config HARDLOCKUP_CHECK_TIMESTAMP
1255	bool
1256
1257config BOOTPARAM_HARDLOCKUP_PANIC
1258	bool "Panic (Reboot) On Hard Lockups"
1259	depends on HARDLOCKUP_DETECTOR
1260	help
1261	  Say Y here to enable the kernel to panic on "hard lockups",
1262	  which are bugs that cause the kernel to loop in kernel
1263	  mode with interrupts disabled for more than 10 seconds (configurable
1264	  using the watchdog_thresh sysctl).
1265
1266	  Say N if unsure.
1267
1268config DETECT_HUNG_TASK
1269	bool "Detect Hung Tasks"
1270	depends on DEBUG_KERNEL
1271	default SOFTLOCKUP_DETECTOR
1272	help
1273	  Say Y here to enable the kernel to detect "hung tasks",
1274	  which are bugs that cause the task to be stuck in
1275	  uninterruptible "D" state indefinitely.
1276
1277	  When a hung task is detected, the kernel will print the
1278	  current stack trace (which you should report), but the
1279	  task will stay in uninterruptible state. If lockdep is
1280	  enabled then all held locks will also be reported. This
1281	  feature has negligible overhead.
1282
1283config DEFAULT_HUNG_TASK_TIMEOUT
1284	int "Default timeout for hung task detection (in seconds)"
1285	depends on DETECT_HUNG_TASK
1286	default 120
1287	help
1288	  This option controls the default timeout (in seconds) used
1289	  to determine when a task has become non-responsive and should
1290	  be considered hung.
1291
1292	  It can be adjusted at runtime via the kernel.hung_task_timeout_secs
1293	  sysctl or by writing a value to
1294	  /proc/sys/kernel/hung_task_timeout_secs.
1295
1296	  A timeout of 0 disables the check.  The default is two minutes.
1297	  Keeping the default should be fine in most cases.
1298
1299config BOOTPARAM_HUNG_TASK_PANIC
1300	int "Number of hung tasks to trigger kernel panic"
1301	depends on DETECT_HUNG_TASK
1302	default 0
1303	help
1304	  When set to a non-zero value, a kernel panic will be triggered
1305	  if the number of hung tasks found during a single scan reaches
1306	  this value.
1307
1308	  The panic can be used in combination with panic_timeout,
1309	  to cause the system to reboot automatically after a
1310	  hung task has been detected. This feature is useful for
1311	  high-availability systems that have uptime guarantees and
1312	  where a hung tasks must be resolved ASAP.
1313
1314	  Say 0 if unsure.
1315
1316config DETECT_HUNG_TASK_BLOCKER
1317	bool "Dump Hung Tasks Blocker"
1318	depends on DETECT_HUNG_TASK
1319	depends on !PREEMPT_RT
1320	default y
1321	help
1322	  Say Y here to show the blocker task's stacktrace who acquires
1323	  the mutex lock which "hung tasks" are waiting.
1324	  This will add overhead a bit but shows suspicious tasks and
1325	  call trace if it comes from waiting a mutex.
1326
1327config WQ_WATCHDOG
1328	bool "Detect Workqueue Stalls"
1329	depends on DEBUG_KERNEL
1330	help
1331	  Say Y here to enable stall detection on workqueues.  If a
1332	  worker pool doesn't make forward progress on a pending work
1333	  item for over a given amount of time, 30s by default, a
1334	  warning message is printed along with dump of workqueue
1335	  state.  This can be configured through kernel parameter
1336	  "workqueue.watchdog_thresh" and its sysfs counterpart.
1337
1338config BOOTPARAM_WQ_STALL_PANIC
1339	int "Panic on Nth workqueue stall"
1340	default 0
1341	range 0 100
1342	depends on WQ_WATCHDOG
1343	help
1344	  Set the number of workqueue stalls to trigger a kernel panic.
1345	  A workqueue stall occurs when a worker pool doesn't make forward
1346	  progress on a pending work item for over 30 seconds (configurable
1347	  using the workqueue.watchdog_thresh parameter).
1348
1349	  If n = 0, the kernel will not panic on stall. If n > 0, the kernel
1350	  will panic after n stall warnings.
1351
1352	  The panic can be used in combination with panic_timeout,
1353	  to cause the system to reboot automatically after a
1354	  stall has been detected. This feature is useful for
1355	  high-availability systems that have uptime guarantees and
1356	  where a stall must be resolved ASAP.
1357
1358	  This setting can be overridden at runtime via the
1359	  workqueue.panic_on_stall kernel parameter.
1360
1361config WQ_CPU_INTENSIVE_REPORT
1362	bool "Report per-cpu work items which hog CPU for too long"
1363	depends on DEBUG_KERNEL
1364	help
1365	  Say Y here to enable reporting of concurrency-managed per-cpu work
1366	  items that hog CPUs for longer than
1367	  workqueue.cpu_intensive_thresh_us. Workqueue automatically
1368	  detects and excludes them from concurrency management to prevent
1369	  them from stalling other per-cpu work items. Occassional
1370	  triggering may not necessarily indicate a problem. Repeated
1371	  triggering likely indicates that the work item should be switched
1372	  to use an unbound workqueue.
1373
1374config TEST_LOCKUP
1375	tristate "Test module to generate lockups"
1376	depends on m
1377	help
1378	  This builds the "test_lockup" module that helps to make sure
1379	  that watchdogs and lockup detectors are working properly.
1380
1381	  Depending on module parameters it could emulate soft or hard
1382	  lockup, "hung task", or locking arbitrary lock for a long time.
1383	  Also it could generate series of lockups with cooling-down periods.
1384
1385	  If unsure, say N.
1386
1387endmenu # "Debug lockups and hangs"
1388
1389menu "Scheduler Debugging"
1390
1391config SCHED_INFO
1392	bool
1393	default n
1394
1395config SCHEDSTATS
1396	bool "Collect scheduler statistics"
1397	depends on PROC_FS
1398	select SCHED_INFO
1399	help
1400	  If you say Y here, additional code will be inserted into the
1401	  scheduler and related routines to collect statistics about
1402	  scheduler behavior and provide them in /proc/schedstat.  These
1403	  stats may be useful for both tuning and debugging the scheduler
1404	  If you aren't debugging the scheduler or trying to tune a specific
1405	  application, you can say N to avoid the very slight overhead
1406	  this adds.
1407
1408endmenu
1409
1410config DEBUG_PREEMPT
1411	bool "Debug preemptible kernel"
1412	depends on DEBUG_KERNEL && PREEMPTION && TRACE_IRQFLAGS_SUPPORT
1413	help
1414	  If you say Y here then the kernel will use a debug variant of the
1415	  commonly used smp_processor_id() function and will print warnings
1416	  if kernel code uses it in a preemption-unsafe way. Also, the kernel
1417	  will detect preemption count underflows.
1418
1419	  This option has potential to introduce high runtime overhead,
1420	  depending on workload as it triggers debugging routines for each
1421	  this_cpu operation. It should only be used for debugging purposes.
1422
1423config DEBUG_ATOMIC
1424	bool "Debug atomic variables"
1425	depends on DEBUG_KERNEL
1426	help
1427	  If you say Y here then the kernel will add a runtime alignment check
1428	  to atomic accesses. Useful for architectures that do not have trap on
1429	  mis-aligned access.
1430
1431	  This option has potentially significant overhead.
1432
1433config DEBUG_ATOMIC_LARGEST_ALIGN
1434	bool "Check alignment only up to __aligned_largest"
1435	depends on DEBUG_ATOMIC
1436	help
1437	  If you say Y here then the check for natural alignment of
1438	  atomic accesses will be constrained to the compiler's largest
1439	  alignment for scalar types.
1440
1441menu "Lock Debugging (spinlocks, mutexes, etc...)"
1442
1443config LOCK_DEBUGGING_SUPPORT
1444	bool
1445	depends on TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
1446	default y
1447
1448config PROVE_LOCKING
1449	bool "Lock debugging: prove locking correctness"
1450	depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1451	select LOCKDEP
1452	select DEBUG_SPINLOCK
1453	select DEBUG_MUTEXES if !PREEMPT_RT
1454	select DEBUG_RT_MUTEXES if RT_MUTEXES
1455	select DEBUG_RWSEMS if !PREEMPT_RT
1456	select DEBUG_WW_MUTEX_SLOWPATH
1457	select DEBUG_LOCK_ALLOC
1458	select PREEMPT_COUNT if !ARCH_NO_PREEMPT
1459	select TRACE_IRQFLAGS
1460	default n
1461	help
1462	 This feature enables the kernel to prove that all locking
1463	 that occurs in the kernel runtime is mathematically
1464	 correct: that under no circumstance could an arbitrary (and
1465	 not yet triggered) combination of observed locking
1466	 sequences (on an arbitrary number of CPUs, running an
1467	 arbitrary number of tasks and interrupt contexts) cause a
1468	 deadlock.
1469
1470	 In short, this feature enables the kernel to report locking
1471	 related deadlocks before they actually occur.
1472
1473	 The proof does not depend on how hard and complex a
1474	 deadlock scenario would be to trigger: how many
1475	 participant CPUs, tasks and irq-contexts would be needed
1476	 for it to trigger. The proof also does not depend on
1477	 timing: if a race and a resulting deadlock is possible
1478	 theoretically (no matter how unlikely the race scenario
1479	 is), it will be proven so and will immediately be
1480	 reported by the kernel (once the event is observed that
1481	 makes the deadlock theoretically possible).
1482
1483	 If a deadlock is impossible (i.e. the locking rules, as
1484	 observed by the kernel, are mathematically correct), the
1485	 kernel reports nothing.
1486
1487	 NOTE: this feature can also be enabled for rwlocks, mutexes
1488	 and rwsems - in which case all dependencies between these
1489	 different locking variants are observed and mapped too, and
1490	 the proof of observed correctness is also maintained for an
1491	 arbitrary combination of these separate locking variants.
1492
1493	 For more details, see Documentation/locking/lockdep-design.rst.
1494
1495config PROVE_RAW_LOCK_NESTING
1496	bool "Enable raw_spinlock - spinlock nesting checks" if !ARCH_SUPPORTS_RT
1497	depends on PROVE_LOCKING
1498	default y if ARCH_SUPPORTS_RT
1499	help
1500	 Enable the raw_spinlock vs. spinlock nesting checks which ensure
1501	 that the lock nesting rules for PREEMPT_RT enabled kernels are
1502	 not violated.
1503
1504config LOCK_STAT
1505	bool "Lock usage statistics"
1506	depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1507	select LOCKDEP
1508	select DEBUG_SPINLOCK
1509	select DEBUG_MUTEXES if !PREEMPT_RT
1510	select DEBUG_RT_MUTEXES if RT_MUTEXES
1511	select DEBUG_LOCK_ALLOC
1512	default n
1513	help
1514	 This feature enables tracking lock contention points
1515
1516	 For more details, see Documentation/locking/lockstat.rst
1517
1518	 This also enables lock events required by "perf lock",
1519	 subcommand of perf.
1520	 If you want to use "perf lock", you also need to turn on
1521	 CONFIG_EVENT_TRACING.
1522
1523	 CONFIG_LOCK_STAT defines "contended" and "acquired" lock events.
1524	 (CONFIG_LOCKDEP defines "acquire" and "release" events.)
1525
1526config DEBUG_RT_MUTEXES
1527	bool "RT Mutex debugging, deadlock detection"
1528	depends on DEBUG_KERNEL && RT_MUTEXES
1529	help
1530	 This allows rt mutex semantics violations and rt mutex related
1531	 deadlocks (lockups) to be detected and reported automatically.
1532
1533config DEBUG_SPINLOCK
1534	bool "Spinlock and rw-lock debugging: basic checks"
1535	depends on DEBUG_KERNEL
1536	select UNINLINE_SPIN_UNLOCK
1537	help
1538	  Say Y here and build SMP to catch missing spinlock initialization
1539	  and certain other kinds of spinlock errors commonly made.  This is
1540	  best used in conjunction with the NMI watchdog so that spinlock
1541	  deadlocks are also debuggable.
1542
1543config DEBUG_MUTEXES
1544	bool "Mutex debugging: basic checks"
1545	depends on DEBUG_KERNEL && !PREEMPT_RT
1546	help
1547	 This feature allows mutex semantics violations to be detected and
1548	 reported.
1549
1550config DEBUG_WW_MUTEX_SLOWPATH
1551	bool "Wait/wound mutex debugging: Slowpath testing"
1552	depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1553	select DEBUG_LOCK_ALLOC
1554	select DEBUG_SPINLOCK
1555	select DEBUG_MUTEXES if !PREEMPT_RT
1556	select DEBUG_RT_MUTEXES if PREEMPT_RT
1557	help
1558	 This feature enables slowpath testing for w/w mutex users by
1559	 injecting additional -EDEADLK wound/backoff cases. Together with
1560	 the full mutex checks enabled with (CONFIG_PROVE_LOCKING) this
1561	 will test all possible w/w mutex interface abuse with the
1562	 exception of simply not acquiring all the required locks.
1563	 Note that this feature can introduce significant overhead, so
1564	 it really should not be enabled in a production or distro kernel,
1565	 even a debug kernel.  If you are a driver writer, enable it.  If
1566	 you are a distro, do not.
1567
1568config DEBUG_RWSEMS
1569	bool "RW Semaphore debugging: basic checks"
1570	depends on DEBUG_KERNEL && !PREEMPT_RT
1571	help
1572	  This debugging feature allows mismatched rw semaphore locks
1573	  and unlocks to be detected and reported.
1574
1575config DEBUG_LOCK_ALLOC
1576	bool "Lock debugging: detect incorrect freeing of live locks"
1577	depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1578	select DEBUG_SPINLOCK
1579	select DEBUG_MUTEXES if !PREEMPT_RT
1580	select DEBUG_RT_MUTEXES if RT_MUTEXES
1581	select LOCKDEP
1582	help
1583	 This feature will check whether any held lock (spinlock, rwlock,
1584	 mutex or rwsem) is incorrectly freed by the kernel, via any of the
1585	 memory-freeing routines (kfree(), kmem_cache_free(), free_pages(),
1586	 vfree(), etc.), whether a live lock is incorrectly reinitialized via
1587	 spin_lock_init()/mutex_init()/etc., or whether there is any lock
1588	 held during task exit.
1589
1590config LOCKDEP
1591	bool
1592	depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1593	select STACKTRACE
1594	select KALLSYMS
1595	select KALLSYMS_ALL
1596
1597config LOCKDEP_SMALL
1598	bool
1599
1600config LOCKDEP_BITS
1601	int "Size for MAX_LOCKDEP_ENTRIES (as Nth power of 2)"
1602	depends on LOCKDEP && !LOCKDEP_SMALL
1603	range 10 24
1604	default 15
1605	help
1606	  Try increasing this value if you hit "BUG: MAX_LOCKDEP_ENTRIES too low!" message.
1607
1608config LOCKDEP_CHAINS_BITS
1609	int "Size for MAX_LOCKDEP_CHAINS (as Nth power of 2)"
1610	depends on LOCKDEP && !LOCKDEP_SMALL
1611	range 10 21
1612	default 16
1613	help
1614	  Try increasing this value if you hit "BUG: MAX_LOCKDEP_CHAINS too low!" message.
1615
1616config LOCKDEP_STACK_TRACE_BITS
1617	int "Size for MAX_STACK_TRACE_ENTRIES (as Nth power of 2)"
1618	depends on LOCKDEP && !LOCKDEP_SMALL
1619	range 10 26
1620	default 19
1621	help
1622	  Try increasing this value if you hit "BUG: MAX_STACK_TRACE_ENTRIES too low!" message.
1623
1624config LOCKDEP_STACK_TRACE_HASH_BITS
1625	int "Size for STACK_TRACE_HASH_SIZE (as Nth power of 2)"
1626	depends on LOCKDEP && !LOCKDEP_SMALL
1627	range 10 26
1628	default 14
1629	help
1630	  Try increasing this value if you need large STACK_TRACE_HASH_SIZE.
1631
1632config LOCKDEP_CIRCULAR_QUEUE_BITS
1633	int "Size for elements in circular_queue struct (as Nth power of 2)"
1634	depends on LOCKDEP
1635	range 10 26
1636	default 12
1637	help
1638	  Try increasing this value if you hit "lockdep bfs error:-1" warning due to __cq_enqueue() failure.
1639
1640config DEBUG_LOCKDEP
1641	bool "Lock dependency engine debugging"
1642	depends on DEBUG_KERNEL && LOCKDEP
1643	select DEBUG_IRQFLAGS
1644	help
1645	  If you say Y here, the lock dependency engine will do
1646	  additional runtime checks to debug itself, at the price
1647	  of more runtime overhead.
1648
1649config DEBUG_ATOMIC_SLEEP
1650	bool "Sleep inside atomic section checking"
1651	select PREEMPT_COUNT
1652	depends on DEBUG_KERNEL
1653	depends on !ARCH_NO_PREEMPT
1654	help
1655	  If you say Y here, various routines which may sleep will become very
1656	  noisy if they are called inside atomic sections: when a spinlock is
1657	  held, inside an rcu read side critical section, inside preempt disabled
1658	  sections, inside an interrupt, etc...
1659
1660config DEBUG_LOCKING_API_SELFTESTS
1661	bool "Locking API boot-time self-tests"
1662	depends on DEBUG_KERNEL
1663	help
1664	  Say Y here if you want the kernel to run a short self-test during
1665	  bootup. The self-test checks whether common types of locking bugs
1666	  are detected by debugging mechanisms or not. (if you disable
1667	  lock debugging then those bugs won't be detected of course.)
1668	  The following locking APIs are covered: spinlocks, rwlocks,
1669	  mutexes and rwsems.
1670
1671config LOCK_TORTURE_TEST
1672	tristate "torture tests for locking"
1673	depends on DEBUG_KERNEL
1674	select TORTURE_TEST
1675	help
1676	  This option provides a kernel module that runs torture tests
1677	  on kernel locking primitives.  The kernel module may be built
1678	  after the fact on the running kernel to be tested, if desired.
1679
1680	  Say Y here if you want kernel locking-primitive torture tests
1681	  to be built into the kernel.
1682	  Say M if you want these torture tests to build as a module.
1683	  Say N if you are unsure.
1684
1685config WW_MUTEX_SELFTEST
1686	tristate "Wait/wound mutex selftests"
1687	help
1688	  This option provides a kernel module that runs tests on the
1689	  on the struct ww_mutex locking API.
1690
1691	  It is recommended to enable DEBUG_WW_MUTEX_SLOWPATH in conjunction
1692	  with this test harness.
1693
1694	  Say M if you want these self tests to build as a module.
1695	  Say N if you are unsure.
1696
1697config SCF_TORTURE_TEST
1698	tristate "torture tests for smp_call_function*()"
1699	depends on DEBUG_KERNEL
1700	select TORTURE_TEST
1701	help
1702	  This option provides a kernel module that runs torture tests
1703	  on the smp_call_function() family of primitives.  The kernel
1704	  module may be built after the fact on the running kernel to
1705	  be tested, if desired.
1706
1707config CSD_LOCK_WAIT_DEBUG
1708	bool "Debugging for csd_lock_wait(), called from smp_call_function*()"
1709	depends on DEBUG_KERNEL
1710	depends on SMP
1711	depends on 64BIT
1712	default n
1713	help
1714	  This option enables debug prints when CPUs are slow to respond
1715	  to the smp_call_function*() IPI wrappers.  These debug prints
1716	  include the IPI handler function currently executing (if any)
1717	  and relevant stack traces.
1718
1719config CSD_LOCK_WAIT_DEBUG_DEFAULT
1720	bool "Default csd_lock_wait() debugging on at boot time"
1721	depends on CSD_LOCK_WAIT_DEBUG
1722	depends on 64BIT
1723	default n
1724	help
1725	  This option causes the csdlock_debug= kernel boot parameter to
1726	  default to 1 (basic debugging) instead of 0 (no debugging).
1727
1728endmenu # lock debugging
1729
1730config TRACE_IRQFLAGS
1731	depends on TRACE_IRQFLAGS_SUPPORT
1732	bool
1733	help
1734	  Enables hooks to interrupt enabling and disabling for
1735	  either tracing or lock debugging.
1736
1737config TRACE_IRQFLAGS_NMI
1738	def_bool y
1739	depends on TRACE_IRQFLAGS
1740	depends on TRACE_IRQFLAGS_NMI_SUPPORT
1741
1742config NMI_CHECK_CPU
1743	bool "Debugging for CPUs failing to respond to backtrace requests"
1744	depends on DEBUG_KERNEL
1745	depends on X86
1746	default n
1747	help
1748	  Enables debug prints when a CPU fails to respond to a given
1749	  backtrace NMI.  These prints provide some reasons why a CPU
1750	  might legitimately be failing to respond, for example, if it
1751	  is offline of if ignore_nmis is set.
1752
1753config DEBUG_IRQFLAGS
1754	bool "Debug IRQ flag manipulation"
1755	help
1756	  Enables checks for potentially unsafe enabling or disabling of
1757	  interrupts, such as calling raw_local_irq_restore() when interrupts
1758	  are enabled.
1759
1760config STACKTRACE
1761	bool "Stack backtrace support"
1762	depends on STACKTRACE_SUPPORT
1763	help
1764	  This option causes the kernel to create a /proc/pid/stack for
1765	  every process, showing its current stack trace.
1766	  It is also used by various kernel debugging features that require
1767	  stack trace generation.
1768
1769config DEBUG_KOBJECT
1770	bool "kobject debugging"
1771	depends on DEBUG_KERNEL
1772	help
1773	  If you say Y here, some extra kobject debugging messages will be sent
1774	  to the syslog.
1775
1776config DEBUG_KOBJECT_RELEASE
1777	bool "kobject release debugging"
1778	depends on DEBUG_OBJECTS_TIMERS
1779	help
1780	  kobjects are reference counted objects.  This means that their
1781	  last reference count put is not predictable, and the kobject can
1782	  live on past the point at which a driver decides to drop its
1783	  initial reference to the kobject gained on allocation.  An
1784	  example of this would be a struct device which has just been
1785	  unregistered.
1786
1787	  However, some buggy drivers assume that after such an operation,
1788	  the memory backing the kobject can be immediately freed.  This
1789	  goes completely against the principles of a refcounted object.
1790
1791	  If you say Y here, the kernel will delay the release of kobjects
1792	  on the last reference count to improve the visibility of this
1793	  kind of kobject release bug.
1794
1795config HAVE_DEBUG_BUGVERBOSE
1796	bool
1797
1798menu "Debug kernel data structures"
1799
1800config DEBUG_LIST
1801	bool "Debug linked list manipulation"
1802	depends on DEBUG_KERNEL
1803	select LIST_HARDENED
1804	help
1805	  Enable this to turn on extended checks in the linked-list walking
1806	  routines.
1807
1808	  This option trades better quality error reports for performance, and
1809	  is more suitable for kernel debugging. If you care about performance,
1810	  you should only enable CONFIG_LIST_HARDENED instead.
1811
1812	  If unsure, say N.
1813
1814config DEBUG_PLIST
1815	bool "Debug priority linked list manipulation"
1816	depends on DEBUG_KERNEL
1817	help
1818	  Enable this to turn on extended checks in the priority-ordered
1819	  linked-list (plist) walking routines.  This checks the entire
1820	  list multiple times during each manipulation.
1821
1822	  If unsure, say N.
1823
1824config DEBUG_SG
1825	bool "Debug SG table operations"
1826	depends on DEBUG_KERNEL
1827	help
1828	  Enable this to turn on checks on scatter-gather tables. This can
1829	  help find problems with drivers that do not properly initialize
1830	  their sg tables.
1831
1832	  If unsure, say N.
1833
1834config DEBUG_NOTIFIERS
1835	bool "Debug notifier call chains"
1836	depends on DEBUG_KERNEL
1837	help
1838	  Enable this to turn on sanity checking for notifier call chains.
1839	  This is most useful for kernel developers to make sure that
1840	  modules properly unregister themselves from notifier chains.
1841	  This is a relatively cheap check but if you care about maximum
1842	  performance, say N.
1843
1844config DEBUG_CLOSURES
1845	bool "Debug closures (bcache async widgits)"
1846	depends on CLOSURES
1847	select DEBUG_FS
1848	help
1849	  Keeps all active closures in a linked list and provides a debugfs
1850	  interface to list them, which makes it possible to see asynchronous
1851	  operations that get stuck.
1852
1853config DEBUG_MAPLE_TREE
1854	bool "Debug maple trees"
1855	depends on DEBUG_KERNEL
1856	help
1857	  Enable maple tree debugging information and extra validations.
1858
1859	  If unsure, say N.
1860
1861endmenu
1862
1863source "kernel/rcu/Kconfig.debug"
1864
1865config DEBUG_WQ_FORCE_RR_CPU
1866	bool "Force round-robin CPU selection for unbound work items"
1867	depends on DEBUG_KERNEL
1868	default n
1869	help
1870	  Workqueue used to implicitly guarantee that work items queued
1871	  without explicit CPU specified are put on the local CPU.  This
1872	  guarantee is no longer true and while local CPU is still
1873	  preferred work items may be put on foreign CPUs.  Kernel
1874	  parameter "workqueue.debug_force_rr_cpu" is added to force
1875	  round-robin CPU selection to flush out usages which depend on the
1876	  now broken guarantee.  This config option enables the debug
1877	  feature by default.  When enabled, memory and cache locality will
1878	  be impacted.
1879
1880config CPU_HOTPLUG_STATE_CONTROL
1881	bool "Enable CPU hotplug state control"
1882	depends on DEBUG_KERNEL
1883	depends on HOTPLUG_CPU
1884	default n
1885	help
1886	  Allows to write steps between "offline" and "online" to the CPUs
1887	  sysfs target file so states can be stepped granular. This is a debug
1888	  option for now as the hotplug machinery cannot be stopped and
1889	  restarted at arbitrary points yet.
1890
1891	  Say N if your are unsure.
1892
1893config LATENCYTOP
1894	bool "Latency measuring infrastructure"
1895	depends on DEBUG_KERNEL
1896	depends on STACKTRACE_SUPPORT
1897	depends on PROC_FS
1898	depends on FRAME_POINTER || MIPS || PPC || S390 || MICROBLAZE || ARM || ARC || X86
1899	select KALLSYMS
1900	select KALLSYMS_ALL
1901	select STACKTRACE
1902	select SCHEDSTATS
1903	help
1904	  Enable this option if you want to use the LatencyTOP tool
1905	  to find out which userspace is blocking on what kernel operations.
1906
1907config DEBUG_CGROUP_REF
1908	bool "Disable inlining of cgroup css reference count functions"
1909	depends on DEBUG_KERNEL
1910	depends on CGROUPS
1911	depends on KPROBES
1912	default n
1913	help
1914	  Force cgroup css reference count functions to not be inlined so
1915	  that they can be kprobed for debugging.
1916
1917source "kernel/trace/Kconfig"
1918
1919config PROVIDE_OHCI1394_DMA_INIT
1920	bool "Remote debugging over FireWire early on boot"
1921	depends on PCI && X86
1922	help
1923	  If you want to debug problems which hang or crash the kernel early
1924	  on boot and the crashing machine has a FireWire port, you can use
1925	  this feature to remotely access the memory of the crashed machine
1926	  over FireWire. This employs remote DMA as part of the OHCI1394
1927	  specification which is now the standard for FireWire controllers.
1928
1929	  With remote DMA, you can monitor the printk buffer remotely using
1930	  firescope and access all memory below 4GB using fireproxy from gdb.
1931	  Even controlling a kernel debugger is possible using remote DMA.
1932
1933	  Usage:
1934
1935	  If ohci1394_dma=early is used as boot parameter, it will initialize
1936	  all OHCI1394 controllers which are found in the PCI config space.
1937
1938	  As all changes to the FireWire bus such as enabling and disabling
1939	  devices cause a bus reset and thereby disable remote DMA for all
1940	  devices, be sure to have the cable plugged and FireWire enabled on
1941	  the debugging host before booting the debug target for debugging.
1942
1943	  This code (~1k) is freed after boot. By then, the firewire stack
1944	  in charge of the OHCI-1394 controllers should be used instead.
1945
1946	  See Documentation/core-api/debugging-via-ohci1394.rst for more information.
1947
1948source "samples/Kconfig"
1949
1950config ARCH_HAS_DEVMEM_IS_ALLOWED
1951	bool
1952
1953config STRICT_DEVMEM
1954	bool "Filter access to /dev/mem"
1955	depends on MMU && DEVMEM
1956	depends on ARCH_HAS_DEVMEM_IS_ALLOWED || GENERIC_LIB_DEVMEM_IS_ALLOWED
1957	default y if PPC || X86 || ARM64 || S390
1958	help
1959	  If this option is disabled, you allow userspace (root) access to all
1960	  of memory, including kernel and userspace memory. Accidental
1961	  access to this is obviously disastrous, but specific access can
1962	  be used by people debugging the kernel. Note that with PAT support
1963	  enabled, even in this case there are restrictions on /dev/mem
1964	  use due to the cache aliasing requirements.
1965
1966	  If this option is switched on, and IO_STRICT_DEVMEM=n, the /dev/mem
1967	  file only allows userspace access to PCI space and the BIOS code and
1968	  data regions.  This is sufficient for dosemu and X and all common
1969	  users of /dev/mem.
1970
1971	  If in doubt, say Y.
1972
1973config IO_STRICT_DEVMEM
1974	bool "Filter I/O access to /dev/mem"
1975	depends on STRICT_DEVMEM
1976	help
1977	  If this option is disabled, you allow userspace (root) access to all
1978	  io-memory regardless of whether a driver is actively using that
1979	  range.  Accidental access to this is obviously disastrous, but
1980	  specific access can be used by people debugging kernel drivers.
1981
1982	  If this option is switched on, the /dev/mem file only allows
1983	  userspace access to *idle* io-memory ranges (see /proc/iomem) This
1984	  may break traditional users of /dev/mem (dosemu, legacy X, etc...)
1985	  if the driver using a given range cannot be disabled.
1986
1987	  If in doubt, say Y.
1988
1989menu "$(SRCARCH) Debugging"
1990
1991source "arch/$(SRCARCH)/Kconfig.debug"
1992
1993endmenu
1994
1995menu "Kernel Testing and Coverage"
1996
1997source "lib/kunit/Kconfig"
1998
1999config NOTIFIER_ERROR_INJECTION
2000	tristate "Notifier error injection"
2001	depends on DEBUG_KERNEL
2002	select DEBUG_FS
2003	help
2004	  This option provides the ability to inject artificial errors to
2005	  specified notifier chain callbacks. It is useful to test the error
2006	  handling of notifier call chain failures.
2007
2008	  Say N if unsure.
2009
2010config PM_NOTIFIER_ERROR_INJECT
2011	tristate "PM notifier error injection module"
2012	depends on PM && NOTIFIER_ERROR_INJECTION
2013	default m if PM_DEBUG
2014	help
2015	  This option provides the ability to inject artificial errors to
2016	  PM notifier chain callbacks.  It is controlled through debugfs
2017	  interface /sys/kernel/debug/notifier-error-inject/pm
2018
2019	  If the notifier call chain should be failed with some events
2020	  notified, write the error code to "actions/<notifier event>/error".
2021
2022	  Example: Inject PM suspend error (-12 = -ENOMEM)
2023
2024	  # cd /sys/kernel/debug/notifier-error-inject/pm/
2025	  # echo -12 > actions/PM_SUSPEND_PREPARE/error
2026	  # echo mem > /sys/power/state
2027	  bash: echo: write error: Cannot allocate memory
2028
2029	  To compile this code as a module, choose M here: the module will
2030	  be called pm-notifier-error-inject.
2031
2032	  If unsure, say N.
2033
2034config OF_RECONFIG_NOTIFIER_ERROR_INJECT
2035	tristate "OF reconfig notifier error injection module"
2036	depends on OF_DYNAMIC && NOTIFIER_ERROR_INJECTION
2037	help
2038	  This option provides the ability to inject artificial errors to
2039	  OF reconfig notifier chain callbacks.  It is controlled
2040	  through debugfs interface under
2041	  /sys/kernel/debug/notifier-error-inject/OF-reconfig/
2042
2043	  If the notifier call chain should be failed with some events
2044	  notified, write the error code to "actions/<notifier event>/error".
2045
2046	  To compile this code as a module, choose M here: the module will
2047	  be called of-reconfig-notifier-error-inject.
2048
2049	  If unsure, say N.
2050
2051config NETDEV_NOTIFIER_ERROR_INJECT
2052	tristate "Netdev notifier error injection module"
2053	depends on NET && NOTIFIER_ERROR_INJECTION
2054	help
2055	  This option provides the ability to inject artificial errors to
2056	  netdevice notifier chain callbacks.  It is controlled through debugfs
2057	  interface /sys/kernel/debug/notifier-error-inject/netdev
2058
2059	  If the notifier call chain should be failed with some events
2060	  notified, write the error code to "actions/<notifier event>/error".
2061
2062	  Example: Inject netdevice mtu change error (-22 = -EINVAL)
2063
2064	  # cd /sys/kernel/debug/notifier-error-inject/netdev
2065	  # echo -22 > actions/NETDEV_CHANGEMTU/error
2066	  # ip link set eth0 mtu 1024
2067	  RTNETLINK answers: Invalid argument
2068
2069	  To compile this code as a module, choose M here: the module will
2070	  be called netdev-notifier-error-inject.
2071
2072	  If unsure, say N.
2073
2074config FUNCTION_ERROR_INJECTION
2075	bool "Fault-injections of functions"
2076	depends on HAVE_FUNCTION_ERROR_INJECTION && KPROBES
2077	help
2078	  Add fault injections into various functions that are annotated with
2079	  ALLOW_ERROR_INJECTION() in the kernel. BPF may also modify the return
2080	  value of these functions. This is useful to test error paths of code.
2081
2082	  If unsure, say N
2083
2084config FAULT_INJECTION
2085	bool "Fault-injection framework"
2086	depends on DEBUG_KERNEL
2087	help
2088	  Provide fault-injection framework.
2089	  For more details, see Documentation/fault-injection/.
2090
2091config FAILSLAB
2092	bool "Fault-injection capability for kmalloc"
2093	depends on FAULT_INJECTION
2094	help
2095	  Provide fault-injection capability for kmalloc.
2096
2097config FAIL_PAGE_ALLOC
2098	bool "Fault-injection capability for alloc_pages()"
2099	depends on FAULT_INJECTION
2100	help
2101	  Provide fault-injection capability for alloc_pages().
2102
2103config FAULT_INJECTION_USERCOPY
2104	bool "Fault injection capability for usercopy functions"
2105	depends on FAULT_INJECTION
2106	help
2107	  Provides fault-injection capability to inject failures
2108	  in usercopy functions (copy_from_user(), get_user(), ...).
2109
2110config FAIL_MAKE_REQUEST
2111	bool "Fault-injection capability for disk IO"
2112	depends on FAULT_INJECTION && BLOCK
2113	help
2114	  Provide fault-injection capability for disk IO.
2115
2116config FAIL_IO_TIMEOUT
2117	bool "Fault-injection capability for faking disk interrupts"
2118	depends on FAULT_INJECTION && BLOCK
2119	help
2120	  Provide fault-injection capability on end IO handling. This
2121	  will make the block layer "forget" an interrupt as configured,
2122	  thus exercising the error handling.
2123
2124	  Only works with drivers that use the generic timeout handling,
2125	  for others it won't do anything.
2126
2127config FAIL_FUTEX
2128	bool "Fault-injection capability for futexes"
2129	select DEBUG_FS
2130	depends on FAULT_INJECTION && FUTEX
2131	help
2132	  Provide fault-injection capability for futexes.
2133
2134config FAULT_INJECTION_DEBUG_FS
2135	bool "Debugfs entries for fault-injection capabilities"
2136	depends on FAULT_INJECTION && SYSFS && DEBUG_FS
2137	help
2138	  Enable configuration of fault-injection capabilities via debugfs.
2139
2140config FAIL_FUNCTION
2141	bool "Fault-injection capability for functions"
2142	depends on FAULT_INJECTION_DEBUG_FS && FUNCTION_ERROR_INJECTION
2143	help
2144	  Provide function-based fault-injection capability.
2145	  This will allow you to override a specific function with a return
2146	  with given return value. As a result, function caller will see
2147	  an error value and have to handle it. This is useful to test the
2148	  error handling in various subsystems.
2149
2150config FAIL_MMC_REQUEST
2151	bool "Fault-injection capability for MMC IO"
2152	depends on FAULT_INJECTION_DEBUG_FS && MMC
2153	help
2154	  Provide fault-injection capability for MMC IO.
2155	  This will make the mmc core return data errors. This is
2156	  useful to test the error handling in the mmc block device
2157	  and to test how the mmc host driver handles retries from
2158	  the block device.
2159
2160config FAIL_SUNRPC
2161	bool "Fault-injection capability for SunRPC"
2162	depends on FAULT_INJECTION_DEBUG_FS && SUNRPC_DEBUG
2163	help
2164	  Provide fault-injection capability for SunRPC and
2165	  its consumers.
2166
2167config FAIL_SKB_REALLOC
2168	bool "Fault-injection capability forcing skb to reallocate"
2169	depends on FAULT_INJECTION_DEBUG_FS
2170	help
2171	  Provide fault-injection capability that forces the skb to be
2172	  reallocated, catching possible invalid pointers to the skb.
2173
2174	  For more information, check
2175	  Documentation/fault-injection/fault-injection.rst
2176
2177config FAULT_INJECTION_CONFIGFS
2178	bool "Configfs interface for fault-injection capabilities"
2179	depends on FAULT_INJECTION
2180	select CONFIGFS_FS
2181	help
2182	  This option allows configfs-based drivers to dynamically configure
2183	  fault-injection via configfs.  Each parameter for driver-specific
2184	  fault-injection can be made visible as a configfs attribute in a
2185	  configfs group.
2186
2187
2188config FAULT_INJECTION_STACKTRACE_FILTER
2189	bool "stacktrace filter for fault-injection capabilities"
2190	depends on FAULT_INJECTION
2191	depends on (FAULT_INJECTION_DEBUG_FS || FAULT_INJECTION_CONFIGFS) && STACKTRACE_SUPPORT
2192	select STACKTRACE
2193	depends on FRAME_POINTER || MIPS || PPC || S390 || MICROBLAZE || ARM || ARC || X86
2194	help
2195	  Provide stacktrace filter for fault-injection capabilities
2196
2197config ARCH_HAS_KCOV
2198	bool
2199	help
2200	  An architecture should select this when it can successfully
2201	  build and run with CONFIG_KCOV. This typically requires
2202	  disabling instrumentation for some early boot code.
2203
2204config KCOV
2205	bool "Code coverage for fuzzing"
2206	depends on ARCH_HAS_KCOV
2207	depends on !ARCH_WANTS_NO_INSTR || HAVE_NOINSTR_HACK || \
2208		   GCC_VERSION >= 120000 || CC_IS_CLANG
2209	select DEBUG_FS
2210	select OBJTOOL if HAVE_NOINSTR_HACK
2211	help
2212	  KCOV exposes kernel code coverage information in a form suitable
2213	  for coverage-guided fuzzing (randomized testing).
2214
2215	  For more details, see Documentation/dev-tools/kcov.rst.
2216
2217config KCOV_ENABLE_COMPARISONS
2218	bool "Enable comparison operands collection by KCOV"
2219	depends on KCOV
2220	depends on $(cc-option,-fsanitize-coverage=trace-cmp)
2221	help
2222	  KCOV also exposes operands of every comparison in the instrumented
2223	  code along with operand sizes and PCs of the comparison instructions.
2224	  These operands can be used by fuzzing engines to improve the quality
2225	  of fuzzing coverage.
2226
2227config KCOV_INSTRUMENT_ALL
2228	bool "Instrument all code by default"
2229	depends on KCOV
2230	default y
2231	help
2232	  If you are doing generic system call fuzzing (like e.g. syzkaller),
2233	  then you will want to instrument the whole kernel and you should
2234	  say y here. If you are doing more targeted fuzzing (like e.g.
2235	  filesystem fuzzing with AFL) then you will want to enable coverage
2236	  for more specific subsets of files, and should say n here.
2237
2238config KCOV_IRQ_AREA_SIZE
2239	hex "Size of interrupt coverage collection area in words"
2240	depends on KCOV
2241	default 0x40000
2242	help
2243	  KCOV uses preallocated per-cpu areas to collect coverage from
2244	  soft interrupts. This specifies the size of those areas in the
2245	  number of unsigned long words.
2246
2247config KCOV_SELFTEST
2248	bool "Perform short selftests on boot"
2249	depends on KCOV
2250	help
2251	  Run short KCOV coverage collection selftests on boot.
2252	  On test failure, causes the kernel to panic. Recommended to be
2253	  enabled, ensuring critical functionality works as intended.
2254
2255menuconfig RUNTIME_TESTING_MENU
2256	bool "Runtime Testing"
2257	default y
2258
2259if RUNTIME_TESTING_MENU
2260
2261config TEST_DHRY
2262	tristate "Dhrystone benchmark test"
2263	help
2264	  Enable this to include the Dhrystone 2.1 benchmark.  This test
2265	  calculates the number of Dhrystones per second, and the number of
2266	  DMIPS (Dhrystone MIPS) obtained when the Dhrystone score is divided
2267	  by 1757 (the number of Dhrystones per second obtained on the VAX
2268	  11/780, nominally a 1 MIPS machine).
2269
2270	  To run the benchmark, it needs to be enabled explicitly, either from
2271	  the kernel command line (when built-in), or from userspace (when
2272	  built-in or modular).
2273
2274	  Run once during kernel boot:
2275
2276	      test_dhry.run
2277
2278	  Set number of iterations from kernel command line:
2279
2280	      test_dhry.iterations=<n>
2281
2282	  Set number of iterations from userspace:
2283
2284	      echo <n> > /sys/module/test_dhry/parameters/iterations
2285
2286	  Trigger manual run from userspace:
2287
2288	      echo y > /sys/module/test_dhry/parameters/run
2289
2290	  If the number of iterations is <= 0, the test will devise a suitable
2291	  number of iterations (test runs for at least 2s) automatically.
2292	  This process takes ca. 4s.
2293
2294	  If unsure, say N.
2295
2296config LKDTM
2297	tristate "Linux Kernel Dump Test Tool Module"
2298	depends on DEBUG_FS
2299	help
2300	This module enables testing of the different dumping mechanisms by
2301	inducing system failures at predefined crash points.
2302	If you don't need it: say N
2303	Choose M here to compile this code as a module. The module will be
2304	called lkdtm.
2305
2306	Documentation on how to use the module can be found in
2307	Documentation/fault-injection/provoke-crashes.rst
2308
2309config CPUMASK_KUNIT_TEST
2310	tristate "KUnit test for cpumask" if !KUNIT_ALL_TESTS
2311	depends on KUNIT
2312	default KUNIT_ALL_TESTS
2313	help
2314	  Enable to turn on cpumask tests, running at boot or module load time.
2315
2316	  For more information on KUnit and unit tests in general, please refer
2317	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2318
2319	  If unsure, say N.
2320
2321config TEST_LIST_SORT
2322	tristate "Linked list sorting test" if !KUNIT_ALL_TESTS
2323	depends on KUNIT
2324	default KUNIT_ALL_TESTS
2325	help
2326	  Enable this to turn on 'list_sort()' function test. This test is
2327	  executed only once during system boot (so affects only boot time),
2328	  or at module load time.
2329
2330	  If unsure, say N.
2331
2332config TEST_SORT
2333	tristate "Array-based sort test" if !KUNIT_ALL_TESTS
2334	depends on KUNIT
2335	default KUNIT_ALL_TESTS
2336	help
2337	  This option enables the self-test function of 'sort()' at boot,
2338	  or at module load time.
2339
2340	  If unsure, say N.
2341
2342config TEST_DIV64
2343	tristate "64bit/32bit division and modulo test"
2344	depends on DEBUG_KERNEL || m
2345	help
2346	  Enable this to turn on 'do_div()' function test. This test is
2347	  executed only once during system boot (so affects only boot time),
2348	  or at module load time.
2349
2350	  If unsure, say N.
2351
2352config TEST_MULDIV64
2353	tristate "mul_u64_u64_div_u64() test"
2354	depends on DEBUG_KERNEL || m
2355	help
2356	  Enable this to turn on 'mul_u64_u64_div_u64()' function test.
2357	  This test is executed only once during system boot (so affects
2358	  only boot time), or at module load time.
2359
2360	  If unsure, say N.
2361
2362config TEST_IOV_ITER
2363	tristate "Test iov_iter operation" if !KUNIT_ALL_TESTS
2364	depends on KUNIT
2365	depends on MMU
2366	default KUNIT_ALL_TESTS
2367	help
2368	  Enable this to turn on testing of the operation of the I/O iterator
2369	  (iov_iter). This test is executed only once during system boot (so
2370	  affects only boot time), or at module load time.
2371
2372	  If unsure, say N.
2373
2374config KPROBES_SANITY_TEST
2375	tristate "Kprobes sanity tests" if !KUNIT_ALL_TESTS
2376	depends on DEBUG_KERNEL
2377	depends on KPROBES
2378	depends on KUNIT
2379	select STACKTRACE if ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
2380	default KUNIT_ALL_TESTS
2381	help
2382	  This option provides for testing basic kprobes functionality on
2383	  boot. Samples of kprobe and kretprobe are inserted and
2384	  verified for functionality.
2385
2386	  Say N if you are unsure.
2387
2388config FPROBE_SANITY_TEST
2389	bool "Self test for fprobe"
2390	depends on DEBUG_KERNEL
2391	depends on FPROBE
2392	depends on KUNIT=y
2393	help
2394	  This option will enable testing the fprobe when the system boot.
2395	  A series of tests are made to verify that the fprobe is functioning
2396	  properly.
2397
2398	  Say N if you are unsure.
2399
2400config BACKTRACE_SELF_TEST
2401	tristate "Self test for the backtrace code"
2402	depends on DEBUG_KERNEL
2403	help
2404	  This option provides a kernel module that can be used to test
2405	  the kernel stack backtrace code. This option is not useful
2406	  for distributions or general kernels, but only for kernel
2407	  developers working on architecture code.
2408
2409	  Note that if you want to also test saved backtraces, you will
2410	  have to enable STACKTRACE as well.
2411
2412	  Say N if you are unsure.
2413
2414config TEST_REF_TRACKER
2415	tristate "Self test for reference tracker"
2416	depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
2417	select REF_TRACKER
2418	help
2419	  This option provides a kernel module performing tests
2420	  using reference tracker infrastructure.
2421
2422	  Say N if you are unsure.
2423
2424config RBTREE_TEST
2425	tristate "Red-Black tree test"
2426	depends on DEBUG_KERNEL
2427	help
2428	  A benchmark measuring the performance of the rbtree library.
2429	  Also includes rbtree invariant checks.
2430
2431config REED_SOLOMON_TEST
2432	tristate "Reed-Solomon library test"
2433	depends on DEBUG_KERNEL || m
2434	select REED_SOLOMON
2435	select REED_SOLOMON_ENC16
2436	select REED_SOLOMON_DEC16
2437	help
2438	  This option enables the self-test function of rslib at boot,
2439	  or at module load time.
2440
2441	  If unsure, say N.
2442
2443config INTERVAL_TREE_TEST
2444	tristate "Interval tree test"
2445	depends on DEBUG_KERNEL
2446	select INTERVAL_TREE
2447	help
2448	  A benchmark measuring the performance of the interval tree library
2449
2450config PERCPU_TEST
2451	tristate "Per cpu operations test"
2452	depends on m && DEBUG_KERNEL
2453	help
2454	  Enable this option to build test module which validates per-cpu
2455	  operations.
2456
2457	  If unsure, say N.
2458
2459config ATOMIC64_SELFTEST
2460	tristate "Perform an atomic64_t self-test"
2461	help
2462	  Enable this option to test the atomic64_t functions at boot or
2463	  at module load time.
2464
2465	  If unsure, say N.
2466
2467config ASYNC_RAID6_TEST
2468	tristate "Self test for hardware accelerated raid6 recovery"
2469	depends on ASYNC_RAID6_RECOV
2470	select ASYNC_MEMCPY
2471	help
2472	  This is a one-shot self test that permutes through the
2473	  recovery of all the possible two disk failure scenarios for a
2474	  N-disk array.  Recovery is performed with the asynchronous
2475	  raid6 recovery routines, and will optionally use an offload
2476	  engine if one is available.
2477
2478	  If unsure, say N.
2479
2480config TEST_HEXDUMP
2481	tristate "Test functions located in the hexdump module at runtime"
2482
2483config PRINTF_KUNIT_TEST
2484	tristate "KUnit test printf() family of functions at runtime" if !KUNIT_ALL_TESTS
2485	depends on KUNIT
2486	default KUNIT_ALL_TESTS
2487	help
2488	  Enable this option to test the printf functions at runtime.
2489
2490	  If unsure, say N.
2491
2492config SCANF_KUNIT_TEST
2493	tristate "KUnit test scanf() family of functions at runtime" if !KUNIT_ALL_TESTS
2494	depends on KUNIT
2495	default KUNIT_ALL_TESTS
2496	help
2497	  Enable this option to test the scanf functions at runtime.
2498
2499	  If unsure, say N.
2500
2501config SEQ_BUF_KUNIT_TEST
2502	tristate "KUnit test for seq_buf" if !KUNIT_ALL_TESTS
2503	depends on KUNIT
2504	default KUNIT_ALL_TESTS
2505	help
2506	  This builds unit tests for the seq_buf library.
2507
2508	  If unsure, say N.
2509
2510config STRING_KUNIT_TEST
2511	tristate "KUnit test string functions at runtime" if !KUNIT_ALL_TESTS
2512	depends on KUNIT
2513	default KUNIT_ALL_TESTS
2514
2515config STRING_HELPERS_KUNIT_TEST
2516	tristate "KUnit test string helpers at runtime" if !KUNIT_ALL_TESTS
2517	depends on KUNIT
2518	default KUNIT_ALL_TESTS
2519
2520config FFS_KUNIT_TEST
2521	tristate "KUnit test ffs-family functions at runtime" if !KUNIT_ALL_TESTS
2522	depends on KUNIT
2523	default KUNIT_ALL_TESTS
2524	help
2525	  This builds KUnit tests for ffs-family bit manipulation functions
2526	  including ffs(), __ffs(), fls(), __fls(), fls64(), and __ffs64().
2527
2528	  These tests validate mathematical correctness, edge case handling,
2529	  and cross-architecture consistency of bit scanning functions.
2530
2531	  For more information on KUnit and unit tests in general,
2532	  please refer to Documentation/dev-tools/kunit/.
2533
2534config TEST_KSTRTOX
2535	tristate "Test kstrto*() family of functions at runtime"
2536
2537config TEST_BITMAP
2538	tristate "Test bitmap_*() family of functions at runtime"
2539	help
2540	  Enable this option to test the bitmap functions at boot.
2541
2542	  If unsure, say N.
2543
2544config TEST_XARRAY
2545	tristate "Test the XArray code at runtime"
2546
2547config TEST_MAPLE_TREE
2548	tristate "Test the Maple Tree code at runtime or module load"
2549	help
2550	  Enable this option to test the maple tree code functions at boot, or
2551	  when the module is loaded. Enable "Debug Maple Trees" will enable
2552	  more verbose output on failures.
2553
2554	  If unsure, say N.
2555
2556config TEST_RHASHTABLE
2557	tristate "Perform selftest on resizable hash table"
2558	help
2559	  Enable this option to test the rhashtable functions at boot.
2560
2561	  If unsure, say N.
2562
2563config TEST_IDA
2564	tristate "Perform selftest on IDA functions"
2565
2566config TEST_MISC_MINOR
2567	bool "miscdevice KUnit test" if !KUNIT_ALL_TESTS
2568	depends on KUNIT=y
2569	default KUNIT_ALL_TESTS
2570	help
2571	  Kunit test for miscdevice API, specially its behavior in respect to
2572	  static and dynamic minor numbers.
2573
2574	  KUnit tests run during boot and output the results to the debug log
2575	  in TAP format (https://testanything.org/). Only useful for kernel devs
2576	  running the KUnit test harness, and not intended for inclusion into a
2577	  production build.
2578
2579	  For more information on KUnit and unit tests in general please refer
2580	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2581
2582	  If unsure, say N.
2583
2584config TEST_PARMAN
2585	tristate "Perform selftest on priority array manager"
2586	depends on PARMAN
2587	help
2588	  Enable this option to test priority array manager on boot
2589	  (or module load).
2590
2591	  If unsure, say N.
2592
2593config TEST_LKM
2594	tristate "Test module loading with 'hello world' module"
2595	depends on m
2596	help
2597	  This builds the "test_module" module that emits "Hello, world"
2598	  on printk when loaded. It is designed to be used for basic
2599	  evaluation of the module loading subsystem (for example when
2600	  validating module verification). It lacks any extra dependencies,
2601	  and will not normally be loaded by the system unless explicitly
2602	  requested by name.
2603
2604	  If unsure, say N.
2605
2606config TEST_BITOPS
2607	tristate "Test module for compilation of bitops operations"
2608	help
2609	  This builds the "test_bitops" module that is much like the
2610	  TEST_LKM module except that it does a basic exercise of the
2611	  set/clear_bit macros and get_count_order/long to make sure there are
2612	  no compiler warnings from C=1 sparse checker or -Wextra
2613	  compilations. It has no dependencies and doesn't run or load unless
2614	  explicitly requested by name.  for example: modprobe test_bitops.
2615
2616	  If unsure, say N.
2617
2618config TEST_VMALLOC
2619	tristate "Test module for stress/performance analysis of vmalloc allocator"
2620	default n
2621	depends on MMU
2622	help
2623	  This builds the "test_vmalloc" module that should be used for
2624	  stress and performance analysis. So, any new change for vmalloc
2625	  subsystem can be evaluated from performance and stability point
2626	  of view.
2627
2628	  If unsure, say N.
2629
2630config TEST_BPF
2631	tristate "Test BPF filter functionality"
2632	depends on m && NET
2633	help
2634	  This builds the "test_bpf" module that runs various test vectors
2635	  against the BPF interpreter or BPF JIT compiler depending on the
2636	  current setting. This is in particular useful for BPF JIT compiler
2637	  development, but also to run regression tests against changes in
2638	  the interpreter code. It also enables test stubs for eBPF maps and
2639	  verifier used by user space verifier testsuite.
2640
2641	  If unsure, say N.
2642
2643config FIND_BIT_BENCHMARK
2644	tristate "Test find_bit functions"
2645	help
2646	  This builds the "test_find_bit" module that measure find_*_bit()
2647	  functions performance.
2648
2649	  If unsure, say N.
2650
2651config FIND_BIT_BENCHMARK_RUST
2652	tristate "Test find_bit functions in Rust"
2653	depends on RUST
2654	help
2655	  This builds the "find_bit_benchmark_rust" module. It is a micro
2656          benchmark that measures the performance of Rust functions that
2657          correspond to the find_*_bit() operations in C. It follows the
2658          FIND_BIT_BENCHMARK closely but will in general not yield same
2659          numbers due to extra bounds checks and overhead of foreign
2660          function calls.
2661
2662	  If unsure, say N.
2663
2664config TEST_FIRMWARE
2665	tristate "Test firmware loading via userspace interface"
2666	depends on FW_LOADER
2667	help
2668	  This builds the "test_firmware" module that creates a userspace
2669	  interface for testing firmware loading. This can be used to
2670	  control the triggering of firmware loading without needing an
2671	  actual firmware-using device. The contents can be rechecked by
2672	  userspace.
2673
2674	  If unsure, say N.
2675
2676config TEST_SYSCTL
2677	tristate "sysctl test driver"
2678	depends on PROC_SYSCTL
2679	help
2680	  This builds the "test_sysctl" module. This driver enables to test the
2681	  proc sysctl interfaces available to drivers safely without affecting
2682	  production knobs which might alter system functionality.
2683
2684	  If unsure, say N.
2685
2686config BITOPS_KUNIT
2687	tristate "KUnit test for bitops" if !KUNIT_ALL_TESTS
2688	depends on KUNIT
2689	default KUNIT_ALL_TESTS
2690	help
2691	  This option enables the KUnit test for the bitops library
2692	  which provides functions for bit operations.
2693
2694	  Note that this is derived from the original test_bitops module.
2695	  For micro-benchmarks and compiler warning checks, enable TEST_BITOPS.
2696
2697	  If unsure, say N.
2698
2699config BITFIELD_KUNIT
2700	tristate "KUnit test bitfield functions at runtime" if !KUNIT_ALL_TESTS
2701	depends on KUNIT
2702	default KUNIT_ALL_TESTS
2703	help
2704	  Enable this option to test the bitfield functions at boot.
2705
2706	  KUnit tests run during boot and output the results to the debug log
2707	  in TAP format (http://testanything.org/). Only useful for kernel devs
2708	  running the KUnit test harness, and not intended for inclusion into a
2709	  production build.
2710
2711	  For more information on KUnit and unit tests in general please refer
2712	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2713
2714	  If unsure, say N.
2715
2716config CHECKSUM_KUNIT
2717	tristate "KUnit test checksum functions at runtime" if !KUNIT_ALL_TESTS
2718	depends on KUNIT
2719	default KUNIT_ALL_TESTS
2720	help
2721	  Enable this option to test the checksum functions at boot.
2722
2723	  KUnit tests run during boot and output the results to the debug log
2724	  in TAP format (http://testanything.org/). Only useful for kernel devs
2725	  running the KUnit test harness, and not intended for inclusion into a
2726	  production build.
2727
2728	  For more information on KUnit and unit tests in general please refer
2729	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2730
2731	  If unsure, say N.
2732
2733config UTIL_MACROS_KUNIT
2734	tristate "KUnit test util_macros.h functions at runtime" if !KUNIT_ALL_TESTS
2735	depends on KUNIT
2736	default KUNIT_ALL_TESTS
2737	help
2738	  Enable this option to test the util_macros.h function at boot.
2739
2740	  KUnit tests run during boot and output the results to the debug log
2741	  in TAP format (http://testanything.org/). Only useful for kernel devs
2742	  running the KUnit test harness, and not intended for inclusion into a
2743	  production build.
2744
2745	  For more information on KUnit and unit tests in general please refer
2746	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2747
2748	  If unsure, say N.
2749
2750config HASH_KUNIT_TEST
2751	tristate "KUnit Test for integer hash functions" if !KUNIT_ALL_TESTS
2752	depends on KUNIT
2753	default KUNIT_ALL_TESTS
2754	help
2755	  Enable this option to test the kernel's string (<linux/stringhash.h>), and
2756	  integer (<linux/hash.h>) hash functions on boot.
2757
2758	  KUnit tests run during boot and output the results to the debug log
2759	  in TAP format (https://testanything.org/). Only useful for kernel devs
2760	  running the KUnit test harness, and not intended for inclusion into a
2761	  production build.
2762
2763	  For more information on KUnit and unit tests in general please refer
2764	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2765
2766	  This is intended to help people writing architecture-specific
2767	  optimized versions. If unsure, say N.
2768
2769config RESOURCE_KUNIT_TEST
2770	tristate "KUnit test for resource API" if !KUNIT_ALL_TESTS
2771	depends on KUNIT
2772	default KUNIT_ALL_TESTS
2773	select GET_FREE_REGION
2774	help
2775	  This builds the resource API unit test.
2776	  Tests the logic of API provided by resource.c and ioport.h.
2777	  For more information on KUnit and unit tests in general please refer
2778	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2779
2780	  If unsure, say N.
2781
2782config SYSCTL_KUNIT_TEST
2783	tristate "KUnit test for sysctl" if !KUNIT_ALL_TESTS
2784	depends on KUNIT
2785	default KUNIT_ALL_TESTS
2786	help
2787	  This builds the proc sysctl unit test, which runs on boot.
2788	  Tests the API contract and implementation correctness of sysctl.
2789	  For more information on KUnit and unit tests in general please refer
2790	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2791
2792	  If unsure, say N.
2793
2794config KFIFO_KUNIT_TEST
2795	tristate "KUnit Test for the generic kernel FIFO implementation" if !KUNIT_ALL_TESTS
2796	depends on KUNIT
2797	default KUNIT_ALL_TESTS
2798	help
2799	  This builds the generic FIFO implementation KUnit test suite.
2800	  It tests that the API and basic functionality of the kfifo type
2801	  and associated macros.
2802
2803	  For more information on KUnit and unit tests in general please refer
2804	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2805
2806	  If unsure, say N.
2807
2808config LIST_KUNIT_TEST
2809	tristate "KUnit Test for Kernel Linked-list structures" if !KUNIT_ALL_TESTS
2810	depends on KUNIT
2811	default KUNIT_ALL_TESTS
2812	help
2813	  This builds the linked list KUnit test suite.
2814	  It tests that the API and basic functionality of the list_head type
2815	  and associated macros.
2816
2817	  KUnit tests run during boot and output the results to the debug log
2818	  in TAP format (https://testanything.org/). Only useful for kernel devs
2819	  running the KUnit test harness, and not intended for inclusion into a
2820	  production build.
2821
2822	  For more information on KUnit and unit tests in general please refer
2823	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2824
2825	  If unsure, say N.
2826
2827config LIST_PRIVATE_KUNIT_TEST
2828	tristate "KUnit Test for Kernel Private Linked-list structures" if !KUNIT_ALL_TESTS
2829	depends on KUNIT
2830	default KUNIT_ALL_TESTS
2831	help
2832	  This builds the KUnit test for the private linked-list primitives
2833	  defined in include/linux/list_private.h.
2834
2835	  These primitives allow manipulation of list_head members that are
2836	  marked as private and require special accessors (ACCESS_PRIVATE)
2837	  to strip qualifiers or handle encapsulation.
2838
2839	  If unsure, say N.
2840
2841config HASHTABLE_KUNIT_TEST
2842	tristate "KUnit Test for Kernel Hashtable structures" if !KUNIT_ALL_TESTS
2843	depends on KUNIT
2844	default KUNIT_ALL_TESTS
2845	help
2846	  This builds the hashtable KUnit test suite.
2847	  It tests the basic functionality of the API defined in
2848	  include/linux/hashtable.h. For more information on KUnit and
2849	  unit tests in general please refer to the KUnit documentation
2850	  in Documentation/dev-tools/kunit/.
2851
2852	  If unsure, say N.
2853
2854config LINEAR_RANGES_TEST
2855	tristate "KUnit test for linear_ranges"
2856	depends on KUNIT
2857	select LINEAR_RANGES
2858	help
2859	  This builds the linear_ranges unit test, which runs on boot.
2860	  Tests the linear_ranges logic correctness.
2861	  For more information on KUnit and unit tests in general please refer
2862	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2863
2864	  If unsure, say N.
2865
2866config CONTEXT_ANALYSIS_TEST
2867	bool "Compiler context-analysis warnings test"
2868	depends on EXPERT
2869	help
2870	  This builds the test for compiler-based context analysis. The test
2871	  does not add executable code to the kernel, but is meant to test that
2872	  common patterns supported by the analysis do not result in false
2873	  positive warnings.
2874
2875	  When adding support for new context locks, it is strongly recommended
2876	  to add supported patterns to this test.
2877
2878	  If unsure, say N.
2879
2880config LIVEUPDATE_TEST
2881	bool "Live Update Kernel Test"
2882	default n
2883	depends on LIVEUPDATE
2884	help
2885	  Enable a built-in kernel test module for the Live Update
2886	  Orchestrator.
2887
2888	  This module validates the File-Lifecycle-Bound subsystem by
2889	  registering a set of mock FLB objects with any real file handlers
2890	  that support live update (such as the memfd handler).
2891
2892	  When live update operations are performed, this test module will
2893	  output messages to the kernel log (dmesg), confirming that its
2894	  registration and various callback functions (preserve, retrieve,
2895	  finish, etc.) are being invoked correctly.
2896
2897	  This is a debugging and regression testing tool for developers
2898	  working on the Live Update subsystem. It should not be enabled in
2899	  production kernels.
2900
2901	  If unsure, say N
2902
2903config CMDLINE_KUNIT_TEST
2904	tristate "KUnit test for cmdline API" if !KUNIT_ALL_TESTS
2905	depends on KUNIT
2906	default KUNIT_ALL_TESTS
2907	help
2908	  This builds the cmdline API unit test.
2909	  Tests the logic of API provided by cmdline.c.
2910	  For more information on KUnit and unit tests in general please refer
2911	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2912
2913	  If unsure, say N.
2914
2915config BASE64_KUNIT
2916	tristate "KUnit test for base64 decoding and encoding" if !KUNIT_ALL_TESTS
2917	depends on KUNIT
2918	default KUNIT_ALL_TESTS
2919	help
2920	  This builds the base64 unit tests.
2921
2922	  The tests cover the encoding and decoding logic of Base64 functions
2923	  in the kernel.
2924	  In addition to correctness checks, simple performance benchmarks
2925	  for both encoding and decoding are also included.
2926
2927	  For more information on KUnit and unit tests in general please refer
2928	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2929
2930	  If unsure, say N.
2931
2932config BITS_TEST
2933	tristate "KUnit test for bit functions and macros" if !KUNIT_ALL_TESTS
2934	depends on KUNIT
2935	default KUNIT_ALL_TESTS
2936	help
2937	  This builds the bits unit test.
2938	  Tests the logic of macros defined in bits.h.
2939	  For more information on KUnit and unit tests in general please refer
2940	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2941
2942	  If unsure, say N.
2943
2944config SLUB_KUNIT_TEST
2945	tristate "KUnit test for SLUB cache error detection" if !KUNIT_ALL_TESTS
2946	depends on SLUB_DEBUG && KUNIT
2947	default KUNIT_ALL_TESTS
2948	help
2949	  This builds SLUB allocator unit test.
2950	  Tests SLUB cache debugging functionality.
2951	  For more information on KUnit and unit tests in general please refer
2952	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2953
2954	  If unsure, say N.
2955
2956config RATIONAL_KUNIT_TEST
2957	tristate "KUnit test for rational.c" if !KUNIT_ALL_TESTS
2958	depends on KUNIT && RATIONAL
2959	default KUNIT_ALL_TESTS
2960	help
2961	  This builds the rational math unit test.
2962	  For more information on KUnit and unit tests in general please refer
2963	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2964
2965	  If unsure, say N.
2966
2967config MEMCPY_KUNIT_TEST
2968	tristate "Test memcpy(), memmove(), and memset() functions at runtime" if !KUNIT_ALL_TESTS
2969	depends on KUNIT
2970	default KUNIT_ALL_TESTS
2971	help
2972	  Builds unit tests for memcpy(), memmove(), and memset() functions.
2973	  For more information on KUnit and unit tests in general please refer
2974	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2975
2976	  If unsure, say N.
2977
2978config MIN_HEAP_KUNIT_TEST
2979	tristate "Min heap test" if !KUNIT_ALL_TESTS
2980	depends on KUNIT
2981	default KUNIT_ALL_TESTS
2982	help
2983	  This option enables the KUnit test suite for the min heap library
2984	  which provides functions for creating and managing min heaps.
2985	  The test suite checks the functionality of the min heap library.
2986
2987	  If unsure, say N
2988
2989config IS_SIGNED_TYPE_KUNIT_TEST
2990	tristate "Test is_signed_type() macro" if !KUNIT_ALL_TESTS
2991	depends on KUNIT
2992	default KUNIT_ALL_TESTS
2993	help
2994	  Builds unit tests for the is_signed_type() macro.
2995
2996	  For more information on KUnit and unit tests in general please refer
2997	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2998
2999	  If unsure, say N.
3000
3001config OVERFLOW_KUNIT_TEST
3002	tristate "Test check_*_overflow() functions at runtime" if !KUNIT_ALL_TESTS
3003	depends on KUNIT
3004	default KUNIT_ALL_TESTS
3005	help
3006	  Builds unit tests for the check_*_overflow(), size_*(), allocation, and
3007	  related functions.
3008
3009	  For more information on KUnit and unit tests in general please refer
3010	  to the KUnit documentation in Documentation/dev-tools/kunit/.
3011
3012	  If unsure, say N.
3013
3014config RANDSTRUCT_KUNIT_TEST
3015	tristate "Test randstruct structure layout randomization at runtime" if !KUNIT_ALL_TESTS
3016	depends on KUNIT
3017	default KUNIT_ALL_TESTS
3018	help
3019	  Builds unit tests for the checking CONFIG_RANDSTRUCT=y, which
3020	  randomizes structure layouts.
3021
3022config STACKINIT_KUNIT_TEST
3023	tristate "Test level of stack variable initialization" if !KUNIT_ALL_TESTS
3024	depends on KUNIT
3025	default KUNIT_ALL_TESTS
3026	help
3027	  Test if the kernel is zero-initializing stack variables and
3028	  padding. Coverage is controlled by compiler flags,
3029	  CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_ALL_ZERO.
3030
3031config FORTIFY_KUNIT_TEST
3032	tristate "Test fortified str*() and mem*() function internals at runtime" if !KUNIT_ALL_TESTS
3033	depends on KUNIT
3034	default KUNIT_ALL_TESTS
3035	help
3036	  Builds unit tests for checking internals of FORTIFY_SOURCE as used
3037	  by the str*() and mem*() family of functions. For testing runtime
3038	  traps of FORTIFY_SOURCE, see LKDTM's "FORTIFY_*" tests.
3039
3040config LONGEST_SYM_KUNIT_TEST
3041	tristate "Test the longest symbol possible" if !KUNIT_ALL_TESTS
3042	depends on KUNIT && KPROBES
3043	depends on !PREFIX_SYMBOLS && !CFI && !GCOV_KERNEL
3044	default KUNIT_ALL_TESTS
3045	help
3046	  Tests the longest symbol possible
3047
3048	  If unsure, say N.
3049
3050config HW_BREAKPOINT_KUNIT_TEST
3051	bool "Test hw_breakpoint constraints accounting" if !KUNIT_ALL_TESTS
3052	depends on HAVE_HW_BREAKPOINT
3053	depends on KUNIT=y
3054	default KUNIT_ALL_TESTS
3055	help
3056	  Tests for hw_breakpoint constraints accounting.
3057
3058	  If unsure, say N.
3059
3060config SIPHASH_KUNIT_TEST
3061	tristate "Perform selftest on siphash functions" if !KUNIT_ALL_TESTS
3062	depends on KUNIT
3063	default KUNIT_ALL_TESTS
3064	help
3065	  Enable this option to test the kernel's siphash (<linux/siphash.h>) hash
3066	  functions on boot (or module load).
3067
3068	  This is intended to help people writing architecture-specific
3069	  optimized versions.  If unsure, say N.
3070
3071config USERCOPY_KUNIT_TEST
3072	tristate "KUnit Test for user/kernel boundary protections"
3073	depends on KUNIT
3074	default KUNIT_ALL_TESTS
3075	help
3076	  This builds the "usercopy_kunit" module that runs sanity checks
3077	  on the copy_to/from_user infrastructure, making sure basic
3078	  user/kernel boundary testing is working.
3079
3080config BLACKHOLE_DEV_KUNIT_TEST
3081	tristate "Test blackhole netdev functionality" if !KUNIT_ALL_TESTS
3082	depends on NET
3083	depends on KUNIT
3084	default KUNIT_ALL_TESTS
3085	help
3086	  This builds the "blackhole_dev_kunit" module that validates the
3087	  data path through this blackhole netdev.
3088
3089	  If unsure, say N.
3090
3091config TEST_UDELAY
3092	tristate "udelay test driver"
3093	help
3094	  This builds the "udelay_test" module that helps to make sure
3095	  that udelay() is working properly.
3096
3097	  If unsure, say N.
3098
3099config TEST_STATIC_KEYS
3100	tristate "Test static keys"
3101	depends on m
3102	help
3103	  Test the static key interfaces.
3104
3105	  If unsure, say N.
3106
3107config TEST_DYNAMIC_DEBUG
3108	tristate "Test DYNAMIC_DEBUG"
3109	depends on DYNAMIC_DEBUG
3110	help
3111	  This module registers a tracer callback to count enabled
3112	  pr_debugs in a 'do_debugging' function, then alters their
3113	  enablements, calls the function, and compares counts.
3114
3115	  If unsure, say N.
3116
3117config TEST_KMOD
3118	tristate "kmod stress tester"
3119	depends on m
3120	select TEST_LKM
3121	help
3122	  Test the kernel's module loading mechanism: kmod. kmod implements
3123	  support to load modules using the Linux kernel's usermode helper.
3124	  This test provides a series of tests against kmod.
3125
3126	  Although technically you can either build test_kmod as a module or
3127	  into the kernel we disallow building it into the kernel since
3128	  it stress tests request_module() and this will very likely cause
3129	  some issues by taking over precious threads available from other
3130	  module load requests, ultimately this could be fatal.
3131
3132	  To run tests run:
3133
3134	  tools/testing/selftests/kmod/kmod.sh --help
3135
3136	  If unsure, say N.
3137
3138config TEST_RUNTIME
3139	bool
3140
3141config TEST_RUNTIME_MODULE
3142	bool
3143
3144config TEST_KALLSYMS
3145	tristate "module kallsyms find_symbol() test"
3146	depends on m
3147	select TEST_RUNTIME
3148	select TEST_RUNTIME_MODULE
3149	select TEST_KALLSYMS_A
3150	select TEST_KALLSYMS_B
3151	select TEST_KALLSYMS_C
3152	select TEST_KALLSYMS_D
3153	help
3154	  This allows us to stress test find_symbol() through the kallsyms
3155	  used to place symbols on the kernel ELF kallsyms and modules kallsyms
3156	  where we place kernel symbols such as exported symbols.
3157
3158	  We have four test modules:
3159
3160	  A: has KALLSYSMS_NUMSYMS exported symbols
3161	  B: uses one of A's symbols
3162	  C: adds KALLSYMS_SCALE_FACTOR * KALLSYSMS_NUMSYMS exported
3163	  D: adds 2 * the symbols than C
3164
3165	  We stress test find_symbol() through two means:
3166
3167	  1) Upon load of B it will trigger simplify_symbols() to look for the
3168	  one symbol it uses from the module A with tons of symbols. This is an
3169	  indirect way for us to have B call resolve_symbol_wait() upon module
3170	  load. This will eventually call find_symbol() which will eventually
3171	  try to find the symbols used with find_exported_symbol_in_section().
3172	  find_exported_symbol_in_section() uses bsearch() so a binary search
3173	  for each symbol. Binary search will at worst be O(log(n)) so the
3174	  larger TEST_MODULE_KALLSYSMS the worse the search.
3175
3176	  2) The selftests should load C first, before B. Upon B's load towards
3177	  the end right before we call module B's init routine we get
3178	  complete_formation() called on the module. That will first check
3179	  for duplicate symbols with the call to verify_exported_symbols().
3180	  That is when we'll force iteration on module C's insane symbol list.
3181	  Since it has 10 * KALLSYMS_NUMSYMS it means we can first test
3182	  just loading B without C. The amount of time it takes to load C Vs
3183	  B can give us an idea of the impact growth of the symbol space and
3184	  give us projection. Module A only uses one symbol from B so to allow
3185	  this scaling in module C to be proportional, if it used more symbols
3186	  then the first test would be doing more and increasing just the
3187	  search space would be slightly different. The last module, module D
3188	  will just increase the search space by twice the number of symbols in
3189	  C so to allow for full projects.
3190
3191	  tools/testing/selftests/module/find_symbol.sh
3192
3193	  The current defaults will incur a build delay of about 7 minutes
3194	  on an x86_64 with only 8 cores. Enable this only if you want to
3195	  stress test find_symbol() with thousands of symbols. At the same
3196	  time this is also useful to test building modules with thousands of
3197	  symbols, and if BTF is enabled this also stress tests adding BTF
3198	  information for each module. Currently enabling many more symbols
3199	  will segfault the build system.
3200
3201	  If unsure, say N.
3202
3203if TEST_KALLSYMS
3204
3205config TEST_KALLSYMS_A
3206	tristate
3207	depends on m
3208
3209config TEST_KALLSYMS_B
3210	tristate
3211	depends on m
3212
3213config TEST_KALLSYMS_C
3214	tristate
3215	depends on m
3216
3217config TEST_KALLSYMS_D
3218	tristate
3219	depends on m
3220
3221choice
3222	prompt "Kallsym test range"
3223	default TEST_KALLSYMS_LARGE
3224	help
3225	  Selecting something other than "Fast" will enable tests which slow
3226	  down the build and may crash your build.
3227
3228config TEST_KALLSYMS_FAST
3229	bool "Fast builds"
3230	help
3231	  You won't really be testing kallsysms, so this just helps fast builds
3232	  when allmodconfig is used..
3233
3234config TEST_KALLSYMS_LARGE
3235	bool "Enable testing kallsyms with large exports"
3236	help
3237	  This will enable larger number of symbols. This will slow down
3238	  your build considerably.
3239
3240config TEST_KALLSYMS_MAX
3241	bool "Known kallsysms limits"
3242	help
3243	  This will enable exports to the point we know we'll start crashing
3244	  builds.
3245
3246endchoice
3247
3248config TEST_KALLSYMS_NUMSYMS
3249	int "test kallsyms number of symbols"
3250	range 2 10000
3251	default 2 if TEST_KALLSYMS_FAST
3252	default 100 if TEST_KALLSYMS_LARGE
3253	default 10000 if TEST_KALLSYMS_MAX
3254	help
3255	  The number of symbols to create on TEST_KALLSYMS_A, only one of which
3256	  module TEST_KALLSYMS_B will use. This also will be used
3257	  for how many symbols TEST_KALLSYMS_C will have, scaled up by
3258	  TEST_KALLSYMS_SCALE_FACTOR. Note that setting this to 10,000 will
3259	  trigger a segfault today, don't use anything close to it unless
3260	  you are aware that this should not be used for automated build tests.
3261
3262config TEST_KALLSYMS_SCALE_FACTOR
3263	int "test kallsyms scale factor"
3264	default 8
3265	help
3266	  How many more unusued symbols will TEST_KALLSYSMS_C have than
3267	  TEST_KALLSYMS_A. If 8, then module C will have 8 * syms
3268	  than module A. Then TEST_KALLSYMS_D will have double the amount
3269	  of symbols than C so to allow projections.
3270
3271endif # TEST_KALLSYMS
3272
3273config TEST_DEBUG_VIRTUAL
3274	tristate "Test CONFIG_DEBUG_VIRTUAL feature"
3275	depends on DEBUG_VIRTUAL
3276	help
3277	  Test the kernel's ability to detect incorrect calls to
3278	  virt_to_phys() done against the non-linear part of the
3279	  kernel's virtual address map.
3280
3281	  If unsure, say N.
3282
3283config TEST_MEMCAT_P
3284	tristate "Test memcat_p() helper function"
3285	help
3286	  Test the memcat_p() helper for correctly merging two
3287	  pointer arrays together.
3288
3289	  If unsure, say N.
3290
3291config TEST_OBJAGG
3292	tristate "Perform selftest on object aggreration manager"
3293	default n
3294	depends on OBJAGG
3295	help
3296	  Enable this option to test object aggregation manager on boot
3297	  (or module load).
3298
3299config TEST_MEMINIT
3300	tristate "Test heap/page initialization"
3301	help
3302	  Test if the kernel is zero-initializing heap and page allocations.
3303	  This can be useful to test init_on_alloc and init_on_free features.
3304
3305	  If unsure, say N.
3306
3307config TEST_HMM
3308	tristate "Test HMM (Heterogeneous Memory Management)"
3309	depends on TRANSPARENT_HUGEPAGE
3310	depends on DEVICE_PRIVATE
3311	select HMM_MIRROR
3312	select MMU_NOTIFIER
3313	help
3314	  This is a pseudo device driver solely for testing HMM.
3315	  Say M here if you want to build the HMM test module.
3316	  Doing so will allow you to run tools/testing/selftest/vm/hmm-tests.
3317
3318	  If unsure, say N.
3319
3320config TEST_FREE_PAGES
3321	tristate "Test freeing pages"
3322	help
3323	  Test that a memory leak does not occur due to a race between
3324	  freeing a block of pages and a speculative page reference.
3325	  Loading this module is safe if your kernel has the bug fixed.
3326	  If the bug is not fixed, it will leak gigabytes of memory and
3327	  probably OOM your system.
3328
3329config TEST_FPU
3330	tristate "Test floating point operations in kernel space"
3331	depends on ARCH_HAS_KERNEL_FPU_SUPPORT && !KCOV_INSTRUMENT_ALL
3332	help
3333	  Enable this option to add /sys/kernel/debug/selftest_helpers/test_fpu
3334	  which will trigger a sequence of floating point operations. This is used
3335	  for self-testing floating point control register setting in
3336	  kernel_fpu_begin().
3337
3338	  If unsure, say N.
3339
3340config TEST_CLOCKSOURCE_WATCHDOG
3341	tristate "Test clocksource watchdog in kernel space"
3342	depends on CLOCKSOURCE_WATCHDOG
3343	help
3344	  Enable this option to create a kernel module that will trigger
3345	  a test of the clocksource watchdog.  This module may be loaded
3346	  via modprobe or insmod in which case it will run upon being
3347	  loaded, or it may be built in, in which case it will run
3348	  shortly after boot.
3349
3350	  If unsure, say N.
3351
3352config TEST_OBJPOOL
3353	tristate "Test module for correctness and stress of objpool"
3354	default n
3355	depends on m && DEBUG_KERNEL
3356	help
3357	  This builds the "test_objpool" module that should be used for
3358	  correctness verification and concurrent testings of objects
3359	  allocation and reclamation.
3360
3361	  If unsure, say N.
3362
3363config TEST_KEXEC_HANDOVER
3364	bool "Test for Kexec HandOver"
3365	default n
3366	depends on KEXEC_HANDOVER
3367	help
3368	  This option enables test for Kexec HandOver (KHO).
3369	  The test consists of two parts: saving kernel data before kexec and
3370	  restoring the data after kexec and verifying that it was properly
3371	  handed over. This test module creates and saves data on the boot of
3372	  the first kernel and restores and verifies the data on the boot of
3373	  kexec'ed kernel.
3374
3375	  For detailed documentation about KHO, see Documentation/core-api/kho.
3376
3377	  To run the test run:
3378
3379	  tools/testing/selftests/kho/vmtest.sh -h
3380
3381	  If unsure, say N.
3382
3383config RATELIMIT_KUNIT_TEST
3384	tristate "KUnit Test for correctness and stress of ratelimit" if !KUNIT_ALL_TESTS
3385	depends on KUNIT
3386	default KUNIT_ALL_TESTS
3387	help
3388	  This builds the "test_ratelimit" module that should be used
3389	  for correctness verification and concurrent testings of rate
3390	  limiting.
3391
3392	  If unsure, say N.
3393
3394config UUID_KUNIT_TEST
3395	tristate "KUnit test for UUID" if !KUNIT_ALL_TESTS
3396	depends on KUNIT
3397	default KUNIT_ALL_TESTS
3398	help
3399	  This option enables the KUnit test suite for the uuid library,
3400	  which provides functions for generating and parsing UUID and GUID.
3401	  The test suite checks parsing of UUID and GUID strings.
3402
3403	  If unsure, say N.
3404
3405config INT_POW_KUNIT_TEST
3406	tristate "Integer exponentiation (int_pow) test" if !KUNIT_ALL_TESTS
3407	depends on KUNIT
3408	default KUNIT_ALL_TESTS
3409	help
3410	  This option enables the KUnit test suite for the int_pow function,
3411	  which performs integer exponentiation. The test suite is designed to
3412	  verify that the implementation of int_pow correctly computes the power
3413	  of a given base raised to a given exponent.
3414
3415	  Enabling this option will include tests that check various scenarios
3416	  and edge cases to ensure the accuracy and reliability of the exponentiation
3417	  function.
3418
3419	  If unsure, say N
3420
3421config INT_SQRT_KUNIT_TEST
3422	tristate "Integer square root test" if !KUNIT_ALL_TESTS
3423	depends on KUNIT
3424	default KUNIT_ALL_TESTS
3425	help
3426	  This option enables the KUnit test suite for the int_sqrt() function,
3427	  which performs square root calculation. The test suite checks
3428	  various scenarios, including edge cases, to ensure correctness.
3429
3430	  Enabling this option will include tests that check various scenarios
3431	  and edge cases to ensure the accuracy and reliability of the square root
3432	  function.
3433
3434	  If unsure, say N
3435
3436config INT_LOG_KUNIT_TEST
3437        tristate "Integer log (int_log) test" if !KUNIT_ALL_TESTS
3438        depends on KUNIT
3439        default KUNIT_ALL_TESTS
3440        help
3441          This option enables the KUnit test suite for the int_log library, which
3442          provides two functions to compute the integer logarithm in base 2 and
3443          base 10, called respectively as intlog2 and intlog10.
3444
3445          If unsure, say N
3446
3447config GCD_KUNIT_TEST
3448	tristate "Greatest common divisor test" if !KUNIT_ALL_TESTS
3449	depends on KUNIT
3450	default KUNIT_ALL_TESTS
3451	help
3452	  This option enables the KUnit test suite for the gcd() function,
3453	  which computes the greatest common divisor of two numbers.
3454
3455	  This test suite verifies the correctness of gcd() across various
3456	  scenarios, including edge cases.
3457
3458	  If unsure, say N
3459
3460config PRIME_NUMBERS_KUNIT_TEST
3461	tristate "Prime number generator test" if !KUNIT_ALL_TESTS
3462	depends on KUNIT
3463	depends on PRIME_NUMBERS
3464	default KUNIT_ALL_TESTS
3465	help
3466	  This option enables the KUnit test suite for the {is,next}_prime_number
3467	  functions.
3468
3469	  Enabling this option will include tests that compare the prime number
3470	  generator functions against a brute force implementation.
3471
3472	  If unsure, say N
3473
3474config GLOB_KUNIT_TEST
3475	tristate "Glob matching test" if !KUNIT_ALL_TESTS
3476	depends on GLOB
3477	depends on KUNIT
3478	default KUNIT_ALL_TESTS
3479	help
3480	  Enable this option to test the glob functions at runtime.
3481
3482	  This test suite verifies the correctness of glob_match() across various
3483	  scenarios, including edge cases.
3484
3485	  If unsure, say N
3486
3487endif # RUNTIME_TESTING_MENU
3488
3489config ARCH_USE_MEMTEST
3490	bool
3491	help
3492	  An architecture should select this when it uses early_memtest()
3493	  during boot process.
3494
3495config MEMTEST
3496	bool "Memtest"
3497	depends on ARCH_USE_MEMTEST
3498	help
3499	  This option adds a kernel parameter 'memtest', which allows memtest
3500	  to be set and executed.
3501	        memtest=0, mean disabled; -- default
3502	        memtest=1, mean do 1 test pattern;
3503	        ...
3504	        memtest=17, mean do 17 test patterns.
3505	  If you are unsure how to answer this question, answer N.
3506
3507
3508
3509config HYPERV_TESTING
3510	bool "Microsoft Hyper-V driver testing"
3511	default n
3512	depends on HYPERV && DEBUG_FS
3513	help
3514	  Select this option to enable Hyper-V vmbus testing.
3515
3516endmenu # "Kernel Testing and Coverage"
3517
3518menu "Rust hacking"
3519
3520config RUST_DEBUG_ASSERTIONS
3521	bool "Debug assertions"
3522	depends on RUST
3523	help
3524	  Enables rustc's `-Cdebug-assertions` codegen option.
3525
3526	  This flag lets you turn `cfg(debug_assertions)` conditional
3527	  compilation on or off. This can be used to enable extra debugging
3528	  code in development but not in production. For example, it controls
3529	  the behavior of the standard library's `debug_assert!` macro.
3530
3531	  Note that this will apply to all Rust code, including `core`.
3532
3533	  If unsure, say N.
3534
3535config RUST_OVERFLOW_CHECKS
3536	bool "Overflow checks"
3537	default y
3538	depends on RUST
3539	help
3540	  Enables rustc's `-Coverflow-checks` codegen option.
3541
3542	  This flag allows you to control the behavior of runtime integer
3543	  overflow. When overflow-checks are enabled, a Rust panic will occur
3544	  on overflow.
3545
3546	  Note that this will apply to all Rust code, including `core`.
3547
3548	  If unsure, say Y.
3549
3550config RUST_BUILD_ASSERT_ALLOW
3551	bool "Allow unoptimized build-time assertions"
3552	depends on RUST
3553	help
3554	  Controls how `build_error!` and `build_assert!` are handled during the build.
3555
3556	  If calls to them exist in the binary, it may indicate a violated invariant
3557	  or that the optimizer failed to verify the invariant during compilation.
3558
3559	  This should not happen, thus by default the build is aborted. However,
3560	  as an escape hatch, you can choose Y here to ignore them during build
3561	  and let the check be carried at runtime (with `panic!` being called if
3562	  the check fails).
3563
3564	  If unsure, say N.
3565
3566config RUST_KERNEL_DOCTESTS
3567	bool "Doctests for the `kernel` crate" if !KUNIT_ALL_TESTS
3568	depends on RUST && KUNIT=y
3569	default KUNIT_ALL_TESTS
3570	help
3571	  This builds the documentation tests of the `kernel` crate
3572	  as KUnit tests.
3573
3574	  For more information on KUnit and unit tests in general,
3575	  please refer to the KUnit documentation in Documentation/dev-tools/kunit/.
3576
3577	  If unsure, say N.
3578
3579endmenu # "Rust"
3580
3581endmenu # Kernel hacking
3582