I am using printk in my kernel loadable module to log parameters of system calls. For each system call, several printks are used to print the variables whey they appear with "\t" as delimiters. To redirect the data in the kernel log buffer to another file other than system /var/log/messages, I use "klogd -f" to bypass the syslog interface. The log data obtained is one line per system call. However, after analyzing the data, I find that there exist 2 problems.
Problem 1: data may be lost.
Problem 2: data of one system call is mixed with data belonging to another system call, perhaps in the middle.
Question 1: is data loss caused by the kernel log buffer overflow which overwrites the oldest log in the buffer? If so, how to overcome it? I plan to increase the size of the kernel log buffer. Do you think it's appropriate and what size is best?
Question 2: can system call preempt another system call? Or in some situations, one system call may invoke another system call and can't finish unless the invoked one finishes? Is this the reason that the data get mixed with each other?
Question 3: is printk atomic? If not, how to make printk atomic? Add a lock to make it un-interruptable?