From: Ingo Molnar <mingo@kernel.org>
To: Byungchul Park <byungchul.park@lge.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
akinobu.mita@gmail.com, jack@suse.cz,
torvalds@linux-foundation.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [PATCH] lib/spinlock_debug.c: prevent deadlock in spin_dump() by console_sem
Date: Fri, 15 Jan 2016 10:30:50 +0100 [thread overview]
Message-ID: <20160115093050.GA22063@gmail.com> (raw)
In-Reply-To: <1452849881-27982-1-git-send-email-byungchul.park@lge.com>
* Byungchul Park <byungchul.park@lge.com> wrote:
> Deadlock occured when using CONFIG_DEBUG_SPINLOCK, in spin_dump().
> Backtrace prints printk() -> console_trylock() -> do_raw_spin_lock() ->
> spin_dump() -> printk()... infinitely.
>
> If spin_bug() is called from a function like printk() which is using
> console lock, we should prevent the debug spinlock code from calling
> printk() any more in the context.
>
> Signed-off-by: Byungchul Park <byungchul.park@lge.com>
> ---
> kernel/locking/spinlock_debug.c | 10 ++++++++++
> kernel/printk/printk.c | 5 +++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/kernel/locking/spinlock_debug.c b/kernel/locking/spinlock_debug.c
> index 0374a59..b339c5e 100644
> --- a/kernel/locking/spinlock_debug.c
> +++ b/kernel/locking/spinlock_debug.c
> @@ -67,11 +67,21 @@ static void spin_dump(raw_spinlock_t *lock, const char *msg)
> dump_stack();
> }
>
> +extern int is_console_lock(raw_spinlock_t *lock);
> +
> static void spin_bug(raw_spinlock_t *lock, const char *msg)
> {
> if (!debug_locks_off())
> return;
>
> + /*
> + * If this function is called from a function like printk()
> + * which is trying console lock, we cannot call printk() any
> + * more. Or it's obviously deadlock!
Small spelling nit, the last sentence is not correct, pick one of these variants:
'It's an obvious deadlock.'
'It's obviously a deadlock.'
Thanks,
Ingo
prev parent reply other threads:[~2016-01-15 9:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-15 9:24 Byungchul Park
2016-01-15 9:30 ` Ingo Molnar [this message]
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=20160115093050.GA22063@gmail.com \
--to=mingo@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=byungchul.park@lge.com \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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
Powered by JetHome