ksummit.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: "ksummit-discuss@lists.linuxfoundation.org"
	<ksummit-discuss@lists.linuxfoundation.org>
Subject: Re: [Ksummit-discuss] [TECH TOPIC] printk redesign
Date: Thu, 20 Jul 2017 16:53:47 +0900	[thread overview]
Message-ID: <20170720075347.GA356@jagdpanzerIV.localdomain> (raw)
In-Reply-To: <1500449720.19151.7.camel@infradead.org>

Hello,

On (07/19/17 09:35), David Woodhouse wrote:
[..]
> > At some point we start reinventing ftrace...  there's issues with
> > joining the two up but there should at least be lessons we can learn.
> > 
> 
> The other way of looking at this is "why are you abusing printk for
> stuff that should have been done via ftrace or other means instead".
>
> I confess I haven't got my curmudgeonly brain out of that mode at all,
> ever since realising that printk had been made asynchronous and
> unreliable (how long ago was that?) and that you could no longer see
> the dying gasp of a crashing kernel on its serial console.
> 
> Rather than morphing printk into something more capable of bulk
> transport, I'd rather see it go back to its roots of
> debugging/diagnostics.
> 
> The original complaint of "all this printk output makes things too
> slow" was better addressed by printing less or at lower severity (or
> adjusting the console loglevel), IMO.
> 
> As things stand, the requirements for the various printk (ab)use cases
> seem to be contradictory — if we're going to have a redesign then I
> think it would be good to take a holistic view and decide what it's
> actually *supposed* to be used for. And, perhaps more to the point,
> what it isn't supposed to be used for.

just some thoughts,

at glance printk has 3 major issues

- it has to do offloading, no doubt.

- printk() can deadlock, easily. (that's the whole reason there is
  printk_deferred())

- printk from NMI is not completely reliable. this area has been
  improved recently; but there are still cases when we can lose
  NMI-printk messages


... but there are more problems. and those issues are not completely
printk fault.

what I mean (and I'm not criticizing anyone),

so we can split printk: defer printing of debug messages and have
direct printing of important messages. and that's where the redesign
hits the first obstacle: direct printing is unreliable. when we do
call_console_drivers() we pass control to the outside world, and we
never know where we will end up at. consoles can invoke timekeeping,
networking, MM, and so on. so I think printk redesign better start
from this part - make call to console drivers more reliable.
if possible.


what I'm talking about, by just one example:

bug report
https://marc.info/?l=dri-devel&m=149938825811219

root cause
https://marc.info/?l=linux-mm&m=149939515214223&w=2


so printk live-locked, and there was no way to see any kernel logs
until Tetsuo sysrq-c'ed the system. and the root cause was all those
complex and difficult dependencies between completely different
subsystems that printk depend on and that, in turn, depend on printk.


> hm, this allocation, per se, looks ok to me. can't really blame it.
> what you had is a combination of factors
>
>        CPU0                    CPU1                            CPU2
>                                                                console_callback()
>                                                                 console_lock()
>                                                                 ^^^^^^^^^^^^^
>        vprintk_emit()          mutex_lock(&par->bo_mutex)
>                                 kzalloc(GFP_KERNEL)
>         console_trylock()        kmem_cache_alloc()              mutex_lock(&par->bo_mutex)
>         ^^^^^^^^^^^^^^^^          io_schedule_timeout


there are more examples.

more closer to the point,
to the best of my knowledge, we don't have that much problems with the
printk logbuf now. we made some progress there over the last year. yes,
NMI printk is not completely awesome.
where we do have problems, I think:

a) we probably need to make more progress towards "and now we print it to the console"
b) print out offloading
c) printk deadlock and the need of printk_deferred()



and it's not always crazy printk abuse to justify the existence of
printk offloading.

example: https://marc.info/?l=linux-mm&m=149977866327662

> you will find that calling cond_resched() (from console_unlock() from printk())
> can cause a delay of nearly one minute, and it can cause a delay of nearly 5 minutes
> to complete one out_of_memory() call. 

example: https://marc.info/?l=linux-kernel&m=149509270422321


printk, to me, is a debugging/diagnostics tool. and we can't fully rely on
it, even we do reasonable things, like OOM print out. moreover, I think, to
some extent, due to printk imperfections, the more debugging options we
enable (CONFIG_DEBUG_PREEMPT, CONFIG_DEBUG_SPINLOCK, etc.) the less stable
the kernel, potentially, gets. because those options use printk() to report
the problems. so might_sleep() or spin_dump() called from "a wrong place"
can eventually deadlock printk() and the system.

example: https://marc.info/?l=linux-kernel&m=149007148320611


well, just my thoughts.

	-ss

  reply	other threads:[~2017-07-20  7:53 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-19  5:21 Sergey Senozhatsky
2017-06-19  6:22 ` Hannes Reinecke
2017-06-19 14:39   ` Steven Rostedt
2017-06-19 15:20     ` Andrew Lunn
2017-06-19 15:54       ` Hannes Reinecke
2017-06-19 16:17         ` Andrew Lunn
2017-06-19 16:23         ` Mark Brown
2017-06-20 15:58           ` Sergey Senozhatsky
2017-06-20 16:44             ` Luck, Tony
2017-06-20 17:11               ` Sergey Senozhatsky
2017-06-20 17:27                 ` Mark Brown
2017-06-20 23:28                   ` Steven Rostedt
2017-06-21  7:17                     ` Hannes Reinecke
2017-06-21 11:12                     ` Sergey Senozhatsky
2017-06-22 14:06                       ` Steven Rostedt
2017-06-23  5:43                         ` Sergey Senozhatsky
2017-06-23 13:09                           ` Steven Rostedt
2017-06-21 12:23                     ` Petr Mladek
2017-06-21 14:18                       ` Andrew Lunn
2017-06-23  8:46                         ` Petr Mladek
2017-06-21 16:09                       ` Andrew Lunn
2017-06-23  8:49                         ` Petr Mladek
2017-07-19  7:35                   ` David Woodhouse
2017-07-20  7:53                     ` Sergey Senozhatsky [this message]
2017-06-20 16:09         ` Sergey Senozhatsky
2017-06-19 16:26       ` Steven Rostedt
2017-06-19 16:35         ` Andrew Lunn
2017-06-24 11:14         ` Mauro Carvalho Chehab
2017-06-24 14:06           ` Andrew Lunn
2017-06-24 22:42             ` Steven Rostedt
2017-06-24 23:21               ` Andrew Lunn
2017-06-24 23:26                 ` Linus Torvalds
2017-06-24 23:40                   ` Steven Rostedt
2017-06-26 11:16                     ` Sergey Senozhatsky
2017-06-24 23:48                   ` Al Viro
2017-06-25  1:29                     ` Andrew Lunn
2017-06-25  2:41                       ` Linus Torvalds
2017-06-26  8:46                         ` Jiri Kosina
2017-07-19  7:59                           ` David Woodhouse
2017-06-20 15:56     ` Sergey Senozhatsky
2017-06-20 18:45     ` Daniel Vetter
2017-06-21  9:29       ` Petr Mladek
2017-06-21 10:15       ` Sergey Senozhatsky
2017-06-22 13:42         ` Daniel Vetter
2017-06-22 13:48           ` Daniel Vetter
2017-06-23  9:07             ` Bartlomiej Zolnierkiewicz
2017-06-27 13:06               ` Sergey Senozhatsky
2017-06-23  5:20           ` Sergey Senozhatsky
2017-06-19 23:46 ` Josh Triplett
2017-06-20  8:24   ` Arnd Bergmann
2017-06-20 14:36     ` Steven Rostedt
2017-06-20 15:26       ` Sergey Senozhatsky
2017-06-22 16:35 ` David Howells
2017-07-19  6:24 ` Sergey Senozhatsky
2017-07-19  6:25   ` Sergey Senozhatsky
2017-07-19  7:26     ` Daniel Vetter
2017-07-20  5:19       ` Sergey Senozhatsky

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=20170720075347.GA356@jagdpanzerIV.localdomain \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=ksummit-discuss@lists.linuxfoundation.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