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

From: Petr Mladek
Date: Tue Jan 03 2023 - 11:13:57 EST


On Tue 2023-01-03 16:06:03, John Ogness wrote:
> On 2023-01-03, Petr Mladek <pmladek@xxxxxxxx> wrote:
> >> 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
>
> The scratch buffer would become PRINTK_RECORD_MAX, but we still need
> SYSLOG_MESSAGE_MAX for the kmalloc's syslog buffers.

I see.

> Unless you think it is OK to kmalloc 8KB instead of 1KB for the
> syslog calls. Then yes, we do not need SYSLOG_MESSAGE_MAX.

IMHO, it is acceptable and even correct. syslog uses the same
prefixes as console. It would make sense to use the same
buffers for formatting.

That said, 8kB looks non-necessary big to me.

It seems that it comes from devkmsg interface, see the commit
d43ff430f434d862db59582 ("printk: guard the amount written
per line by devkmsg_read()"). It was supposed to include
the message, the extended prefix and dictionary, where

+ message is limited by LOG_LINE_MAX
+ prefix includes few well defined fields (should be < 128B)
+ dictionary comes from dev_printk() => ( < 128B as well)

I believe that 2kB or 4kB would be perfectly fine.

Best Regards,
Petr