All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.com>
To: Josh Triplett <josh@joshtriplett.org>
Cc: ksummit-discuss@lists.linuxfoundation.org
Subject: Re: [Ksummit-discuss] [TECH TOPIC] asynchronous printk
Date: Tue, 19 Jul 2016 09:02:17 +0200	[thread overview]
Message-ID: <02f7282d-954a-8491-6110-fe6ce704d0c5@suse.com> (raw)
In-Reply-To: <20160719064902.GA1314@x>

On 07/19/2016 08:49 AM, Josh Triplett wrote:
> On Tue, Jul 19, 2016 at 08:17:19AM +0200, Hannes Reinecke wrote:
>> Yes. The main problem stems from the fact that printk has two different
>> and conflicting use-cases:
>> - Really urgent, 'I am about to die' messages. Which obviously need to
>>   be printed out as fast as possible.
>> - Rather largish, information/logging 'what I always wanted to tell you'
>>   type of messages. These messages tend to be very large, but at the end
>>   it doesn't really matter _when_ they'll be printed as they are
>>   time-stamped anyway.
>>
>> For the first use-case you absolutely need a synchronous printk, but
>> this is a complete killer for the second case.
>> And OTOH having a separate thread is really the way to go for the second
>> case, but an absolute no-go for the first.
>>
>> So I really wonder if it does make sense to lump both use-cases into one
>> call, or whether it wouldn't be better to have two distinct calls
>> for that (or, for the sake of argument, use KERN_EMERG to trigger
>> synchronous printks).
> 
> For the sake of argument: what about using loglevel to distinguish the
> two cases by default?
> 
That's what I've tried to infer by the above statement; KERN_EMERG could
easily used for that sort of thing.
Also I'd like to have everything on board with this idea, namely that
using printk for instantaneous but really long messages it _NOT_ going
to work.
(And I'd love to kill printk line continuation, too, but that's another
story)

> If the printk would show up on the console, handle it inline immediately
> before returning, so that the user sees it on the console immediately in
> case the very next line hangs the system.  That also helps with the
> debugging approach of copy/pasting many instances of pr_alert("%s:%d:
> here\n", __func__, __LINE__) and looking for the last one that shows up.
> 
> If the printk would *not* show up on the console, and would only show up
> asynchronously in dmesg or a log somewhere, then go ahead and throw it
> to the asynchronous printk_kthread context to handle and return, because
> if the next line crashes, userspace wouldn't get the opportunity to read
> and log it anyway.
> 
> Combined with a mechanism like "if the kernel panics, try as hard as
> possible to dump out all the pending printks before dying", that seems
> like a reasonable default behavior that shouldn't result in surprises.
> If the kernel is alive enough that userspace can still log things (such
> as if the display hangs but the kernel and userspace are still running),
> then the kernel should also still be alive enough to process the pending
> printks.
> 
But it still leaves us with a possible priority inversion.
How should we deal with situations where the async thread is running and
someone is issuing a synchronous printk?
Should we skip the asynchonous ones and print the synchronous one first,
risking out-of-order messages but a higher probability that the urgent
message is actually printed ?
Or should we elevate everything to synchronous, preserving ordering
but increasing the risk that the synchronous message never ever makes it
to the console?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		               zSeries & Storage
hare@suse.com			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

  reply	other threads:[~2016-07-19  7:02 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-19  3:47 [Ksummit-discuss] [TECH TOPIC] asynchronous printk Sergey Senozhatsky
2016-07-19  3:56 ` Viresh Kumar
2016-07-19  6:17 ` Hannes Reinecke
2016-07-19  6:49   ` Josh Triplett
2016-07-19  7:02     ` Hannes Reinecke [this message]
2016-07-19  7:11       ` Geert Uytterhoeven
2016-07-20  6:02         ` Jan Kara
2016-07-20 22:54       ` Josh Triplett
2016-07-21  0:46         ` Sergey Senozhatsky
2016-07-21  1:12           ` Josh Triplett
2016-07-19  7:33   ` Sergey Senozhatsky
2016-07-19  7:38     ` Hannes Reinecke
2016-07-19  7:46       ` Sergey Senozhatsky
2016-07-19  8:02         ` Hannes Reinecke
2016-07-19  8:23           ` Sergey Senozhatsky
2016-07-21 10:36           ` David Woodhouse
2016-07-21 12:31             ` Jan Kara
2016-07-28  2:55             ` Steven Rostedt
2016-07-20  6:09       ` Jan Kara
2016-07-19  7:46   ` Christian Borntraeger
2016-07-19  7:53     ` Christian Borntraeger
2016-07-19 13:55       ` Jan Kara
2016-07-28  2:59         ` Steven Rostedt
2016-07-28  4:12           ` Sergey Senozhatsky
2016-07-28 13:02             ` Steven Rostedt
2016-07-20  3:35   ` Wangnan (F)
2016-07-21  1:16     ` Andy Lutomirski
2016-07-21  1:52       ` Wangnan (F)
2016-07-21  5:59       ` Hannes Reinecke
2016-07-21 10:31         ` David Woodhouse
2016-07-21 11:19           ` Josh Triplett
2016-07-21 11:59             ` David Woodhouse
2016-07-21 14:21               ` Josh Triplett
2016-07-21 14:40                 ` David Woodhouse
2016-07-28  3:05                 ` Steven Rostedt
2016-08-02 11:59               ` Petr Mladek
2016-07-21 15:05           ` Andy Lutomirski
2016-07-26 14:40             ` David Woodhouse
2016-07-26 15:44               ` Benjamin Herrenschmidt
2016-07-26 21:00               ` Andy Lutomirski
2016-07-27  0:03                 ` David Woodhouse
2016-07-27  1:16                   ` Sergey Senozhatsky
2016-07-21 10:28       ` David Woodhouse
2016-07-19 14:45 ` James Bottomley
2016-07-19 14:55   ` Sergey Senozhatsky
2016-07-19 17:58     ` James Bottomley
2016-07-19 18:24       ` Viresh Kumar
2016-07-20  2:08       ` Sergey Senozhatsky
2016-07-20  6:14     ` Jan Kara
2016-09-21  4:41 ` Sergey Senozhatsky
2016-10-31  6:54   ` Sergey Senozhatsky
2016-10-31 13:56     ` Theodore Ts'o
2016-10-31 13:59       ` Jiri Kosina
2016-10-31 14:56       ` [Ksummit-discuss] [TECH TOPIC] printk considered harmful (was: [TECH TOPIC] asynchronous printk) Sergey Senozhatsky
2016-10-31 16:18         ` Theodore Ts'o
2016-10-31 18:21           ` Sergey Senozhatsky
2016-10-31 18:26             ` [Ksummit-discuss] [TECH TOPIC] printk considered harmful Hannes Reinecke
2016-10-31 20:28           ` [Ksummit-discuss] [TECH TOPIC] printk considered harmful (was: [TECH TOPIC] asynchronous printk) Jan Kara
2016-11-01 12:27             ` [Ksummit-discuss] [TECH TOPIC] printk considered harmful Hannes Reinecke
2016-11-01 17:50         ` [Ksummit-discuss] [TECH TOPIC] printk considered harmful (was: [TECH TOPIC] asynchronous printk) 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=02f7282d-954a-8491-6110-fe6ce704d0c5@suse.com \
    --to=hare@suse.com \
    --cc=josh@joshtriplett.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 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.