From: "Paul E. McKenney" <paulmck@kernel.org> To: Petr Mladek <pmladek@suse.com> Cc: John Ogness <john.ogness@linutronix.de>, Sergey Senozhatsky <senozhatsky@chromium.org>, Steven Rostedt <rostedt@goodmis.org>, frederic@kernel.org, Peter Geis <pgwipeout@gmail.com>, zhouzhouyi@gmail.com, dave@stgolabs.net, josh@joshtriplett.org, Linus Torvalds <torvalds@linux-foundation.org>, rcu@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/2] printk: Prevent printk kthreads from blocking direct console handling Date: Wed, 15 Jun 2022 10:10:42 -0700 [thread overview] Message-ID: <20220615171042.GT1790663@paulmck-ThinkPad-P17-Gen-1> (raw) In-Reply-To: <20220615162805.27962-1-pmladek@suse.com> On Wed, Jun 15, 2022 at 06:28:03PM +0200, Petr Mladek wrote: > There are reports that console kthreads prevented printing > messages during panic() or shutdown(), see > BugLink: https://lore.kernel.org/r/20220610205038.GA3050413@paulmck-ThinkPad-P17-Gen-1 > BugLink: https://lore.kernel.org/r/CAMdYzYpF4FNTBPZsEFeWRuEwSies36QM_As8osPWZSr2q-viEA@mail.gmail.com > > In both situations, printk() correctly tries to flush the consoles > directly but it fails to get the global console_lock(). Both > problems went away with these patches: > > 1st patch blocks console kthreads so that they do not start > handling new messages when the direct printing is preferred > by the system state. It is probably enough on its own. It > solves the problem when the kthreads actively did > the wrong thing. > > 2nd patch allows to wait for the console kthreads to release > the lock in any context. It should make it more reliable. > It would have been useful even for the legacy code. Thank you! For the series: Tested-by: Paul E. McKenney <paulmck@kernel.org> > More possible improvements: > > + the waiting might be necessary also in the suspend code paths > > + convert con->mutex to con->spinlock to avoid blocking > the global console_lock() when sleeping with con->lock > > + at least disable preemption around console_emit_next_record() > in console kthread to avoid sleeping in the console driver > code > > + somehow change the priority of the kthread so that it gets > scheduled immediately when the scheduler works > > Petr Mladek (2): > printk: Block console kthreads when direct printing will be required > printk: Wait for the global console lock when the system is going down > > include/linux/printk.h | 5 +++++ > kernel/panic.c | 2 ++ > kernel/printk/internal.h | 2 ++ > kernel/printk/printk.c | 8 +++++++- > kernel/printk/printk_safe.c | 32 ++++++++++++++++++++++++++++++++ > kernel/reboot.c | 2 ++ > 6 files changed, 50 insertions(+), 1 deletion(-) > > -- > 2.35.3 >
WARNING: multiple messages have this Message-ID (diff)
From: "Paul E. McKenney" <paulmck@kernel.org> To: Petr Mladek <pmladek@suse.com> Cc: John Ogness <john.ogness@linutronix.de>, Sergey Senozhatsky <senozhatsky@chromium.org>, Steven Rostedt <rostedt@goodmis.org>, frederic@kernel.org, Peter Geis <pgwipeout@gmail.com>, zhouzhouyi@gmail.com, dave@stgolabs.net, josh@joshtriplett.org, Linus Torvalds <torvalds@linux-foundation.org>, rcu@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/2] printk: Prevent printk kthreads from blocking direct console handling Date: Wed, 15 Jun 2022 10:10:42 -0700 [thread overview] Message-ID: <20220615171042.GT1790663@paulmck-ThinkPad-P17-Gen-1> (raw) In-Reply-To: <20220615162805.27962-1-pmladek@suse.com> On Wed, Jun 15, 2022 at 06:28:03PM +0200, Petr Mladek wrote: > There are reports that console kthreads prevented printing > messages during panic() or shutdown(), see > BugLink: https://lore.kernel.org/r/20220610205038.GA3050413@paulmck-ThinkPad-P17-Gen-1 > BugLink: https://lore.kernel.org/r/CAMdYzYpF4FNTBPZsEFeWRuEwSies36QM_As8osPWZSr2q-viEA@mail.gmail.com > > In both situations, printk() correctly tries to flush the consoles > directly but it fails to get the global console_lock(). Both > problems went away with these patches: > > 1st patch blocks console kthreads so that they do not start > handling new messages when the direct printing is preferred > by the system state. It is probably enough on its own. It > solves the problem when the kthreads actively did > the wrong thing. > > 2nd patch allows to wait for the console kthreads to release > the lock in any context. It should make it more reliable. > It would have been useful even for the legacy code. Thank you! For the series: Tested-by: Paul E. McKenney <paulmck@kernel.org> > More possible improvements: > > + the waiting might be necessary also in the suspend code paths > > + convert con->mutex to con->spinlock to avoid blocking > the global console_lock() when sleeping with con->lock > > + at least disable preemption around console_emit_next_record() > in console kthread to avoid sleeping in the console driver > code > > + somehow change the priority of the kthread so that it gets > scheduled immediately when the scheduler works > > Petr Mladek (2): > printk: Block console kthreads when direct printing will be required > printk: Wait for the global console lock when the system is going down > > include/linux/printk.h | 5 +++++ > kernel/panic.c | 2 ++ > kernel/printk/internal.h | 2 ++ > kernel/printk/printk.c | 8 +++++++- > kernel/printk/printk_safe.c | 32 ++++++++++++++++++++++++++++++++ > kernel/reboot.c | 2 ++ > 6 files changed, 50 insertions(+), 1 deletion(-) > > -- > 2.35.3 > _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2022-06-15 17:10 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-15 16:28 [PATCH 0/2] printk: Prevent printk kthreads from blocking direct console handling Petr Mladek 2022-06-15 16:28 ` Petr Mladek 2022-06-15 16:28 ` [PATCH 1/2] printk: Block console kthreads when direct printing will be required Petr Mladek 2022-06-15 16:28 ` Petr Mladek 2022-06-15 17:47 ` Linus Torvalds 2022-06-15 17:47 ` Linus Torvalds 2022-06-15 19:20 ` Petr Mladek 2022-06-15 19:20 ` Petr Mladek 2022-06-15 16:28 ` [PATCH 2/2] printk: Wait for the global console lock when the system is going down Petr Mladek 2022-06-15 16:28 ` Petr Mladek 2022-06-15 17:10 ` Paul E. McKenney [this message] 2022-06-15 17:10 ` [PATCH 0/2] printk: Prevent printk kthreads from blocking direct console handling Paul E. McKenney 2022-06-15 20:09 ` Petr Mladek 2022-06-15 20:09 ` 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=20220615171042.GT1790663@paulmck-ThinkPad-P17-Gen-1 \ --to=paulmck@kernel.org \ --cc=dave@stgolabs.net \ --cc=frederic@kernel.org \ --cc=john.ogness@linutronix.de \ --cc=josh@joshtriplett.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-rockchip@lists.infradead.org \ --cc=pgwipeout@gmail.com \ --cc=pmladek@suse.com \ --cc=rcu@vger.kernel.org \ --cc=rostedt@goodmis.org \ --cc=senozhatsky@chromium.org \ --cc=torvalds@linux-foundation.org \ --cc=zhouzhouyi@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: linkBe 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.