Re: [PATCH v2 1/4] printk/NMI: Handle continuous lines and missing newline

From: Sergey Senozhatsky
Date: Thu Nov 10 2016 - 19:26:39 EST


On (11/09/16 13:41), Petr Mladek wrote:
> The commit 4bcc595ccd80decb4245 ("printk: reinstate KERN_CONT for printing
> continuation lines") added back KERN_CONT message header. As a result
> it might appear in the middle of the line when the parts are squashed
> via the temporary NMI buffer.
>
> A reasonable solution seems to be to split the text in the NNI temporary
> not only by newlines but also by the message headers.
>
> Another solution would be to filter out KERN_CONT when writing to
> the temporary buffer. But this would complicate the lockless handling.
> Also it would not solve problems with a missing newline that was there
> even before the KERN_CONT stuff.
>
> This patch moves the temporary buffer handling into separate function.
> I played with it and it seems that using the char pointers make the
> code easier to read.
>
> Also it prints the final newline as a continuous line.
>
> Finally, it moves handling of the s->len overflow into the paranoid check.
> And allows to recover from the disaster.
>
> Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>

Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx>



without the patch I see prefixes (^Ac) in WARN_ON() output from NMI:

[ 0.895911] ------------[ cut here ]------------
[ 0.895966] WARNING: CPU: 0 PID: 1 at kernel/[..]
[ 0.896026] Modules linked in:^Ac
^^^^
[..]
[ 0.896705] RSP: 0000:ffffc900000176c0 EFLAGS: 00000296^Ac
^^^^^

-ss