Telem GW kernel debug: Difference between revisions
No edit summary |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
*** Trace SLAB allocations | *** Trace SLAB allocations | ||
*** Kernel function profiler | *** Kernel function profiler | ||
**Fault-injection framework | ** Linux Kernel Dump Test Tool Module | ||
** Fault-injection framework | |||
*** Fault-injection capability for kmalloc | *** Fault-injection capability for kmalloc | ||
*** Fault-injection capability for allow_pages() | *** Fault-injection capability for allow_pages() | ||
Line 38: | Line 39: | ||
at the end of buildroot/system/skeleton/etc/fstab | at the end of buildroot/system/skeleton/etc/fstab | ||
[[Kasutaja:MarkTomm|MarkTomm]] | = Various Details = | ||
== Kernel Hacking Configuration Options Details == | |||
=== KGDB: kernel debugger === | |||
KGDB: kernel debugger | |||
<pre> | |||
menuconfig KGDB | |||
bool "KGDB: kernel debugger" | |||
depends on HAVE_ARCH_KGDB | |||
depends on DEBUG_KERNEL && EXPERIMENTAL | |||
help | |||
If you say Y here, it will be possible to remotely debug the | |||
kernel using gdb. It is recommended but not required, that | |||
you also turn on the kernel config option | |||
CONFIG_FRAME_POINTER to aid in producing more reliable stack | |||
backtraces in the external debugger. Documentation of | |||
kernel debugger is available at http://kgdb.sourceforge.net | |||
as well as in DocBook form in Documentation/DocBook/. | |||
</pre> | |||
KGDB: use kgdb over the serial console | |||
<pre> | |||
config KGDB_SERIAL_CONSOLE | |||
tristate "KGDB: use kgdb over the serial console" | |||
select CONSOLE_POLL | |||
select MAGIC_SYSRQ | |||
default y | |||
help | |||
Share a serial console with kgdb. Sysrq-g must be used | |||
to break in initially. | |||
</pre> | |||
KGDB_KDB: include kdb frontend for kgdb | |||
<pre> | |||
config KGDB_KDB | |||
bool "KGDB_KDB: include kdb frontend for kgdb" | |||
default n | |||
help | |||
KDB frontend for kernel | |||
</pre> | |||
=== Kernel memory leak detector === | |||
Kernel memory leak detector | |||
<pre> | |||
config DEBUG_KMEMLEAK | |||
bool "Kernel memory leak detector" | |||
depends on DEBUG_KERNEL && EXPERIMENTAL && !MEMORY_HOTPLUG && \ | |||
(X86 || ARM || PPC || S390 || SPARC64 || SUPERH || MICROBLAZE) | |||
select DEBUG_FS if SYSFS | |||
select STACKTRACE if STACKTRACE_SUPPORT | |||
select KALLSYMS | |||
select CRC32 | |||
help | |||
Say Y here if you want to enable the memory leak | |||
detector. The memory allocation/freeing is traced in a way | |||
similar to the Boehm's conservative garbage collector, the | |||
difference being that the orphan objects are not freed but | |||
only shown in /sys/kernel/debug/kmemleak. Enabling this | |||
feature will introduce an overhead to memory | |||
allocations. See Documentation/kmemleak.txt for more | |||
details. | |||
Enabling DEBUG_SLAB or SLUB_DEBUG may increase the chances | |||
of finding leaks due to the slab objects poisoning. | |||
In order to access the kmemleak file, debugfs needs to be | |||
mounted (usually at /sys/kernel/debug). | |||
</pre> | |||
40000) Maximum kmemleak early log entries | |||
=== Tracers === | |||
Kernel Function Tracer | |||
<pre> | |||
config FUNCTION_TRACER | |||
bool "Kernel Function Tracer" | |||
depends on HAVE_FUNCTION_TRACER | |||
select FRAME_POINTER | |||
select KALLSYMS | |||
select GENERIC_TRACER | |||
select CONTEXT_SWITCH_TRACER | |||
help | |||
Enable the kernel to trace every kernel function. This is done | |||
by using a compiler feature to insert a small, 5-byte No-Operation | |||
instruction at the beginning of every kernel function, which NOP | |||
sequence is then dynamically patched into a tracer call when | |||
tracing is enabled by the administrator. If it's runtime disabled | |||
(the bootup default), then the overhead of the instructions is very | |||
small and not measurable even in micro-benchmarks. | |||
</pre> | |||
Trace max Stack | |||
<pre> | |||
config STACK_TRACER | |||
bool "Trace max stack" | |||
depends on HAVE_FUNCTION_TRACER | |||
select FUNCTION_TRACER | |||
select STACKTRACE | |||
select KALLSYMS | |||
help | |||
This special tracer records the maximum stack footprint of the | |||
kernel and displays it in /sys/kernel/debug/tracing/stack_trace. | |||
This tracer works by hooking into every function call that the | |||
kernel executes, and keeping a maximum stack depth value and | |||
stack-trace saved. If this is configured with DYNAMIC_FTRACE | |||
then it will not have any overhead while the stack tracer | |||
is disabled. | |||
To enable the stack tracer on bootup, pass in 'stacktrace' | |||
on the kernel command line. | |||
The stack tracer can also be enabled or disabled via the | |||
sysctl kernel.stack_tracer_enabled | |||
</pre> | |||
Trace SLAB allocations | |||
<pre> | |||
config KMEMTRACE | |||
bool "Trace SLAB allocations" | |||
select GENERIC_TRACER | |||
help | |||
kmemtrace provides tracing for slab allocator functions, such as | |||
kmalloc, kfree, kmem_cache_alloc, kmem_cache_free, etc. Collected | |||
data is then fed to the userspace application in order to analyse | |||
allocation hotspots, internal fragmentation and so on, making it | |||
possible to see how well an allocator performs, as well as debug | |||
and profile kernel code. | |||
This requires an userspace application to use. See | |||
Documentation/trace/kmemtrace.txt for more information. | |||
Saying Y will make the kernel somewhat larger and slower. However, | |||
if you disable kmemtrace at run-time or boot-time, the performance | |||
impact is minimal (depending on the arch the kernel is built for). | |||
</pre> | |||
Kernel function profiler | |||
<pre> | |||
config FUNCTION_PROFILER | |||
bool "Kernel function profiler" | |||
depends on FUNCTION_TRACER | |||
default n | |||
help | |||
This option enables the kernel function profiler. A file is created | |||
in debugfs called function_profile_enabled which defaults to zero. | |||
When a 1 is echoed into this file profiling begins, and when a | |||
zero is entered, profiling stops. A "functions" file is created in | |||
the trace_stats directory; this file shows the list of functions that | |||
have been hit and their counters. | |||
</pre> | |||
=== Linux Kernel Dump Test Tool Module === | |||
Linux Kernel Dump Test Tool Module | |||
<pre> | |||
config LKDTM | |||
tristate "Linux Kernel Dump Test Tool Module" | |||
depends on DEBUG_FS | |||
depends on BLOCK | |||
default n | |||
help | |||
This module enables testing of the different dumping mechanisms by | |||
inducing system failures at predefined crash points. | |||
If you don't need it: say N | |||
Choose M here to compile this code as a module. The module will be | |||
called lkdtm. | |||
Documentation on how to use the module can be found in | |||
Documentation/fault-injection/provoke-crashes.txt | |||
</pre> | |||
=== Fault-injection framework === | |||
Fault-injection framework | |||
<pre> | |||
config FAULT_INJECTION | |||
bool "Fault-injection framework" | |||
depends on DEBUG_KERNEL | |||
help | |||
Provide fault-injection framework. | |||
For more details, see Documentation/fault-injection/. | |||
</pre> | |||
Fault-injection capability for kmalloc | |||
<pre> | |||
config FAILSLAB | |||
bool "Fault-injection capability for kmalloc" | |||
depends on FAULT_INJECTION | |||
depends on SLAB || SLUB | |||
help | |||
Provide fault-injection capability for kmalloc. | |||
</pre> | |||
Fault-injection capability for allow_pages() | |||
<pre> | |||
config FAIL_PAGE_ALLOC | |||
bool "Fault-injection capabilitiy for alloc_pages()" | |||
depends on FAULT_INJECTION | |||
help | |||
Provide fault-injection capability for alloc_pages(). | |||
</pre> | |||
Fault-injection capability for disk IO | |||
<pre> | |||
config FAIL_MAKE_REQUEST | |||
bool "Fault-injection capability for disk IO" | |||
depends on FAULT_INJECTION && BLOCK | |||
help | |||
Provide fault-injection capability for disk IO. | |||
</pre> | |||
Fault-injection capability for faking disk interrupts | |||
<pre> | |||
config FAIL_IO_TIMEOUT | |||
bool "Faul-injection capability for faking disk interrupts" | |||
depends on FAULT_INJECTION && BLOCK | |||
help | |||
Provide fault-injection capability on end IO handling. This | |||
will make the block layer "forget" an interrupt as configured, | |||
thus exercising the error handling. | |||
Only works with drivers that use the generic timeout handling, | |||
for others it wont do anything. | |||
</pre> | |||
Debugfs entries for fault-injection capabilities | |||
<pre> | |||
config FAULT_INJECTION_DEBUG_FS | |||
bool "Debugfs entries for fault-injection capabilities" | |||
depends on FAULT_INJECTION && SYSFS && DEBUG_FS | |||
help | |||
Enable configuration of fault-injection capabilities via debugfs. | |||
</pre> | |||
stacktrace filter for fault-injection capabilities | |||
<pre> | |||
config FAULT_INJECTION_STACKTRACE_FILTER | |||
bool "stacktrace filter for fault-injection capabilities" | |||
depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT | |||
depends on !X86_64 | |||
select STACKTRACE | |||
select FRAME_POINTER if !PPC && !S390 | |||
help | |||
Provide stacktrace filter for fault-injection capabilities | |||
</pre> | |||
=== Enable stack utilization instrumentation === | |||
Enable stack utilization instrumentation | |||
<pre> | |||
config DEBUG_STACK_USAGE | |||
bool "Enable stack utilization instrumentation" | |||
depends on DEBUG_KERNEL | |||
help | |||
Enables the display of the minimum amount of free stack which each | |||
task has ever had available in the sysrq-T output. | |||
</pre> | |||
= Known Issues = | |||
Unable to assign a serial port to KGDB | |||
[[Kasutaja:MarkTomm|MarkTomm]] 5. märts 2015, kell 12:07 (EET) |
Latest revision as of 10:07, 5 March 2015
Kernel Conf
Additions
- Kernel Hacking
- KGDB: kernel debugger
- KGDB: use kgdb over the serial console
- KGDB_KDB: include kdb frontend for kgdb
- Kernel memory leak detector
- (40000) Maximum kmemleak early log entries
- Tracers
- Kernel Function Tracer
- Trace max Stack
- Trace SLAB allocations
- Kernel function profiler
- Linux Kernel Dump Test Tool Module
- Fault-injection framework
- Fault-injection capability for kmalloc
- Fault-injection capability for allow_pages()
- Fault-injection capability for disk IO
- Fault-injection capability for faking disk interrupts
- Debugfs entries for fault-injection capabilities
- stacktrace filter for fault-injection capabilities
- Enable stack utilization instrumentation
- KGDB: kernel debugger
Other
Add kernel boot argument
console=ttymxc0
Add
nodev /sys/kernel/debug debugfs defaults 0 0
at the end of buildroot/system/skeleton/etc/fstab
Various Details
Kernel Hacking Configuration Options Details
KGDB: kernel debugger
KGDB: kernel debugger
menuconfig KGDB bool "KGDB: kernel debugger" depends on HAVE_ARCH_KGDB depends on DEBUG_KERNEL && EXPERIMENTAL help If you say Y here, it will be possible to remotely debug the kernel using gdb. It is recommended but not required, that you also turn on the kernel config option CONFIG_FRAME_POINTER to aid in producing more reliable stack backtraces in the external debugger. Documentation of kernel debugger is available at http://kgdb.sourceforge.net as well as in DocBook form in Documentation/DocBook/.
KGDB: use kgdb over the serial console
config KGDB_SERIAL_CONSOLE tristate "KGDB: use kgdb over the serial console" select CONSOLE_POLL select MAGIC_SYSRQ default y help Share a serial console with kgdb. Sysrq-g must be used to break in initially.
KGDB_KDB: include kdb frontend for kgdb
config KGDB_KDB bool "KGDB_KDB: include kdb frontend for kgdb" default n help KDB frontend for kernel
Kernel memory leak detector
Kernel memory leak detector
config DEBUG_KMEMLEAK bool "Kernel memory leak detector" depends on DEBUG_KERNEL && EXPERIMENTAL && !MEMORY_HOTPLUG && \ (X86 || ARM || PPC || S390 || SPARC64 || SUPERH || MICROBLAZE) select DEBUG_FS if SYSFS select STACKTRACE if STACKTRACE_SUPPORT select KALLSYMS select CRC32 help Say Y here if you want to enable the memory leak detector. The memory allocation/freeing is traced in a way similar to the Boehm's conservative garbage collector, the difference being that the orphan objects are not freed but only shown in /sys/kernel/debug/kmemleak. Enabling this feature will introduce an overhead to memory allocations. See Documentation/kmemleak.txt for more details. Enabling DEBUG_SLAB or SLUB_DEBUG may increase the chances of finding leaks due to the slab objects poisoning. In order to access the kmemleak file, debugfs needs to be mounted (usually at /sys/kernel/debug).
40000) Maximum kmemleak early log entries
Tracers
Kernel Function Tracer
config FUNCTION_TRACER bool "Kernel Function Tracer" depends on HAVE_FUNCTION_TRACER select FRAME_POINTER select KALLSYMS select GENERIC_TRACER select CONTEXT_SWITCH_TRACER help Enable the kernel to trace every kernel function. This is done by using a compiler feature to insert a small, 5-byte No-Operation instruction at the beginning of every kernel function, which NOP sequence is then dynamically patched into a tracer call when tracing is enabled by the administrator. If it's runtime disabled (the bootup default), then the overhead of the instructions is very small and not measurable even in micro-benchmarks.
Trace max Stack
config STACK_TRACER bool "Trace max stack" depends on HAVE_FUNCTION_TRACER select FUNCTION_TRACER select STACKTRACE select KALLSYMS help This special tracer records the maximum stack footprint of the kernel and displays it in /sys/kernel/debug/tracing/stack_trace. This tracer works by hooking into every function call that the kernel executes, and keeping a maximum stack depth value and stack-trace saved. If this is configured with DYNAMIC_FTRACE then it will not have any overhead while the stack tracer is disabled. To enable the stack tracer on bootup, pass in 'stacktrace' on the kernel command line. The stack tracer can also be enabled or disabled via the sysctl kernel.stack_tracer_enabled
Trace SLAB allocations
config KMEMTRACE bool "Trace SLAB allocations" select GENERIC_TRACER help kmemtrace provides tracing for slab allocator functions, such as kmalloc, kfree, kmem_cache_alloc, kmem_cache_free, etc. Collected data is then fed to the userspace application in order to analyse allocation hotspots, internal fragmentation and so on, making it possible to see how well an allocator performs, as well as debug and profile kernel code. This requires an userspace application to use. See Documentation/trace/kmemtrace.txt for more information. Saying Y will make the kernel somewhat larger and slower. However, if you disable kmemtrace at run-time or boot-time, the performance impact is minimal (depending on the arch the kernel is built for).
Kernel function profiler
config FUNCTION_PROFILER bool "Kernel function profiler" depends on FUNCTION_TRACER default n help This option enables the kernel function profiler. A file is created in debugfs called function_profile_enabled which defaults to zero. When a 1 is echoed into this file profiling begins, and when a zero is entered, profiling stops. A "functions" file is created in the trace_stats directory; this file shows the list of functions that have been hit and their counters.
Linux Kernel Dump Test Tool Module
Linux Kernel Dump Test Tool Module
config LKDTM tristate "Linux Kernel Dump Test Tool Module" depends on DEBUG_FS depends on BLOCK default n help This module enables testing of the different dumping mechanisms by inducing system failures at predefined crash points. If you don't need it: say N Choose M here to compile this code as a module. The module will be called lkdtm. Documentation on how to use the module can be found in Documentation/fault-injection/provoke-crashes.txt
Fault-injection framework
Fault-injection framework
config FAULT_INJECTION bool "Fault-injection framework" depends on DEBUG_KERNEL help Provide fault-injection framework. For more details, see Documentation/fault-injection/.
Fault-injection capability for kmalloc
config FAILSLAB bool "Fault-injection capability for kmalloc" depends on FAULT_INJECTION depends on SLAB || SLUB help Provide fault-injection capability for kmalloc.
Fault-injection capability for allow_pages()
config FAIL_PAGE_ALLOC bool "Fault-injection capabilitiy for alloc_pages()" depends on FAULT_INJECTION help Provide fault-injection capability for alloc_pages().
Fault-injection capability for disk IO
config FAIL_MAKE_REQUEST bool "Fault-injection capability for disk IO" depends on FAULT_INJECTION && BLOCK help Provide fault-injection capability for disk IO.
Fault-injection capability for faking disk interrupts
config FAIL_IO_TIMEOUT bool "Faul-injection capability for faking disk interrupts" depends on FAULT_INJECTION && BLOCK help Provide fault-injection capability on end IO handling. This will make the block layer "forget" an interrupt as configured, thus exercising the error handling. Only works with drivers that use the generic timeout handling, for others it wont do anything.
Debugfs entries for fault-injection capabilities
config FAULT_INJECTION_DEBUG_FS bool "Debugfs entries for fault-injection capabilities" depends on FAULT_INJECTION && SYSFS && DEBUG_FS help Enable configuration of fault-injection capabilities via debugfs.
stacktrace filter for fault-injection capabilities
config FAULT_INJECTION_STACKTRACE_FILTER bool "stacktrace filter for fault-injection capabilities" depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT depends on !X86_64 select STACKTRACE select FRAME_POINTER if !PPC && !S390 help Provide stacktrace filter for fault-injection capabilities
Enable stack utilization instrumentation
Enable stack utilization instrumentation
config DEBUG_STACK_USAGE bool "Enable stack utilization instrumentation" depends on DEBUG_KERNEL help Enables the display of the minimum amount of free stack which each task has ever had available in the sysrq-T output.
Known Issues
Unable to assign a serial port to KGDB
MarkTomm 5. märts 2015, kell 12:07 (EET)