From: Don Zickus <dzickus@redhat.com>
To: Seiji Aguchi <seiji.aguchi@hds.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Vivek Goyal <vgoyal@redhat.com>, Matthew Garrett <mjg@redhat.com>,
"tony.luck@intel.com" <tony.luck@intel.com>,
"gong.chen@intel.com" <gong.chen@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
"dle-develop@lists.sourceforge.net"
<dle-develop@lists.sourceforge.net>,
Satoru Moriya <satoru.moriya@hds.com>
Subject: Re: [RFC][PATCH -next] pstore: replace spin_lock with spin_trylock_irqsave in panic path
Date: Tue, 27 Sep 2011 13:34:13 -0400 [thread overview]
Message-ID: <20110927173413.GJ5795@redhat.com> (raw)
In-Reply-To: <5C4C569E8A4B9B42A84A977CF070A35B2C56C9B823@USINDEVS01.corp.hds.com>
On Tue, Sep 27, 2011 at 01:14:59PM -0400, Seiji Aguchi wrote:
> Hi,
>
> [Problem]
> Currently, pstore takes spin_trylock(&psinfo->buf_lock) in NMI context.
> And it takes spin_lock(&psinfo->buf_lock) in other cases.
>
> If there are some bugs in pstore and kernel panics, spin_lock(&psinfo->buf_lock) causes deadlock
> and panic_notifier_chain will not work.
Ok, so I missed your 'return' first time through and originally had a
bunch of comments. So I would suggest adding a comment explaining why we
are returning in that failure.
Personally, I am not sure we want to abort here at the pstore layer, it
should probably be aborted lower. There isn't any reason why we can't
continue from a pstore perspective (we can just bust the spinlock).
>From an ERST perspective, the state machine might be screwed up, hence
aborting in that layer could make sense. But I don't think I agree with
the 'return' statement.
So I am opposed to it for now.
Cheers,
Don
>
> [Patch Description]
> For solving this problem, this patch replaces spin_lock with spin_trylock_irqsave in panic path.
>
> Dead lock in panic path will not happen by applying this patch.
>
> Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
>
> ---
> fs/pstore/platform.c | 17 ++++++++---------
> 1 files changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 0472924..9882892 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -97,12 +97,15 @@ static void pstore_dump(struct kmsg_dumper *dumper,
> else
> why = "Unknown";
>
> - if (in_nmi()) {
> - is_locked = spin_trylock(&psinfo->buf_lock);
> - if (!is_locked)
> - pr_err("pstore dump routine blocked in NMI, may corrupt error record\n");
> + if (reason == KMSG_DUMP_PANIC) {
> + is_locked = spin_trylock_irqsave(&psinfo->buf_lock, flags);
> + if (!is_locked) {
> + pr_err("pstore dump routine skipped in panic path\n");
> + return;
> + }
> } else
> spin_lock_irqsave(&psinfo->buf_lock, flags);
> +
> oopscount++;
> while (total < kmsg_bytes) {
> dst = psinfo->buf;
> @@ -131,11 +134,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
> total += l1_cpy + l2_cpy;
> part++;
> }
> - if (in_nmi()) {
> - if (is_locked)
> - spin_unlock(&psinfo->buf_lock);
> - } else
> - spin_unlock_irqrestore(&psinfo->buf_lock, flags);
> + spin_unlock_irqrestore(&psinfo->buf_lock, flags);
> }
>
> static struct kmsg_dumper pstore_dumper = {
> --
> 1.7.1
>
next prev parent reply other threads:[~2011-09-27 17:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-27 17:14 Seiji Aguchi
2011-09-27 17:34 ` Don Zickus [this message]
2011-09-27 17:46 ` Luck, Tony
2011-09-27 17:59 ` Don Zickus
2011-09-27 19:02 ` Luck, Tony
2011-09-27 19:46 ` Seiji Aguchi
2011-09-28 14:09 ` Don Zickus
2011-09-28 18:55 ` Seiji Aguchi
2011-09-28 13:57 ` Don Zickus
2011-09-28 22:30 ` Luck, Tony
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=20110927173413.GJ5795@redhat.com \
--to=dzickus@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dle-develop@lists.sourceforge.net \
--cc=gong.chen@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mjg@redhat.com \
--cc=satoru.moriya@hds.com \
--cc=seiji.aguchi@hds.com \
--cc=tony.luck@intel.com \
--cc=vgoyal@redhat.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
all inboxes | Powered by JetHome®