From: Petr Mladek <pmladek@suse.com>
To: David Howells <dhowells@redhat.com>
Cc: linux-kernel@vger.kernel.org, jack@suse.cz, will.deacon@arm.com,
rostedt@goodmis.org, dwmw2@infradead.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] printk: Don't discard earlier unprinted messages to make space
Date: Thu, 22 Oct 2015 14:30:36 +0200 [thread overview]
Message-ID: <20151022123036.GB2599@pathway.suse.cz> (raw)
In-Reply-To: <20151022101650.25995.95155.stgit@warthog.procyon.org.uk>
Added Andrew into CC who maintains printk() code.
On Thu 2015-10-22 11:16:50, David Howells wrote:
> printk() currently discards earlier messages to make space for new messages
> arriving. This has the distinct downside that if the kernel starts
> churning out messages because of some initial incident, the report of the
> initial incident is likely to be lost under a blizzard of:
>
> ** NNN printk messages dropped **
>
> messages from console_unlock().
>
> The first message generated (typically an oops) is usually the most
> important - the one you want to solve first - so we really want to see
> that.
oops=panic or panic_on_warn kernel parameters might be more useful in
this situation.
I would expect that the first few messages are printed to the console
before the buffer is wrapped. IMHO, in many cases, you are interested
into the final messages that describe why the system went down. If there
is no time to print them, you want to have them in the crash dump
(ring buffer) at least.
> To this end, change log_store() to only write a message into the buffer if
> there is sufficient space to hold that message. The message may be
> truncated if it will then fit.
>
> This patch could be improved by noting that some messages got discarded
> when next there is space to do so.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> ---
[...]
> + if (CIRC_SPACE_TO_END(log_next_idx, log_first_idx, log_buf_len) >= wsize)
> + goto have_space_no_wrap;
> +
> + if (CIRC_SPACE(log_next_idx, log_first_idx, log_buf_len) >= size)
> + goto have_space_wrap;
> +
> + /* Try to truncate the message. */
> + size = truncate_msg(&text_len, &trunc_msg_len, &dict_len, &pad_len);
> + wsize = size + sizeof(struct printk_log);
truncate_msg() currently works only for messages that are
bigger than half of the buffer.
Also if the flood of messages is faster than printing, you might
end up with the buffer full of "<truncated>" strings with a minimum
of useful information.
> + if (CIRC_SPACE_TO_END(log_next_idx, log_first_idx, log_buf_len) >= wsize)
> + goto have_space_no_wrap;
> +
> + if (CIRC_SPACE(log_next_idx, log_first_idx, log_buf_len) < size)
> + return 0;
Please, try to avoid copy&pasted code.
Best Regards,
Petr
next prev parent reply other threads:[~2015-10-22 12:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-22 10:16 [PATCH] printk: Don't discard earlier unprinted messages to make space David Howells
2015-10-22 10:28 ` David Woodhouse
2015-10-22 12:18 ` Jan Kara
2015-10-22 12:36 ` David Woodhouse
2015-10-22 12:30 ` Petr Mladek [this message]
2015-10-22 13:19 ` David Howells
2015-10-22 13:23 ` David Woodhouse
2015-10-23 8:49 ` Petr Mladek
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=20151022123036.GB2599@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=dwmw2@infradead.org \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=will.deacon@arm.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