Re: [PATCH printk v3 6/6] printk: introduce console_prepend_dropped() for dropped messages

From: Petr Mladek
Date: Tue Jan 03 2023 - 09:17:12 EST


On Tue 2023-01-03 14:50:23, John Ogness wrote:
> On 2023-01-03, Petr Mladek <pmladek@xxxxxxxx> wrote:
> > Well, what about making sure that something more useful is always
> > printed. For example:
> >
> > /*
> > * Make sure outbuf is sufficiently large before prepending.
> > * Keep at least the prefix when the message has to be truncated.
> > * It is a rather theoretical problem when someone tries to
> > * use a minimalist buffer.
> > */
> > if (WARN_ON_ONCE(len + PREFIX_MAX + 1 >= outbuf_sz))
> > return;
>
> I am fine with this. We won't see this warning anyway. Few lines would
> ever be printed correctly if anyone ever tries to use a buffer so small.

Yup.

> > If we want to use this way. It would probably make sense to
> > rename PREFIX_MAX to CONSOLE_PREFIX_MAX.
>
> Actually, I would like to rename all of those limit macros to something
> that makes more sense for the new code base:
>
> CONSOLE_EXT_LOG_MAX -> CONSOLE_MESSAGE_MAX
>
> CONSOLE_LOG_MAX -> SYSLOG_MESSAGE_MAX

Heh, we actually do not need this. The size of @scratchbuf
might be LOG_LINE_MAX/PRINTK_RECORD_MAX. The scratch buffer
is newly used only to read the plain message. The prefixes
are added to @outbuf.

> LOG_LINE_MAX -> PRINTK_RECORD_MAX
>
> PREFIX_MAX -> CONSOLE_PREFIX_MAX

I like this.

> I have a patch to do this ready, but I did not want to post it until we
> are finished with the thread/atomic work.

It would make sense to do this as part of this patchset. But I do not
want to delay it too much. Feel free to do it later.

Best Regards,
Petr