You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

内核无动态调试信息输出问题:模块dynamic debug配置疑问

Troubleshooting Dynamic Debug Messages for Kernel Modules

Let's break down why your command isn't working and fix it step by step:

1. The Critical Flaw in Your Command

Your current command uses > (overwrite) inside the xargs loop, which means only the last module's debug rule gets applied. Each iteration of echo 'module {} +p' > /sys/kernel/debug/dynamic_debug/control overwrites the previous rule, so all earlier modules' debug settings are discarded entirely.

Fixed Command to Enable All Modules' Dynamic Debug

Instead, generate all rules first and write them to the control interface in one go. Here's a more reliable version:

# Extract unique module names, generate rules, and apply all at once
awk -F'[][]' '{print "module " $2 " +p"}' /sys/kernel/debug/dynamic_debug/control | sort -u > /sys/kernel/debug/dynamic_debug/control
  • awk -F'[][]' splits each line by [ and ] to grab the module name directly (cleaner than nested cuts)
  • sort -u removes duplicate module entries (since one module can have multiple debug lines)
  • Writing all rules in a single operation ensures every module's debug flag is set properly

2. Verify Debug Configuration is Applied

Check if the +p flag is present for your target module in the control file:

grep "your_module_name" /sys/kernel/debug/dynamic_debug/control

You should see lines ending with +p (the p indicates print is enabled for those debug statements).

3. Ensure Your Module Uses Dynamic Debug Macros

Dynamic debug only works with specific macros, not regular printk(). Make sure your module uses:

  • pr_debug() for general debug messages
  • dev_dbg() for device-specific debug messages
  • netdev_dbg() for network device debug messages

If you're using printk(KERN_DEBUG ...), those messages will log regardless of dynamic debug settings (they just depend on the kernel log level).

4. Adjust Kernel Log Level

Dynamic debug messages are logged at the DEBUG level (kernel log level 7). If your system is filtering out low-priority logs, you won't see them.

  • Temporarily set the log level to show all messages:
    dmesg -n 8
    
  • Monitor logs in real-time to catch the debug output as it happens:
    dmesg -w
    # Or use journalctl on systemd-based systems
    journalctl -k -f
    

5. Confirm Module and Kernel Configuration

  • Ensure your kernel was compiled with CONFIG_DYNAMIC_DEBUG=y (verify with zcat /proc/config.gz | grep CONFIG_DYNAMIC_DEBUG)
  • Check that your module was built with debug support: it should have been compiled with -DDEBUG (review your module's Makefile or build flags)
  • Confirm the module is actually loaded: lsmod | grep <your_module_name>

6. Test with a Single Module First

To isolate the issue, try enabling debug for just one module manually:

echo 'module my_target_module +p' > /sys/kernel/debug/dynamic_debug/control

Then trigger the module's code path and check logs. If this works, the problem was with your batch command; if not, focus on verifying the module's debug macro usage or kernel configuration.


内容的提问来源于stack exchange,提问作者Masoud

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:51:32