linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anton Vorontsov <anton.vorontsov@linaro.org>
To: Chuansheng Liu <chuansheng.liu@intel.com>
Cc: gregkh@linuxfoundation.org, keescook@chromium.org,
	tony.luck@intel.com, linux-kernel@vger.kernel.org,
	Colin Cross <ccross@android.com>
Subject: Re: [PATCH] pstore: avoid recursive spinlocks in the oops_in_progress case
Date: Thu, 20 Sep 2012 15:57:28 -0700	[thread overview]
Message-ID: <20120920225727.GD29721@lizard> (raw)
In-Reply-To: <1347903824.29767.15.camel@cliu38-desktop-build>

On Tue, Sep 18, 2012 at 01:43:44AM +0800, Chuansheng Liu wrote:
> Like 8250 driver, when pstore is registered as a console,
> to avoid recursive spinlocks when panic happening, change the
> spin_lock_irqsave to spin_trylock_irqsave when oops_in_progress
> is true.
> 
> Signed-off-by: liu chuansheng <chuansheng.liu@intel.com>
> ---
>  fs/pstore/platform.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
> index 29996e8..cbcb5fc 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -164,7 +164,12 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
>  
>  		if (c > psinfo->bufsize)
>  			c = psinfo->bufsize;
> -		spin_lock_irqsave(&psinfo->buf_lock, flags);
> +
> +		if (oops_in_progress) {
> +			if (!spin_trylock_irqsave(&psinfo->buf_lock, flags))
> +				break;

Mm... why break?

Like 8250, in this case it's better still log the console.
That is, something along these lines:

bool locked = 1;

if (oops_in_progress)
	locked = spin_trylock_irqsave(&psinfo->buf_lock, flags);
else
	spin_lock_irqsave(&psinfo->buf_lock, flags);

memcpy(psinfo->buf, s, c);
psinfo->write(PSTORE_TYPE_CONSOLE, 0, NULL, 0, c, psinfo);

if (locked)
	spin_unlock_irqrestore(&psinfo->buf_lock, flags);


Thanks,

Anton.

> +		} else
> +			spin_lock_irqsave(&psinfo->buf_lock, flags);
>  		memcpy(psinfo->buf, s, c);
>  		psinfo->write(PSTORE_TYPE_CONSOLE, 0, NULL, 0, c, psinfo);
>  		spin_unlock_irqrestore(&psinfo->buf_lock, flags);
> -- 
> 1.7.0.4

  reply	other threads:[~2012-09-20 23:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-17 17:43 [PATCH] pstore: avoid recursive spinlocks in the oops_in_progress case Chuansheng Liu
2012-09-20 22:57 ` Anton Vorontsov [this message]
2012-09-20 23:09   ` Luck, Tony
2012-09-20 23:25     ` Anton Vorontsov
2012-09-20 23:48       ` Luck, Tony
2012-09-21  0:37         ` Anton Vorontsov
2012-09-24 15:02           ` Luck, Tony
2012-09-26 23:35             ` Anton Vorontsov

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=20120920225727.GD29721@lizard \
    --to=anton.vorontsov@linaro.org \
    --cc=ccross@android.com \
    --cc=chuansheng.liu@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.com \
    /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).