All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Tony Luck <tony.luck@gmail.com>
Cc: Joe Perches <joe@perches.com>, Jiri Kosina <jikos@kernel.org>,
	Colin Ian King <colin.king@canonical.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [GIT PULL] trivial for 4.9
Date: Fri, 7 Oct 2016 16:36:47 -0700	[thread overview]
Message-ID: <CA+55aFzcJ=DnWdfMaiNXYS8BEp4CxUdZKXrrF9pRBGsrB67iow@mail.gmail.com> (raw)
In-Reply-To: <CA+8MBbJFD69qGiJQ1odu2ZczDoxbvViS+i6EbsLFX-zApBO4yQ@mail.gmail.com>

On Fri, Oct 7, 2016 at 4:09 PM, Tony Luck <tony.luck@gmail.com> wrote:
> On Fri, Oct 7, 2016 at 4:01 PM, Tony Luck <tony.luck@gmail.com> wrote:
>> What if there isn't a "next printk" call for hours, or days?
>>
>> That poor little message without a "\n" will sit in the kernel buffers,
>> and the user who might want to see the message can't, until some
>> unrelated thing happens to print something.
>
> Retracted ...  I'm sure that at some point in the past it happened
> like that ...  but I just retested on 4.8 and the first message (with
> no "\n") showed up on the serial port just fine without some other
> message to push it out.  When the next message came along, a "\n" was
> auto-inserted.

Yeah, that immediate printout has actually always worked fine - the
newline was never really a buffering thing.

The buffering actually came fairly late, with the "newfangled"
record-oriented logging facility (4+ years old by now).

Our kernel message log was historically just a plain buffer, and not
record-oriented at all. You'd just read and write it as a stream. In
that historical context, it made tons of sense to just write something
without a newline, and then continue writing on the same line: that's
how <stderr> always works.

But back in 2012, Kay Sievers wanted to make it record-based, because
reasons. That *really* doesn't play well with the whole "oh, you might
not get the whole thing in one go" model, and things were broken a few
times. It also made our printk implementation a lot more complex. But
there was some argument for a full-featured syslog facility.  Line
continuations suddenly weren't very natural any more, because now a
continuation printk was very much a "broken record".

Anyway, the complexity has had upsides too, and the "let's not require
'\n' at the end" actually came in through that (in fact, I think the
record-based internal format removes the newlines at the end of
characters). And there are some real advantages, both with timestamps
and with having per-record log levels. So it's definitely not all bad,
but there's a fair amount of complexity in there. The old model was
rather broken in other ways, though, so on the whole I think we're
doing fairly ok.

But yes, the line continuation that *used* to be very natural (but
always had problems with concurrent output from multiple contexts)
definitely makes for extra complexity in the record-based model. But
exactly *because* the record-based thing needs to be more careful
about those newlines, it actually ended up being why the explicit "\n"
thing at the end of a printk shouldn't really matter any more.

And not having it does make for nicer printk strings. "Just the facts".

             Linus

  reply	other threads:[~2016-10-07 23:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-07  8:51 [GIT PULL] trivial for 4.9 Jiri Kosina
2016-10-07 19:22 ` Linus Torvalds
2016-10-07 20:04   ` Joe Perches
2016-10-07 20:13     ` Linus Torvalds
2016-10-07 20:18       ` Joe Perches
2016-10-07 20:25         ` Linus Torvalds
2016-10-07 20:33           ` Joe Perches
2016-10-07 21:06             ` Linus Torvalds
2016-10-07 21:37               ` Linus Torvalds
2016-10-08  7:36                 ` Joe Perches
2016-10-10  5:48                 ` Joe Perches
2016-10-07 21:44               ` Joe Perches
2016-10-07 23:01                 ` Tony Luck
2016-10-07 23:09                   ` Tony Luck
2016-10-07 23:36                     ` Linus Torvalds [this message]
2016-10-08 13:16                     ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+55aFzcJ=DnWdfMaiNXYS8BEp4CxUdZKXrrF9pRBGsrB67iow@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=colin.king@canonical.com \
    --cc=jikos@kernel.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.