From: Andrew Morton <akpm@linux-foundation.org>
To: Derek Basehore <dbasehore@chromium.org>
Cc: linux-kernel@vger.kernel.org, Joe Perches <joe@perches.com>,
Petr Mladek <pmladek@suse.cz>, Arun KS <arunks.linux@gmail.com>,
Kees Cook <keescook@chromium.org>,
Sonny Rao <sonnyrao@chromium.org>, Jan Kara <jack@suse.cz>
Subject: Re: [PATCH] Fix lockup on panic with lockdep
Date: Tue, 13 May 2014 13:29:58 -0700 [thread overview]
Message-ID: <20140513132958.e9a0bcee461e375b90ce7bbd@linux-foundation.org> (raw)
In-Reply-To: <1399941714-20145-1-git-send-email-dbasehore@chromium.org>
On Mon, 12 May 2014 17:41:54 -0700 Derek Basehore <dbasehore@chromium.org> wrote:
> If we don't call mutex_acquire at the beginning of console_unblank, we can run
> into a lockup on the logbuf_lock between console_unlock and printk during panic.
> What happens in console_unlock is:
>
> -locks logbuf_lock
> -calls mutex_release
> -which calls printk
> -which locks logbuf_lock
>
> This fixes the problem by calling console_trylock (which calls mutex_acquire)
> instead of directly accessing the semaphore in console_unblank and moves the
> mutex_release to after we unlock logbuf_lock in console_unlock (interrupts are
> still disabled).
Please take a look at linux-next, where this code has changed a lot.
> index 7228258..c599ab5 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2084,7 +2084,6 @@ skip:
> local_irq_restore(flags);
> }
> console_locked = 0;
> - mutex_release(&console_lock_dep_map, 1, _RET_IP_);
>
> /* Release the exclusive_console once it is used */
> if (unlikely(exclusive_console))
> @@ -2092,6 +2091,7 @@ skip:
>
> raw_spin_unlock(&logbuf_lock);
>
> + mutex_release(&console_lock_dep_map, 1, _RET_IP_);
> up(&console_sem);
>
> /*
> @@ -2137,7 +2137,7 @@ void console_unblank(void)
> * oops_in_progress is set to 1..
> */
> if (oops_in_progress) {
> - if (down_trylock(&console_sem) != 0)
> + if (!console_trylock())
> return;
> } else
> console_lock();
Although the code is quite different, an equivalent change appears to
have been made already. I'm not sure that bugfix was intentional ;)
next prev parent reply other threads:[~2014-05-13 20:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-13 0:41 Derek Basehore
2014-05-13 20:29 ` Andrew Morton [this message]
2014-05-13 23:11 ` Jan Kara
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=20140513132958.e9a0bcee461e375b90ce7bbd@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=arunks.linux@gmail.com \
--cc=dbasehore@chromium.org \
--cc=jack@suse.cz \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.cz \
--cc=sonnyrao@chromium.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®