Jump to contentJump to page navigation: previous page [access key p]/next page [access key n]
documentation.suse.com / Documentation de SUSE Linux Enterprise Server / System Analysis and Tuning Guide / Kernel monitoring / Dynamic debug—kernel debugging messages
Applies to SUSE Linux Enterprise Server 15 SP4

8 Dynamic debug—kernel debugging messages

Dynamic debug is a powerful debugging feature in the Linux kernel that allows you to enable and disable debugging messages at runtime without the need to recompile the kernel or reboot the system.

You can use dynamic debugging in several situations, such as:

  • Troubleshooting kernel issues

  • Developing drivers for new hardware

  • Tracing and auditing security events

8.1 Benefits of dynamic debugging

Certain benefits of dynamic debugging are listed below:

Real-time debugging

Dynamic debugging enables debugging messages without requiring a system reboot. This real-time capability is crucial for diagnosing issues in production environments.

Selective debugging

You can enable debugging messages for specific parts of the kernel or even individual modules, allowing you to focus on relevant information.

Performance tuning

Use dynamic debugging to monitor and optimize kernel performance by selectively enabling or disabling debugging messages based on the current analysis requirements.

8.2 Checking the status of dynamic debug

For supported kernel versions that are installed by default, dynamic debug is already built-in. To check the status of dynamic debug, run the following command as the root user:

# zcat /proc/config.gz | grep CONFIG_DYNAMIC_DEBUG

If dynamic debug is compiled into the kernel, you should see an output similar to the following:

CONFIG_DYNAMIC_DEBUG=y
CONFIG_DYNAMIC_DEBUG_CORE=y

8.3 Using dynamic debug

To enable specific debug messages or logs within the running kernel, you can use the echo command and write to the /sys/kernel/debug/dynamic_debug/control file.

The following examples illustrate certain simple uses of dynamic debug:

Note
Note

Dynamic debug relies on specific debugging macros, such as pr_debug, embedded in the kernel code. These macros are used by kernel developers to insert debugging messages into the code.

The examples in this section assume that the pr_debug macro works correctly because dynamic debug is allowed for the running kernel.

Enabling debug messages for a specific kernel source code file

To enable the debug messages for a specific kernel source code file, use the following example:

# echo "file FILE_NAME.c +p" > /sys/kernel/debug/dynamic_debug/control
Enabling debug messages for a specific kernel module

To enable debug messages for a specific kernel module, use the following example:

# echo "module MODULE_NAME +p" > /sys/kernel/debug/dynamic_debug/control
Disabling debug messages

To disable previously enabled debugging messages for a specific kernel source code file or a kernel module, run the echo command with the -p option. For example:

# echo "file FILE_NAME.c -p" > /sys/kernel/debug/dynamic_debug/control
# echo "module MODULE_NAME -p" > /sys/kernel/debug/dynamic_debug/control

For detailed information about dynamic debug and its use cases, refer to its official documentation.

8.4 Viewing the dynamic debug messages

You can view the dynamic debug messages that were generated based on the configurations you enabled, by running dmesg and filtering the output with grep. For example:

# dmesg | grep -i "FILE_NAME.c"

Optionally, to continuously monitor the system messages as they are generated, you can use the tail command with the -f option:

# tail -f /var/log/messages