I'm trying to debug a linux driver and a particular piece of code is behaving very strangely. In order to see what's going on I've filled the code with printk statements so I can see exactly what the variables I'm interested in do as the code executes. Unfortunately, when printing the ring buffer with dmesg lots of lines appear to be randomly missing. Google tells me this is because I'm writing too much data to the ring buffer at once. I've tried increasing the ring buffer size to its maximum (1 << 21) and I've tried inserting udelays to slow the writing down but I'm still having the same problem.

What else can I try?

  • You could try a serial or network console. Those may get the messages out faster than klogd gets them to disk.
    – derobert
    Feb 1, 2013 at 12:31

1 Answer 1


As far as I can tell, klogd uses a blocking read() to read from /proc/kmsg. It might help if you boost its priority via renice. You could also try writing the kernel logs to a ramfs/tmpfs to save some disk overhead, either via syslog, or with klogd's -f option to write directly to a file.

Otherwise, plan B is ftrace and trace_printk(): http://lwn.net/Articles/365835/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .