# Enable kernel debugging

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 /
        Copy to clipboard

mount -t debugfs none /sys/kernel/debug
        Copy to clipboard

    1. Verify whether dynamic debug is enabled by checking that the following path exists:

cd /sys/kernel/debug/dynamic_debug
            Copy to clipboard
    2. If the directory exists, verify the defined logs:

cat /sys/kernel/debug/dynamic_debug/control
            Copy to clipboard
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
            Copy to clipboard
    - 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
            Copy to clipboard
5. Verify logs using the `dmesg` command or run the following command:

cat /proc/kmsg
        Copy to clipboard

    For more information, see [Documentation/dynamic-debug-howto.txt](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/dynamic-debug-howto.rst).

## 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](https://docs.qualcomm.com/bundle/publicresource/topics/80-80022-3/kernel-development.html#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

Note

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.

Last Published: May 14, 2026

[Previous Topic
Debug Linux kernel-space issues](https://docs.qualcomm.com/bundle/publicresource/80-80022-12/topics/debugging_linux_kernel.md) [Next Topic
Configure the kernel for debugging](https://docs.qualcomm.com/bundle/publicresource/80-80022-12/topics/configure_the_kernel_for_debugging.md)