[PATCH 0/4] printk: reimplement LOG_CONT handling
Linus Torvalds
torvalds at linux-foundation.org
Fri Jul 17 20:00:00 EDT 2020
On Fri, Jul 17, 2020 at 4:48 PM John Ogness <john.ogness at linutronix.de> wrote:
>
> Using placeholders avoids tools such as systemd-journald from
> erroneously reporting missed messages. However, it also means that
> empty placeholder records are visible in systemd-journald logs and
> displayed in tools such as dmesg.
As long as the readers still reliably do the joining, this is fine.
HOWEVER.
Make sure you test the case of "fast concurrent readers". The last
time we did things like this, it was a disaster, because a concurrent
reader would see and return the _incomplete_ line, and the next entry
was still being generated on another CPU.
The reader would then decide to return that incomplete line, because
it had something.
And while in theory this could then be handled properly in user space,
in practice it wasn't. So you'd see a lot of logging tools that would
then report all those continuations as separate log events.
Which is the whole point of LOG_CONT - for that *not* to happen.
So this is just a heads-up that I will not pull something that breaks
LOG_CONT because it thinks "user space can handle it". No. User space
does not handle it, and we need to handle it for the user.
So as long as the kernel makes sure the joining does happen it at some
point, it's all fine. It obviously doesn't have to happen at printk()
time, just as long as incomplete records aren't exposed even to
concurrent readers.
A test-case with a short delay in between writes might be a good idea,
although the last time this broke it was very clear in peoples syslogs
and dmesg because it turns out there are lots of concurrent readers at
boot time and _somebody_ will hit the race.
Linus
More information about the kexec
mailing list