From: Jan Kara <jack@suse.cz>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: pmladek@suse.com, LKML <linux-kernel@vger.kernel.org>,
Jan Kara <jack@suse.cz>
Subject: [PATCH 2/3] printk: Skip messages on oops
Date: Wed, 2 Mar 2016 16:59:22 +0100 [thread overview]
Message-ID: <1456934363-3199-2-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1456934363-3199-1-git-send-email-jack@suse.cz>
When there are too many messages in the kernel printk buffer it can take
very long to print them to console (especially when using slow serial
console). This is undesirable during oops so when we encounter oops and
there are more than 100 messages to print, print just the newest 100
messages and then the oops message.
Signed-off-by: Jan Kara <jack@suse.cz>
---
kernel/printk/printk.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 73ec760a4bc8..03f5278b47b4 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -267,6 +267,9 @@ static u64 console_seq;
static u32 console_idx;
static enum log_flags console_prev;
+/* current record sequence when oops happened */
+static u64 oops_start_seq;
+
/* the next printk record to read after the last 'clear' command */
static u64 clear_seq;
static u32 clear_idx;
@@ -1785,6 +1788,8 @@ asmlinkage int vprintk_emit(int facility, int level,
NULL, 0, recursion_msg,
strlen(recursion_msg));
}
+ if (oops_in_progress && !printk_sync && !oops_start_seq)
+ oops_start_seq = log_next_seq;
/*
* The printf needs to come first; we need the syslog
@@ -2295,6 +2300,12 @@ out:
raw_spin_unlock_irqrestore(&logbuf_lock, flags);
}
+/*
+ * When oops happens and there are more messages to be printed in the printk
+ * buffer that this, skip some mesages and print only this many newest messages.
+ */
+#define PRINT_MSGS_BEFORE_OOPS 100
+
/**
* console_unlock - unlock the console system
*
@@ -2351,7 +2362,28 @@ again:
seen_seq = log_next_seq;
}
- if (console_seq < log_first_seq) {
+ /*
+ * If oops happened and there are more than
+ * PRINT_MSGS_BEFORE_OOPS messages pending before oops message,
+ * skip them to make oops appear faster.
+ */
+ if (oops_start_seq &&
+ console_seq + PRINT_MSGS_BEFORE_OOPS < oops_start_seq) {
+ len = sprintf(text,
+ "** %u printk messages dropped due to oops ** ",
+ (unsigned)(oops_start_seq - console_seq -
+ PRINT_MSGS_BEFORE_OOPS));
+ if (console_seq < log_first_seq) {
+ console_seq = log_first_seq;
+ console_idx = log_first_idx;
+ }
+ while (console_seq <
+ oops_start_seq - PRINT_MSGS_BEFORE_OOPS) {
+ console_idx = log_next(console_idx);
+ console_seq++;
+ }
+ console_prev = 0;
+ } else if (console_seq < log_first_seq) {
len = sprintf(text, "** %u printk messages dropped ** ",
(unsigned)(log_first_seq - console_seq));
--
2.6.2
next prev parent reply other threads:[~2016-03-02 16:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-02 15:59 [PATCH 1/3] printk: Make printk() completely async Jan Kara
2016-03-02 15:59 ` Jan Kara [this message]
2016-03-02 17:06 ` [PATCH 2/3] printk: Skip messages on oops kbuild test robot
2016-03-02 15:59 ` [PATCH 3/3] printk: debug: Slow down printing to 9600 bauds Jan Kara
2016-03-03 11:26 ` [PATCH 1/3] printk: Make printk() completely async Tetsuo Handa
2016-03-03 12:01 ` Jan Kara
2016-03-04 11:24 ` Sergey Senozhatsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456934363-3199-2-git-send-email-jack@suse.cz \
--to=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=sergey.senozhatsky@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox