From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Seiji Aguchi <seiji.aguchi@hds.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Chen, Gong" <gong.chen@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Luck, Tony" <tony.luck@intel.com>,
Matthew Garrett <mjg@redhat.com>, Vivek Goyal <vgoyal@redhat.com>,
"len.brown@intel.com" <len.brown@intel.com>,
"ying.huang@intel.com" <ying.huang@intel.com>,
"ak@linux.intel.com" <ak@linux.intel.com>,
"hughd@chromium.org" <hughd@chromium.org>,
"mingo@elte.hu" <mingo@elte.hu>,
"jmorris@namei.org" <jmorris@namei.org>,
"namhyung@gmail.com" <namhyung@gmail.com>,
Don Zickus <dzickus@redhat.com>,
"dle-develop@lists.sourceforge.net"
<dle-develop@lists.sourceforge.net>,
Satoru Moriya <satoru.moriya@hds.com>
Subject: Re: [RFC][PATCH v2 -next 2/2] Adding lock operations to kmsg_dump()/pstore_dump()
Date: Thu, 10 Nov 2011 13:50:25 +0100 [thread overview]
Message-ID: <1320929425.13800.12.camel@twins> (raw)
In-Reply-To: <5C4C569E8A4B9B42A84A977CF070A35B2C576122A9@USINDEVS01.corp.hds.com>
On Fri, 2011-10-21 at 17:21 -0400, Seiji Aguchi wrote:
> +++ b/fs/pstore/platform.c
> @@ -97,6 +97,17 @@ static void pstore_dump(struct kmsg_dumper *dumper,
> else
> why = "Unknown";
>
> + /*
> + * pstore_dump() is called after smp_send_stop() in panic path.
> + * So, spin_lock should be bust for avoiding deadlock.
> + */
> + if (reason == KMSG_DUMP_PANIC)
> + spin_lock_init(&psinfo->buf_lock);
> +
> + /*
> + * While a cpu is in NMI handler, other cpus may be running.
> + * So, trylock should be called so that lockdep checking works.
> + */
Don't be silly, lockdep doesn't cover NMI, in fact you shouldn't use
locks from NMI context ever.
> if (in_nmi()) {
> is_locked = spin_trylock(&psinfo->buf_lock);
> if (!is_locked)
> diff --git a/kernel/printk.c b/kernel/printk.c
> index 1455a0d..f51f547 100644
> --- a/kernel/printk.c
> +++ b/kernel/printk.c
> @@ -1730,15 +1730,37 @@ void kmsg_dump(enum kmsg_dump_reason reason)
> struct kmsg_dumper *dumper;
> const char *s1, *s2;
> unsigned long l1, l2;
> - unsigned long flags;
> + unsigned long flags = 0;
> + int is_locked = 0;
>
> /* Theoretically, the log could move on after we do this, but
> there's not a lot we can do about that. The new messages
> will overwrite the start of what we dump. */
> - raw_spin_lock_irqsave(&logbuf_lock, flags);
> +
> + /*
> + * kmsg_dump() is called after smp_send_stop() in panic path.
> + * So, spin_lock should be bust for avoiding deadlock.
> + */
> + if (reason == KMSG_DUMP_PANIC)
> + raw_spin_lock_init(&logbuf_lock);
In both cases where you bust the spinlock at least yell loudly and
disable lock debugging.
And I guess this is where Don wants to use NMIs for smp_send_stop() so
what you get around the fact that this lock you're busting disabled
IRQs?
All in all this patch is way ugly and doesn't make me feel all warm and
fuzzy.
next prev parent reply other threads:[~2011-11-10 12:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-21 21:21 [RFC][PATCH v2 -next 2/2] Adding lock operations to kmsg_dump()/pstore_dump() Seiji Aguchi
2011-10-28 18:33 ` Don Zickus
2011-10-28 19:02 ` Luck, Tony
2011-10-28 20:00 ` Don Zickus
2011-11-10 12:50 ` Peter Zijlstra [this message]
2011-11-10 13:33 ` Don Zickus
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=1320929425.13800.12.camel@twins \
--to=a.p.zijlstra@chello.nl \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=dle-develop@lists.sourceforge.net \
--cc=dzickus@redhat.com \
--cc=gong.chen@intel.com \
--cc=hughd@chromium.org \
--cc=jmorris@namei.org \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mjg@redhat.com \
--cc=namhyung@gmail.com \
--cc=satoru.moriya@hds.com \
--cc=seiji.aguchi@hds.com \
--cc=tony.luck@intel.com \
--cc=vgoyal@redhat.com \
--cc=ying.huang@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