Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1309993

Re: [PATCH] lib/spinlock_debug.c: prevent deadlock in spin_dump() by console_sem

From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH] lib/spinlock_debug.c: prevent deadlock in spin_dump() by console_sem
Date 2016-01-15 10:40 +0100
Message-ID <qR91o-49P-19@gated-at.bofh.it> (permalink)
References <qR8RJ-464-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* 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

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] lib/spinlock_debug.c: prevent deadlock in spin_dump() by console_sem Byungchul Park <byungchul.park@lge.com> - 2016-01-15 10:30 +0100
  Re: [PATCH] lib/spinlock_debug.c: prevent deadlock in spin_dump() by  console_sem Ingo Molnar <mingo@kernel.org> - 2016-01-15 10:40 +0100

csiph-web