Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
You could try a serial or network console. Those may get the messages out faster than klogd gets them to disk. – derobert Feb 1 '13 at 12:31
up vote 1 down vote accepted

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/

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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