All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>, Jan Kara <jack@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Eric Biederman <ebiederm@xmission.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>, Pavel Machek <pavel@ucw.cz>,
	Andreas Mohr <andi@lisas.de>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCHv3 2/5] printk: introduce printing kernel thread
Date: Fri, 30 Jun 2017 21:42:24 +0900	[thread overview]
Message-ID: <20170630124224.GA792@jagdpanzerIV.localdomain> (raw)
In-Reply-To: <20170630115457.GE23069@pathway.suse.cz>

Hello,

On (06/30/17 13:54), Petr Mladek wrote:
> > but.....
> > the opposite possibility is that messages either won't be printed
> > soon (until next printk or console_unlock()) or won't be printed
> > ever at all (in case of sudden system death). I don't think it's
> > a good alternative.
> 
> I see it like a weighing machine. There is a "guaranteed" output on
> one side and a softlockups prevention on the other side. The more
> we prevent the softlockups the less we guarantee the output.

I apply a very simple litmus test. if the answer to the question
"so we leave console_unlock() and there are pending messages,
who and when is going to flush the remaining messages?" is
"something sometime in the future" then it's a no-no.

"something sometime in the future" is equal to "no one".

we must stay and continue printing. because it gives the right
answer - "current process and right now. until someone else
(+printk_kthread) takes over".


> We do not have the same opinion about the balance. My solution
> completely prevents softlockups.

not at all costs. especially if we talk about possibility of losing
messages. if we consider such possibility, then let's just
unconditionally drop logbuf entries every time console_lock() is
looping for too long.

> Your one tries to be more conservative.

Linus wrote:

: If those two things aren't the absolutely primary goals, the whole
: thing is pointless to even discuss. No amount of cool features,
: performance, or theoretical deadlock avoidance matters ONE WHIT
: compared to the two things above.

and

Linus wrote:

: But not having any messages at all, because we were trying so hard to
: abstract things out and put them in buffers so that we couldn't
: deadlock with the IO routines, and the timer or workqueue that was
: supposed to do it is never going to happen any more because of the bug
: that is trying to be printed out?
:
: THAT is bad.


I think our priorities should be quite clear here.


> My main unresolved doubts about this patchset are:
> 
> 1. It gives other processes only very small change to take
>    over the job. They either need to call console_trylock()
>    in very small "race" window or they need to call
>    console_lock(). Where console_lock() only signalizes
>    that the caller is willing to take the job and puts
>    him into sleep.

printk_kthread does console_lock().

we may (and need to) improve the retry path in console_unlock().
but we must not leave it until other process locks the console_sem.

>    Another detailed description of this problem can be found
>    in my previous mail, see
>    https://lkml.kernel.org/r/20170628121925.GN1538@pathway.suse.cz
> 
> 
> 2. It adds rather complex dependency on the scheduler. I know
>    that my simplified solution do this as well but another way[*]
>    Let me explain. I would split the dependency on the code
>    and behavior relation.
> 
>    From the code side: The current printk() calls wake_up_process()
>    and we need to use printk_deferred() in the related scheduler code.
>    This patch does this as well, so there is no win and no lose.
>    Well, you talk about changing the affinity and other tricks
>    in the other mails. This might add more locations where
>    printk_deferred() would be needed.

we are in printk_safe all the way through console_offload_printing(),
the context is derived from console_unlock().

why we would need printk_deferred()?

>    From the behavior side: The current code wakes the process
>    and is done. The code in this patch wakes the process and
>    waits until it[**] gets CPU and really runs. It switches to
>    the emergency mode when the other process does not run in time.
>    By other words, this patch depends on more actions done
>    by the scheduler and changes behavior based on it. IMHO,
>    this will be very hard to code, tune, and debug.
>    A proper solution might require more code dependency.
> 
>    [*] My solution depends on the scheduler in the sense
>        that messages will get lost when nobody else will take
>        over the console job.

which is precisely and exactly the thing that we should never
let to happen. there is no _win_, because we _lost_ the messages.


> 3. The prevention of soft-lockups is questionable. If you are in
>    soft-lockup prone situation, the only prevention is to do an
>    offload. But if you switch to the emergency mode and give
>    up offloading too early, the new code stops preventing
>    the softlockup.
> 
>    Of course, the patchset does not make it worse but the question
>    is how much it really helps. It would be bad to add a lot of
>    code/complexity with almost no gain.
> 
> 
> IMHO, if we try to solve the 1st problem (chance of offloading),
> it might add a risk of deadlocks and/or make the 2nd problem
> (dependency on scheduler) worse. Also I am afraid that we would
> repeat many dead ways already tried by Jan Kara.

what deadlock?


> If you will try to improve 3rd problem and make some guaranties
> of the soft-lockup prevention, it would make the 2nd problem
> (dependency on scheduler) worse. Also the code might be
> very hard to understand and tune.
> 
> 
> This is why I look for a rather simple solution. IMHO, we both
> agree that:
> 
>    +  the offload will be activated only when there is
>       a flood of messages
> 
>    + the only reason to wait for the other handler is to
>      better handle sudden death where panic() is not called.
> 
> IMHO, the only one who brought the problem of sudden death
> was Pavel Machek.

we gave up on printk-async. the last bug report was titled "blah blah
missing backtrace". and I really would rather prefer to see that
backtrace + soft lockup or even hard lockup. still would have been
better than seeing nothing at all.

	-ss

> AFAIK, he works on embedded systems and hardware enablement.
> I guess the combination of the flood of messages and sudden
> death is rare there. Also I doubt that the current code handle
> it well. The flood is badly handed in general. In each case,
> I wonder how long we could survive flushing messages when there
> is sudden death and scheduling does not work.
> 
> One problem here is that some questions/doubts are hard to
> answer/prove without wide testing.
> 
> A compromise might be to start with the simple code
> and disable the offloading by default. I am sure that
> there will be volunteers that would want to play with it,
> e.g. Tetsuo. We would enable it in SUSE as well because
> there should not be any regression against what we have
> used for years now. We could make it always more complex
> according to the feedback and eventually enable it
> by default.
> 
> Best Regards,
> Petr
> 

  reply	other threads:[~2017-06-30 12:42 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-09  8:28 [RFC][PATCHv3 0/5] printk: introduce printing kernel thread Sergey Senozhatsky
2017-05-09  8:28 ` [RFC][PATCHv3 1/5] printk: move printk_pending out of per-cpu Sergey Senozhatsky
2017-05-25 12:11   ` Petr Mladek
2017-05-25 12:36     ` Sergey Senozhatsky
2017-05-25 12:43       ` Petr Mladek
2017-05-09  8:28 ` [RFC][PATCHv3 2/5] printk: introduce printing kernel thread Sergey Senozhatsky
2017-05-10  5:59   ` Sergey Senozhatsky
2017-05-29  9:29     ` Petr Mladek
2017-05-29 12:12       ` Jan Kara
2017-05-31  7:30         ` Sergey Senozhatsky
2017-05-31 21:44           ` Andreas Mohr
2017-06-01  7:21           ` Sergey Senozhatsky
2017-06-01  7:23             ` Sergey Senozhatsky
2017-06-01  9:20             ` Sergey Senozhatsky
2017-06-28 13:17             ` Petr Mladek
2017-06-29  7:40               ` Sergey Senozhatsky
2017-06-28 12:45           ` Petr Mladek
2017-05-31  7:22       ` Sergey Senozhatsky
2017-06-28 12:19         ` Petr Mladek
2017-06-29  6:26           ` Andreas Mohr
2017-06-29  7:00             ` Andreas Mohr
2017-06-29  7:33           ` Sergey Senozhatsky
2017-06-29 11:24             ` Tetsuo Handa
2017-06-30  7:01             ` Sergey Senozhatsky
2017-06-30 10:18               ` Tetsuo Handa
2017-06-30 11:57                 ` Sergey Senozhatsky
2017-06-30 12:35                   ` Tetsuo Handa
2017-06-30 12:50                     ` Sergey Senozhatsky
2017-06-30 13:16               ` Petr Mladek
2017-06-30 13:38                 ` Sergey Senozhatsky
2017-07-03 11:11                   ` Sergey Senozhatsky
2017-07-02 20:27                     ` Pavel Machek
2017-07-05 16:36                       ` Sergey Senozhatsky
2017-07-03 19:34                     ` Steven Rostedt
2017-07-04  5:26                       ` Sergey Senozhatsky
2017-07-04  6:53                         ` Sergey Senozhatsky
2017-06-30 14:10                 ` Sergey Senozhatsky
2017-06-30 11:54             ` Petr Mladek
2017-06-30 12:42               ` Sergey Senozhatsky [this message]
2017-06-30 13:33                 ` Steven Rostedt
2017-06-30 14:28                   ` Sergey Senozhatsky
2017-06-30 14:45                     ` Steven Rostedt
2017-07-01  1:50                       ` Sergey Senozhatsky
2017-07-04 14:03                 ` Petr Mladek
2017-07-05  5:02                   ` Sergey Senozhatsky
2017-05-09  8:28 ` [RFC][PATCHv3 3/5] printk: add enforce_emergency parameter Sergey Senozhatsky
2017-05-09  8:28 ` [RFC][PATCHv3 4/5] printk: enable printk offloading Sergey Senozhatsky
2017-05-09  8:28 ` [RFC][PATCHv3 5/5] printk: register PM notifier Sergey Senozhatsky
2017-05-30  9:55   ` Petr Mladek
2017-05-31  6:42     ` Sergey Senozhatsky
2017-06-27 14:45       ` Petr Mladek

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=20170630124224.GA792@jagdpanzerIV.localdomain \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@lisas.de \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rjw@rjwysocki.net \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@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.