[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151022123036.GB2599@pathway.suse.cz>
Date: Thu, 22 Oct 2015 14:30:36 +0200
From: Petr Mladek <pmladek@...e.com>
To: David Howells <dhowells@...hat.com>
Cc: linux-kernel@...r.kernel.org, jack@...e.cz, will.deacon@....com,
rostedt@...dmis.org, dwmw2@...radead.org,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] printk: Don't discard earlier unprinted messages to make
space
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@...hat.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists