linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Byungchul Park <byungchul.park@lge.com>
Cc: akpm@linux-foundation.org, mingo@kernel.org,
	linux-kernel@vger.kernel.org, akinobu.mita@gmail.com,
	jack@suse.cz, sergey.senozhatsky.work@gmail.com,
	peter@hurleysoftware.com, torvalds@linux-foundation.org
Subject: Re: [PATCH v5] lib/spinlock_debug.c: prevent a recursive cycle in the debug code
Date: Mon, 1 Feb 2016 11:31:12 +0900	[thread overview]
Message-ID: <20160201023112.GC1033@swordfish> (raw)
In-Reply-To: <1454071417-20685-1-git-send-email-byungchul.park@lge.com>

On (01/29/16 21:43), Byungchul Park wrote:
[..]
> +extern int is_console_lock(raw_spinlock_t *lock);
> +
>  static void __spin_lock_debug(raw_spinlock_t *lock)
>  {
>  	u64 i;
> @@ -113,11 +115,19 @@ static void __spin_lock_debug(raw_spinlock_t *lock)
>  			return;
>  		__delay(1);
>  	}
> -	/* lockup suspected: */
> -	spin_dump(lock, "lockup suspected");
> +
> +	/*
> +	 * If this function is called from printk(), then we should
> +	 * not call printk() more. Or it will cause an infinite
> +	 * recursive cycle!
> +	 */
> +	if (likely(!is_console_lock(lock))) {
> +		/* lockup suspected: */
> +		spin_dump(lock, "lockup suspected");
>  #ifdef CONFIG_SMP
> -	trigger_all_cpu_backtrace();
> +		trigger_all_cpu_backtrace();
>  #endif
> +	}

/* speaking in a context of printk locks only */

... may be for a recoverable "lockup suspected" spin_dump()
we can switch to deferred printk of the messages, which is a
bit better than nothing. but for unrecoverable "lockup suspected"
spin_dump() -- an actual bug (spin lock owner is not going to
release the lock any more) -- we need something else, I think.
the bug will neither be reported nor fixed.

	-ss

>  	/*
>  	 * The trylock above was causing a livelock.  Give the lower level arch
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 2ce8826..568ab11 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1981,6 +1981,11 @@ asmlinkage __visible void early_printk(const char *fmt, ...)
>  }
>  #endif
>  
> +int is_console_lock(raw_spinlock_t *lock)
> +{
> +	return lock == &console_sem.lock;
> +}
> +
>  static int __add_preferred_console(char *name, int idx, char *options,
>  				   char *brl_options)
>  {
> -- 
> 1.9.1
> 

  parent reply	other threads:[~2016-02-01  2:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-29 12:43 [PATCH v5] lib/spinlock_debug.c: prevent a recursive cycle in the debug code Byungchul Park
2016-01-29 12:54 ` Byungchul Park
2016-01-31 12:40   ` Sergey Senozhatsky
2016-02-01  1:45     ` Byungchul Park
2016-02-01  2:13       ` Sergey Senozhatsky
2016-01-30  9:27 ` Ingo Molnar
2016-02-02  2:34   ` Byungchul Park
2016-02-01  2:31 ` Sergey Senozhatsky [this message]
2016-02-01  6:28   ` Byungchul Park

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=20160201023112.GC1033@swordfish \
    --to=sergey.senozhatsky.work@gmail.com \
    --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=mingo@kernel.org \
    --cc=peter@hurleysoftware.com \
    --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;
as well as URLs for NNTP newsgroup(s).