问题
I have enabled the CONFIG_DYNAMIC_DEBUG flag in kernel config file, built & installed the kernel. Then, when I reboot, I can see /sys/kernel/debug/dynamic_debug/control.
However, when I tried to dynamically enable a module like so:
sudo echo 'module xhci_hcd +p' > /sys/kernel/debug/dynamic_debug/control
I got:
bash: /sys/kernel/debug/dynamic_debug/control: Permission denied
Notice that I'm using sudo.
回答1:
The redirection (with the > shell operator) is not performed as root. That's why you get a permission denied error. I suggest you run the whole command in a sub shell like:
sudo sh -c "echo 'module xhci_hcd +p' > /sys/kernel/debug/dynamic_debug/control"
回答2:
Just check if you have booted into the correct version of the kernel after enabling CONFIG_DYNAMIC_DEBUG ? Next check if debugfs is mounted.
Try with -n option (do not output the trailing newline)
echo -n 'module xhci_hcd +p' | sudo tee /sys/kernel/debug/dynamic_debug/control
Also try if you are able to debug a specific file for the ko:
echo -n 'file filename.c +p' | sudo tee /sys/kernel/debug/dynamic_debug/control
来源:https://stackoverflow.com/questions/26556246/cannot-enable-kernel-dynamic-debugging-on-linux