Skip to main content
This section describes kernel debugging features that are used to diagnose system and performance issues.

Enable dynamic debug

The debugfs 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:
  1. Enable the CONFIG_DYNAMIC_DEBUG kernel configuration option.
  2. Recompile and reflash the build.
  3. To mount the debugfs file system, run the following commands:
    mount -o rw,remount /
    
    mount -t debugfs none /sys/kernel/debug
    
    1. Verify whether dynamic debug is enabled by checking that the following path exists:
      cd /sys/kernel/debug/dynamic_debug
      
    2. If the directory exists, verify the defined logs:
      cat /sys/kernel/debug/dynamic_debug/control
      
  4. Enable debug logs for the files or functions that require debugging. For example:
    • To enable all debugfs logs in the mdp.c file, run the following command:
      echo 'file mdp.c +p' > /sys/kernel/debug/dynamic_debug/control
      
    • To enable the log at line 2921 in the mdp.c file, run the following command:
      echo 'file mdp.c line 2921 +p' > /sys/kernel/debug/dynamic_debug/control
      
  5. Verify logs using the dmesg command or run the following command:
    cat /proc/kmsg
    
    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, invoke menuconfig. 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.