Enable dynamic debug
Thedebugfs file system allows you to debug the kernel by enabling logs at runtime. When verifying a particular scenario, use the debugfs file system to enable logs for the specific time.
By default, dynamic debug is disabled. To enable debugfs in the kernel, do the following:
- Enable the
CONFIG_DYNAMIC_DEBUGkernel configuration option. - Recompile and reflash the build.
- To mount the
debugfsfile system, run the following commands:- Verify whether dynamic debug is enabled by checking that the following path exists:
- If the directory exists, verify the defined logs:
- Verify whether dynamic debug is enabled by checking that the following path exists:
- Enable debug logs for the files or functions that require debugging.
For example:
- To enable all
debugfslogs in themdp.cfile, run the following command: - To enable the log at line 2921 in the
mdp.cfile, run the following command:
- To enable all
- Verify logs using the
dmesgcommand or run the following command:For more information, see Documentation/dynamic-debug-howto.txt.
Enable kernel debugging options
You can enable kernel configuration options to debug various issues such as memory leak, lock-related, and mutex problems. To see the available kernel debugging options, invokemenuconfig. For more information about kernel debugging options, see Configure the kernel
The following are some debugging options:
Kernel hacking
[*] Kernel debugging
[*] Detect Soft Lockups
[ ] Collect scheduler statistics
[*] Debug slab memory allocations
[*] Memory leak debugging
[*] Mutex debugging, deadlock detection
[*] Spinlock debugging
[*] Sleep-inside-spinlock checking
[ ] kobject debugging
[ ] Highmem debugging
[ ] Compile the kernel with debug info
If you enable any of these debugging options, the kernel slows down marginally. Therefore, if you notice any decrease in performance, disable the kernel debug configuration options.

