lkml.org 
[lkml]   [2020]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH printk 3/5] printk: use buffer pool for sprint buffers
Date
From: Petr Mladek
> Sent: 23 September 2020 16:11
>
> On Tue 2020-09-22 17:44:14, John Ogness wrote:
> > vprintk_store() is using a single static buffer as a temporary
> > sprint buffer for the message text. This will not work once
> > @logbuf_lock is removed. Replace the single static buffer with a
> > pool of buffers.
>
> The buffer is used because we do not know the length of the
> formatted message to reserve the right space in the ring buffer
> in advance.
>
> There was the idea to call vsprintf(NULL, fmt, args) to count
> the length in advance.
>
> AFAIK, there is one catch. We need to use va_copy() around
> the 1st call because va_format can be proceed only once.
> See, va_format() in lib/vsprintf.c as an example.
>
> Is there any other problem, please?

Potentially the data can change after the vsprintf(NULL, ...)
call so that the buffer isn't guaranteed to be the right length.

Never mind the extra cost of doing all the work twice.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

\
 
 \ /
  Last update: 2020-09-23 17:23    [W:0.110 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site