All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH -next] pstore: replace spin_lock with spin_trylock_irqsave in panic path
@ 2011-09-27 17:14 Seiji Aguchi
  2011-09-27 17:34 ` Don Zickus
  0 siblings, 1 reply; 10+ messages in thread
From: Seiji Aguchi @ 2011-09-27 17:14 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org, Vivek Goyal, Matthew Garrett,
	tony.luck@intel.com, dzickus@redhat.com, gong.chen@intel.com,
	Andrew Morton
  Cc: dle-develop@lists.sourceforge.net, Satoru Moriya

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.

[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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-09-28 22:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-27 17:14 [RFC][PATCH -next] pstore: replace spin_lock with spin_trylock_irqsave in panic path Seiji Aguchi
2011-09-27 17:34 ` Don Zickus
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.