title: how to avoid printk log dropping in linux kernel
body: <p>Is there any tips or method to avoid kernel log drop or log buffer overrun ?</p>
  
  <p>I have increased the log buffer size to maximum with below code change. I'm running in high end device only. But, still when when i want to get the complete log from my driver(which writes heavy logs), I see the printk logs are dropped sometimes. I use printk with KERN_INFO, gets enabled through dynamic debug(dprintk).</p>
  
  <p><strong>Change i do:</strong></p>
  
  <pre><code>--- a/kernel/printk.c
  +++ b/kernel/printk.c
  @@ -55,7 +55,7 @@ void asmlinkage __attribute__((weak)) early_printk(const char *fmt, ...)
   {
   }
  
  -#define __LOG_BUF_LEN  (1 &lt;&lt; CONFIG_LOG_BUF_SHIFT)
  +#define __LOG_BUF_LEN  (1 &lt;&lt; 17)
  </code></pre>
  
  <p><strong>Command i use to write into a file:</strong></p>
  
  <pre><code>cat "/proc/kmsg"&gt;/sdcard/klog.txt
  </code></pre>
  
  <p>Only While debugging, I'm okay if the performance is degraded in my driver but, i don't want  drop any logs. I understand we can't make work queues/threads to wait until printing completes. But, still is there any way to get guaranteed that, logs are not dropped.</p>