aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2014-06-04 19:11:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 19:54:17 -0400
commit84b5ec8a9df86f3dcaaaf912715db35e4852d1da (patch)
tree1843d72b20376e3ea2c8c44bd1ab242c4a386b19
parent6e099f557d9c6797c3ee3ee7b5c8cebe543ec1cc (diff)
printk: report dropping of messages from logbuf
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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/printk/printk.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 35d9db251903..923c5d4e4202 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2157,10 +2157,15 @@ again:
2157 } 2157 }
2158 2158
2159 if (console_seq < log_first_seq) { 2159 if (console_seq < log_first_seq) {
2160 len = sprintf(text, "** %u printk messages dropped ** ",
2161 (unsigned)(log_first_seq - console_seq));
2162
2160 /* messages are gone, move to first one */ 2163 /* messages are gone, move to first one */
2161 console_seq = log_first_seq; 2164 console_seq = log_first_seq;
2162 console_idx = log_first_idx; 2165 console_idx = log_first_idx;
2163 console_prev = 0; 2166 console_prev = 0;
2167 } else {
2168 len = 0;
2164 } 2169 }
2165skip: 2170skip:
2166 if (console_seq == log_next_seq) 2171 if (console_seq == log_next_seq)
@@ -2185,8 +2190,8 @@ skip:
2185 } 2190 }
2186 2191
2187 level = msg->level; 2192 level = msg->level;
2188 len = msg_print_text(msg, console_prev, false, 2193 len += msg_print_text(msg, console_prev, false,
2189 text, sizeof(text)); 2194 text + len, sizeof(text) - len);
2190 console_idx = log_next(console_idx); 2195 console_idx = log_next(console_idx);
2191 console_seq++; 2196 console_seq++;
2192 console_prev = msg->flags; 2197 console_prev = msg->flags;