LWN.net Logo

Re: [PATCH RESEND 1/3] printk: convert byte-buffer to variable-length record buffer

From:  Linus Torvalds <torvalds-AT-linux-foundation.org>
To:  Kay Sievers <kay-AT-vrfy.org>
Subject:  Re: [PATCH RESEND 1/3] printk: convert byte-buffer to variable-length record buffer
Date:  Tue, 8 May 2012 20:52:06 -0700
Message-ID:  <CA+55aFwbQTq_f7p2j-eu8-hVpiZ1Uf2MCU7R+DDWHimiVbcScg@mail.gmail.com>
Cc:  Sasha Levin <levinsasha928-AT-gmail.com>, Greg Kroah-Hartmann <greg-AT-kroah.com>, Ingo Molnar <mingo-AT-kernel.org>, linux-kernel-AT-vger.kernel.org
Archive-link:  Article, Thread

On Tue, May 8, 2012 at 4:14 AM, Kay Sievers <kay@vrfy.org> wrote:
>
> Yeah, we need to make sure, we never merge the (always racy)
> continuation printk() users with (non-racy) non-continuation users.
> Therefore KERN_CONT is required to suppress the newline and to merge the
> content with the earlier non-newline-terminated printk() line.

Why?

I really think this is just a bug in the new code.

KERN_CONT should not be needed if the previous printk didn't have a final "\n".

We made it easier to use printk for a reason a few months ago. The new
rules are:

 - If you have a KERN_<loglevel>, it *always* starts a new line, the
obvious exception being KERN_CONT

 - the loglevels *only* matter at the start of the printk - so if you
have '\n' embedded in a single printk, that changes nothing
what-so-ever. It's not line-based.

 - if you didn't have a '\n', and don't have a loglevel, KERN_CONT is implied.

Quite frankly, those three rules (a) make sense and (b) make things easy.

Breaking them now is a bug. Please don't go adding ugly KERN_CONT when
there really isn't any reason for it. Just fix the printk code you
broke.

                  Linus


(Log in to post comments)

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds