linuxlinux-kernellinux-device-driverprintk

Limitations on printing to kernel logs


I'm working on a linux device driver (kernel version 2.6.32-37). I debug my code mostly by printing to the kernel logs (using printk). everything goes well, until my computer suddenly stop responding. I've checked it over and over again and my code seems to be correct. my question is:

is it possible that too many printings to the kernel log might cause the computer to stop responding?

Thanks a lot!

Omer


Solution

  • I doubt the problem is caused by printk, certainly using printk in itself slows down the whole code but it won't crash your system.

    Here's a quote from Ubuntu Kernel Debugging Tricks: The internal kernel console message buffer can sometimes be too small to capture all of the printk messages, especially when debug code generates a lot of printk messages. If the buffer fills up, it wraps around and one can lose valueable debug messages.

    As you can read, when printing too much data, you'll simply start writing over some old data that you wanted to see in the log-file; that's a problem because some debugging messages will disappear but not troubling enough to crash the whole thing.

    I suggest you double check your code again, try to trace when/where it's crashing and if you can't fix the problem post a question here or in some kernel hacking mailing list.

    P.S Also gotta mention, you need to be careful where you're putting your printk statements as some code areas might not tolerate the delay caused by it and THIS might cause further problems leading to a freeze/crash.