linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Petr Mladek <pmladek@suse.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Joe Perches <joe@perches.com>,
	Steven Rostedt <rostedt@goodmis.org>, Pavel Machek <pavel@ucw.cz>,
	Jan Kara <jack@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jiri Slaby <jslaby@suse.com>, Andreas Mohr <andi@lisas.de>,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: printk: what is going on with additional newlines?
Date: Mon, 18 Sep 2017 09:46:41 +0900	[thread overview]
Message-ID: <20170918004641.GA3161@jagdpanzerIV.localdomain> (raw)
In-Reply-To: <CA+55aFynkjSL1NNZbx6m1iE2HjZagGK09rAr5-HaZ4Ep2eWKOg@mail.gmail.com>

Hello Linus,

On (09/17/17 08:35), Linus Torvalds wrote:
> On Sat, Sep 16, 2017 at 11:26 PM, Sergey Senozhatsky
> <sergey.senozhatsky@gmail.com> wrote:
> >
> > so... I think we don't have to update 'struct printk_log'. we can store
> > that "extended data" at the beginning of every message, right after the
> > prefix.
> 
> No, we really can't. That just means that all the tools would have to
> be changed to get the normal messages without the extra crud. And
> since it will have lost the difference, that's not even easy to do.

well, that extra crud is meant to be there only when people explicitly
enable CONFIG_PRINTK_ADD_EXTRA_CRUD_PLEASE. so it's a debugging option.


> So this is exactly the wrong way around.
> 
> If people want to see the extra data, it really should be extra data
> that you can get with a new interface from the kernel logs. Not a
> "let's just a add it to all lines and make every line uglier and
> harder to read.

there is another reason why I think that, yes, we probably better do
it some other way. and the reason is that not every message that looks
like !PREFIX (does not start with KERN_SOH_ASCII) is _actually_ a
!PREFIX message. the normal/usual way is to have something like

	printk(KERN_SOH_ASCII %d " foo bar / %s %s\n", "foo", "bar");

but some messages look like

	printk("%s", KERN_SOH_ASCII %d "foo bar\n");

so we end up having a "normal" message with KERN_SOH_ASCII %d at
offsets 0 and 1 in the resulting text, but only after we do vscnprintf()
in vprintk_emit(). so the proposed _pre-processing_ is complicated.
post-processing -- the one we do in vprintk_emit() -- is still simple.


that's why last night I thought that may be we can do something more
radical - double the number of logbuf lines. IOW, every time we do

	log_store(facility, level, lflags, 0, dict, dictlen, text, text_len)

we also will do

	static char ext_data[...];

	size_t ext_sz = sprintf(ext_data, .....);
	log_store(facility, level, lflags, 0, dict, dictlen, ext_data, ext_sz);

so every message will now have "extra message" before (or after) it. we
do log_store() under logbuf lock, so no other messages should appear
(um, hopefully). every extra message will contain "[extra:" text, so it'll
be possible to filter it out... but, once again, the extra stuff is printed
only when people ask for it.


we are currently looking at
	lkml.kernel.org/r/1504613201-23868-1-git-send-email-prarit@redhat.com

which will definitely break some user space tools (well, if enabled in
.config); so I thought that may be that "helpful" timestamp can go as
extra payload.

p.s.
while I'm not entire sold on the whole timestamps in printk help
resolve issues thing. first, printk() can spin on logbuf lock before
it will read the timestamp. second, between
printk()->va_start->vprintk_func->{...this_cpu_read...}->vprintk_emit->logbuf_lock->...

and printk_get_ts() many things can happen - irq, preemption, etc. - so
timestamp that we take under ->logbuf_lock is of somewhat questionable
accurateness.

	-ss

  reply	other threads:[~2017-09-18  0:46 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-15  2:56 [RFC][PATCHv5 00/13] printk: introduce printing kernel thread Sergey Senozhatsky
2017-08-15  2:56 ` [RFC][PATCHv5 01/13] printk: move printk_pending out of per-cpu Sergey Senozhatsky
2017-08-15  2:56 ` [RFC][PATCHv5 02/13] printk: introduce printing kernel thread Sergey Senozhatsky
2017-08-15  2:56 ` [RFC][PATCHv5 03/13] printk: add sync printk_emergency API Sergey Senozhatsky
2017-08-15  2:56 ` [RFC][PATCHv5 04/13] printk: add enforce_emergency parameter Sergey Senozhatsky
2017-08-15  2:56 ` [RFC][PATCHv5 05/13] printk: enable printk offloading Sergey Senozhatsky
2017-08-15  2:56 ` [RFC][PATCHv5 06/13] printk: register PM notifier Sergey Senozhatsky
2017-08-15 11:51   ` Rafael J. Wysocki
2017-08-16  7:31     ` Sergey Senozhatsky
2017-08-16 12:58       ` Rafael J. Wysocki
2017-08-17  5:55         ` Sergey Senozhatsky
2017-08-17 15:43           ` Rafael J. Wysocki
2017-08-17 23:19             ` Sergey Senozhatsky
2017-08-15  2:56 ` [RFC][PATCHv5 07/13] printk: register syscore notifier Sergey Senozhatsky
2017-08-15 11:56   ` Rafael J. Wysocki
2017-08-16  6:55     ` Sergey Senozhatsky
2017-08-16 12:59       ` Rafael J. Wysocki
2017-08-15  2:56 ` [RFC][PATCHv5 08/13] printk: set watchdog_thresh as maximum value for atomic_print_limit Sergey Senozhatsky
2017-08-15  2:56 ` [RFC][PATCHv5 09/13] printk: add auto-emergency enforcement mechanism Sergey Senozhatsky
2017-08-15  2:56 ` [RFC][PATCHv5 10/13] printk: force printk_kthread to offload printing Sergey Senozhatsky
2017-08-15  2:56 ` [RFC][PATCHv5 11/13] printk: always offload printing from user-space processes Sergey Senozhatsky
2017-08-15  2:56 ` [RFC][PATCHv5 12/13] printk: do not cond_resched() when we can offload Sergey Senozhatsky
2017-08-15  2:56 ` [RFC][PATCHv5 13/13] printk: move offloading logic to per-cpu Sergey Senozhatsky
2017-08-23  8:33 ` [RFC][PATCHv5 00/13] printk: introduce printing kernel thread Sergey Senozhatsky
2017-08-28  9:05 ` printk: what is going on with additional newlines? Pavel Machek
2017-08-28 10:28   ` Sergey Senozhatsky
2017-08-28 12:21     ` Sergey Senozhatsky
2017-08-28 12:38       ` Sergey Senozhatsky
2017-08-28 12:46       ` Pavel Machek
2017-08-29 13:40         ` Sergey Senozhatsky
2017-08-29 16:37           ` Joe Perches
2017-08-29 17:00           ` Linus Torvalds
2017-08-29 17:12             ` Linus Torvalds
2017-08-29 20:41               ` Tetsuo Handa
2017-08-29 20:51                 ` Linus Torvalds
2017-09-02  6:12                   ` Tetsuo Handa
2017-09-02 17:06                     ` Linus Torvalds
2017-08-29 23:50               ` Steven Rostedt
2017-08-29 23:59                 ` Linus Torvalds
2017-08-30  1:03                 ` Sergey Senozhatsky
2017-08-30  1:10                   ` Steven Rostedt
2017-08-30  1:51                     ` Sergey Senozhatsky
2017-08-30  1:52                     ` Joe Perches
2017-08-30  2:25                       ` Sergey Senozhatsky
2017-08-30  2:31                         ` Joe Perches
2017-08-30  2:47                           ` Sergey Senozhatsky
2017-08-30  2:58                             ` Joe Perches
2017-08-30  5:37                               ` Sergey Senozhatsky
2017-09-08 10:18                                 ` Pavel Machek
2017-09-05  9:44                             ` Petr Mladek
2017-09-05  9:59                               ` Sergey Senozhatsky
2017-09-05 12:21                                 ` Petr Mladek
2017-09-05 12:35                                   ` Tetsuo Handa
2017-09-05 14:18                                     ` Sergey Senozhatsky
2017-09-05 13:42                                   ` Sergey Senozhatsky
2017-09-06  7:55                                     ` Petr Mladek
2017-09-17  6:26                                       ` Sergey Senozhatsky
2017-09-17  9:27                                         ` Sergey Senozhatsky
2017-09-17 15:35                                         ` Linus Torvalds
2017-09-18  0:46                                           ` Sergey Senozhatsky [this message]
2017-09-18  2:22                                             ` Joe Perches
2017-09-18  2:41                                               ` Sergey Senozhatsky
2017-09-18  2:45                                                 ` Joe Perches
2017-09-18  2:55                                                   ` Sergey Senozhatsky
2017-09-18  3:07                                                     ` Joe Perches
2017-09-18  4:42                                                       ` Sergey Senozhatsky
2017-09-01 13:19                     ` Sergey Senozhatsky
2017-09-01 17:32                       ` Joe Perches
2017-09-01 20:21                         ` Linus Torvalds
2017-09-04  5:22                           ` Sergey Senozhatsky
2017-09-04  5:41                             ` Joe Perches
2017-09-05 14:54                             ` Steven Rostedt
2017-09-06  2:14                               ` Sergey Senozhatsky
2017-09-06  2:36                               ` Linus Torvalds
2017-09-04  4:30                         ` Sergey Senozhatsky
2017-09-04  5:24                           ` Sergey Senozhatsky
2017-08-29 17:33             ` Sergey Senozhatsky
2017-08-29 17:52               ` Linus Torvalds
2017-08-29 18:09                 ` Joe Perches
2017-08-30  1:07                   ` Sergey Senozhatsky
2017-08-30  0:58                 ` Sergey Senozhatsky
2017-08-29 16:48   ` Linus Torvalds
2017-08-29 17:10     ` Joe Perches
2017-08-29 17:20       ` Linus Torvalds
2017-08-29 17:33         ` Joe Perches
2017-08-29 17:36           ` Linus Torvalds
2017-08-29 17:48             ` Joe Perches
2017-08-29 20:24     ` Pavel Machek
2017-09-01  1:40       ` Sergey Senozhatsky
2017-09-01  2:04         ` Joe Perches
2017-09-01  6:59           ` Pavel Machek
2017-09-01  7:23             ` Joe Perches
2017-09-01  7:29         ` Pavel Machek
2017-09-01 11:13           ` 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=20170918004641.GA3161@jagdpanzerIV.localdomain \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@lisas.de \
    --cc=jack@suse.cz \
    --cc=joe@perches.com \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).