Re: [PATCH v6 1/3] printk: Add line-buffered printk() API.

From: Sergey Senozhatsky
Date: Wed Nov 07 2018 - 21:30:15 EST


On (11/07/18 19:52), Tetsuo Handa wrote:
> > A question.
> >
> > How bad would it actually be to:
> >
> > - Allocate seq_buf 512-bytes buffer (GFP_ATOMIC) just-in-time, when we
> > need it.
> > // How often systems cannot allocate a 512-byte buffer? //
>
> It is a very bad thing to do GFP_ATOMIC without __GFP_NOWARN.

Absolutely, __GFP_NOWARN.

> "it does not sleep". Not suitable for printk() which might be called from
> critically dangerous situations.

So I'm really not convinced that we can use buffered printk in critically
dangerous situations. Premature 'cont' flushes and 'cont' flushes on panic
are nice and right in critically dangerous situations.

[..]
> > - Do not allocate seq_buf if we are in printk-safe or in printk-nmi mode.
> > To avoid "buffering for the sake of buffering". IOW, when in printk-safe
> > use printk-safe.
>
> Why? Since printk_safe_flush_buffer() forcibly flushes the partial line

We need to leave printk_safe and enable local IRQs for that partial
flush to occur. I'm not sure that those "partial flushes" from printk_safe
actually happen.

-ss