mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Sultan Alsawaf <sultan@kerneltoast.com>,
	Anton Vorontsov <anton@enomsg.org>,
	Ben Segall <bsegall@google.com>, Colin Cross <ccross@android.com>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	David Airlie <airlied@linux.ie>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	dri-devel@lists.freedesktop.org, Ingo Molnar <mingo@redhat.com>,
	John Ogness <john.ogness@linutronix.de>,
	Juri Lelli <juri.lelli@redhat.com>,
	Kees Cook <keescook@chromium.org>,
	linux-kernel@vger.kernel.org,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>, Mel Gorman <mgorman@suse.de>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Tony Luck <tony.luck@intel.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	mkoutny@suse.com
Subject: Re: printk deadlock due to double lock attempt on current CPU's runqueue
Date: Thu, 11 Nov 2021 10:27:06 +0100	[thread overview]
Message-ID: <YYzh6rxX6tY8/d+L@alley> (raw)
In-Reply-To: <YYuS1uNhxWOEX1Ci@phenom.ffwll.local>

On Wed 2021-11-10 10:37:26, Daniel Vetter wrote:
> On Tue, Nov 09, 2021 at 10:38:47PM +0100, Peter Zijlstra wrote:
> > On Tue, Nov 09, 2021 at 12:06:48PM -0800, Sultan Alsawaf wrote:
> > > Hi,
> > > 
> > > I encountered a printk deadlock on 5.13 which appears to still affect the latest
> > > kernel. The deadlock occurs due to printk being used while having the current
 > > > CPU's runqueue locked, and the underlying framebuffer console attempting to lock
> > > the same runqueue when printk tries to flush the log buffer.
> > 
> > Yes, that's a known 'feature' of some consoles. printk() is in the
> > process of being reworked to not call con->write() from the printk()
> > calling context, which would go a long way towards fixing this.
> 
> And it's getting worse by the year:
> - direct scanout displays (i.e. just a few mmio writes and it will show
>   up) are on the way out at least in laptops, everyone gets self-refresh
>   (dp psr) under software control, so without being able to kick a kthread
>   off nothing shows up except more oopses

printk() tries to avoid this problem by waking processes via
irq_vork(). For example, it is used for waking userspace log
daemons, see wake_up_klogd().

There is one hidden wake_up_process() in up() of @console_sem.
It is "less" critical because it calls the wake_up() only when
there is another process waiting for console_lock(). It must
be a non-printk caller because printk() uses trylock and does
not add waiters. So, there is a non-trivial chance to avoid
the deadlock and the messages.

I wonder if fbdev might use the same trick.

> - because of the impendence mismatch between fbdev and drm-kms we even go
>   ever more this direction for dumb framebuffers, including the firmware
>   boot-up framebuffer simpledrm. This could perhaps be fixed with a new
>   dedicate console driver directly on top of drm-kms, but that's on the
>   wishlist for years and I don't see anyone typing that.
> 
> So yeah for fbcon at least I think we really should throw out direct
> con->write from printk completely.

Yup, that would be great.

Well, I guess that it would be available only for a panic mode when it
will not race with other users?

Best Regards,
Petr

  parent reply	other threads:[~2021-11-11  9:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09 20:06 Sultan Alsawaf
2021-11-09 21:38 ` Peter Zijlstra
2021-11-10  9:00   ` Vincent Guittot
2021-11-10 10:45     ` Michal Koutný
2021-11-10 19:50     ` Sultan Alsawaf
2021-11-12  7:50       ` Vincent Guittot
2021-11-10  9:37   ` Daniel Vetter
2021-11-10 10:07     ` John Ogness
2021-11-10 10:44       ` Daniel Vetter
2021-11-10 20:03       ` Sultan Alsawaf
2021-11-11  8:28         ` John Ogness
2021-11-11  9:27     ` Petr Mladek [this message]
2021-11-10 10:50 ` Petr Mladek
2021-11-10 11:20   ` Peter Zijlstra
2021-11-10 13:21     ` Daniel Vetter

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=YYzh6rxX6tY8/d+L@alley \
    --to=pmladek@suse.com \
    --cc=airlied@linux.ie \
    --cc=anton@enomsg.org \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=ccross@android.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=john.ogness@linutronix.de \
    --cc=juri.lelli@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=mkoutny@suse.com \
    --cc=mripard@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=sultan@kerneltoast.com \
    --cc=tony.luck@intel.com \
    --cc=tzimmermann@suse.de \
    --cc=vincent.guittot@linaro.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

all inboxes | Powered by JetHome®