From: Petr Mladek <pmladek@suse.com>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Luo Jiaxing <luojiaxing@huawei.com>,
sergey.senozhatsky@gmail.com, rostedt@goodmis.org,
john.ogness@linutronix.de, linux-kernel@vger.kernel.org,
linuxarm@huawei.com, bobo.shaobowang@huawei.com
Subject: Re: [PATCH] printk: stop spining waiter when console resume to flush prb
Date: Fri, 7 May 2021 18:36:16 +0200 [thread overview]
Message-ID: <YJVsgPc66lhaAUN0@alley> (raw)
In-Reply-To: <YJP5MnkJ8pJevXM6@google.com>
On Thu 2021-05-06 23:12:02, Sergey Senozhatsky wrote:
> On (21/05/06 23:07), Sergey Senozhatsky wrote:
> >
> > Can we count the number of lines that we print from the `current` context
> > in console_unlock() and if after N messages there is no console_lock waiter
> > waiting for the `current` to handover console lock ownership, then create
> > one: schedule IRQ work that will become a console lock owner, spin on
> > console lock and call console_unlock() once it acquired the ownership.
> > That 'artificial' console lock owner will do the same - print N
> > messages, if nothing wants to become a console lock owner then it'll
> > queue another IRQ work.
>
> Or even simpler
>
> console_unlock()
> {
> ...
>
> if (printed_messages > limit && !console_lock_spinning_disable_and_check()) {
> printk_safe_exit_irqrestore(flags);
>
> console_locked = 0;
> up_console_sem();
>
> defer_console_output();
> return;
> }
>
> ...
> }
No, please, no.
This is exactly the opposite. The original patch tried to keep the
work in the preemtible context. This proposal moves the work into irq
context which is bad. Not to say, that defer_console_output() would
trigger IRQ on the same CPU again and again.
All the problems with printk() are that we try to support all
scenarios. But it simply does not work. We need to say that some
situations are not supported.
Flood of messages and slow console requires a miracle. The only chance
is a huge buffer and get them out later. Infinite flood of messages
is impossible to handle by definition.
I hope that we agreed that the priority is to keep printk() safe
and do not break the system. The ultimate solution is to handle
consoles in a separate preemtible context (kthread).
There should be atomic consoles for those who want to see the messages
immediately with the cost of slowing down the code doing the real job.
I do not have strong opinion whether the proposed patch is worth it.
It is just another compromise that might be better in some situations
and worse in others.
Well, this situation is special. There might be many accumulated
messages during the hibernation. They did not have any chance to
be handled by more CPUs. Using the well known preemtible context
sounds slightly better than risking a random victim in atomic
context.
Anyway, I am fine with discarding this patch and focusing on
the offload to kthreads.
Best Regards,
Petr
next prev parent reply other threads:[~2021-05-07 16:36 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-06 8:00 Luo Jiaxing
2021-05-06 13:13 ` Steven Rostedt
2021-05-07 8:35 ` luojiaxing
2021-05-06 13:39 ` Petr Mladek
2021-05-06 14:07 ` Sergey Senozhatsky
2021-05-06 14:12 ` Sergey Senozhatsky
2021-05-06 15:14 ` John Ogness
2021-05-07 7:58 ` luojiaxing
2021-05-07 7:33 ` luojiaxing
2021-05-07 7:49 ` Sergey Senozhatsky
2021-05-07 16:36 ` Petr Mladek [this message]
2021-05-10 8:26 ` Sergey Senozhatsky
2021-05-10 10:17 ` Petr Mladek
2021-05-10 10:32 ` John Ogness
2021-05-10 11:16 ` Sergey Senozhatsky
2021-05-10 11:43 ` Sergey Senozhatsky
2021-05-07 16:13 ` Petr Mladek
2021-05-10 8:29 ` luojiaxing
2021-05-10 9:50 ` Petr Mladek
2021-05-10 12:06 ` Sergey Senozhatsky
2021-05-10 7:41 ` luojiaxing
2021-05-10 9:30 ` Petr Mladek
2021-05-11 7:32 ` luojiaxing
2021-05-11 9:08 ` Petr Mladek
2021-05-13 7:55 ` luojiaxing
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=YJVsgPc66lhaAUN0@alley \
--to=pmladek@suse.com \
--cc=bobo.shaobowang@huawei.com \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=luojiaxing@huawei.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®