2

I noticed that kernel has different console levels for the printk.

I also noticed this post [1].

I understand that we can change the /proc/sys/kernel/printk to change the printk level for the console; We can even use the dmesg --level to change the display level for dmesg.

However, my question is:

If I have a printk(KERN_DEBUG "debug message") line in the kernel, can I configure the system to advice kernel not to run the printk(KERN_DEBU ...) statement, instead of just not showing the message?

I don't want the kernel to run this printk because printk will cause some performance overhead. Even though we don't see the message print out by dmesg, the kernel may still save it somewhere else, which may slow down the system a little bit (say several ms), which I want to avoid.

Thank you very much for your time and help in this question!

[1] can't filter printk messages

1

It looks to me like KERN_DEBUG and lower will not get compiled in unless you set an appropriate flag in your kconfig. http://lxr.free-electrons.com/source/include/linux/printk.h?v=4.10#L280 I highly doubt the overhead of a function call and checking an if statement is an issue though and that is all the printk(KERN_DEBU ...) will run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.