]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
printk: report dropping of messages from logbuf
authorWill Deacon <will.deacon@arm.com>
Thu, 22 May 2014 00:43:37 +0000 (10:43 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 22 May 2014 00:43:37 +0000 (10:43 +1000)
If the log ring buffer becomes full, we silently overwrite old messages
with new data.  console_unlock will detect this case and fast-forward the
console_* pointers to skip over the corrupted data, but nothing will be
reported to the user.

This patch hijacks the first valid log message after detecting that we
dropped messages and prefixes it with a note detailing how many messages
were dropped.  For long (~1000 char) messages, this will result in some
truncation of the real message, but given that we're dropping things
anyway, that doesn't seem to be the end of the world.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Kay Sievers <kay@vrfy.org>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/printk/printk.c

index f01d01f7b0a9ae8ad6c232e5cf5e36b23c0b0c6a..b030cb2843b6bd69148a6cd6ee72d9bbc83b8f5f 100644 (file)
@@ -2157,10 +2157,15 @@ again:
                }
 
                if (console_seq < log_first_seq) {
+                       len = sprintf(text, "** %u printk messages dropped ** ",
+                                     (unsigned)(log_first_seq - console_seq));
+
                        /* messages are gone, move to first one */
                        console_seq = log_first_seq;
                        console_idx = log_first_idx;
                        console_prev = 0;
+               } else {
+                       len = 0;
                }
 skip:
                if (console_seq == log_next_seq)
@@ -2185,8 +2190,8 @@ skip:
                }
 
                level = msg->level;
-               len = msg_print_text(msg, console_prev, false,
-                                    text, sizeof(text));
+               len += msg_print_text(msg, console_prev, false,
+                                     text + len, sizeof(text) - len);
                console_idx = log_next(console_idx);
                console_seq++;
                console_prev = msg->flags;