1# Thread analyzer configuration options
2
3# Copyright (c) 2015 Wind River Systems, Inc.
4# SPDX-License-Identifier: Apache-2.0
5
6menuconfig THREAD_ANALYZER
7	bool "Thread analyzer"
8	depends on !ARCH_POSIX
9	select INIT_STACKS
10	select THREAD_MONITOR
11	select THREAD_STACK_INFO
12	select THREAD_RUNTIME_STATS
13	help
14	  Enable thread analyzer functionality and all the required modules.
15	  This module may be used to debug thread configuration issues, e.g.
16	  stack size configuration to find stack overflow or to find stacks
17	  which may be optimized.
18
19if THREAD_ANALYZER
20module = THREAD_ANALYZER
21module-str = thread analyzer
22source "subsys/logging/Kconfig.template.log_config"
23
24choice
25	prompt "Thread analysis print mode"
26	default THREAD_ANALYZER_USE_PRINTK
27
28config THREAD_ANALYZER_USE_LOG
29	bool "Use logger output"
30	select LOG
31	help
32	  Use logger output to print thread information.
33
34config THREAD_ANALYZER_USE_PRINTK
35	bool "Use printk function"
36	help
37	  Use kernel printk function to print thread information.
38
39endchoice
40
41config THREAD_ANALYZER_ISR_STACK_USAGE
42	bool "Analyze interrupt stacks usage"
43	default y
44
45config THREAD_ANALYZER_PRIV_STACK_USAGE
46	bool "Analyze privileged stacks usage"
47	depends on USERSPACE
48	depends on ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET
49	help
50	  Print privileged stack usage for user threads.
51
52config THREAD_ANALYZER_RUN_UNLOCKED
53	bool "Run analysis with interrupts unlocked"
54	default y
55	help
56	  The thread analysis takes quite a long time.
57	  Every thread it finds is analyzed word by word to find any that
58	  does not match the magic number.
59	  Normally while thread are analyzed the k_thread_foreach function
60	  is used.
61	  While this is a safe run from the thread list perspective it may lock
62	  the interrupts for a long time - long enough to disconnect when
63	  Bluetooth communication is used.
64	  Setting this flag will force thread analyzer to use
65	  the k_thread_foreach_unlocked function.
66	  This will allow the interrupts to be processed while the thread is
67	  analyzed.
68	  For the limitation of such configuration see the k_thread_foreach
69	  documentation.
70
71config THREAD_ANALYZER_AUTO
72	bool "Run periodic thread analysis in a thread"
73	help
74	  Run the thread analyzer automatically, without the need to add
75	  any code to the application.
76	  Thread analysis would be called periodically.
77
78if THREAD_ANALYZER_AUTO
79
80config THREAD_ANALYZER_AUTO_SEPARATE_CORES
81	bool "Run thread analyzer separately on each core"
82	default y if KERNEL_COHERENCE
83	depends on SCHED_CPU_MASK
84	help
85	  Run the thread analyzer auto thread on each core and report
86	  cores separately. This feature is needed for platforms running
87	  on cache-incoherent architectures.
88
89config THREAD_ANALYZER_AUTO_INTERVAL
90	int "Thread analysis interval"
91	default 60
92	range 5 3600
93	help
94	  The time in seconds to call thread analyzer periodic printing function.
95
96config THREAD_ANALYZER_AUTO_STACK_SIZE
97	int "Stack size for the periodic thread analysis thread"
98	default 2048 if THREAD_ANALYZER_USE_LOG && LOG_MODE_IMMEDIATE && NO_OPTIMIZATIONS
99	default 1024
100
101config THREAD_ANALYZER_AUTO_THREAD_PRIORITY_OVERRIDE
102	bool "Override default thread analysis thread priority"
103	help
104	  Option to change the default value of thread analysis thread priority.
105
106if THREAD_ANALYZER_AUTO_THREAD_PRIORITY_OVERRIDE
107config THREAD_ANALYZER_AUTO_THREAD_PRIORITY
108	int "Thread analysis thread priority"
109	default 0
110	help
111	  Set thread priority of the thread analysis
112endif # THREAD_ANALYZER_AUTO_THREAD_PRIORITY_OVERRIDE
113
114endif # THREAD_ANALYZER_AUTO
115
116endif # THREAD_ANALYZER
117