From: "Luck, Tony" <tony.luck@intel.com>
To: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Cc: linux-kernel@vger.kernel.org, Seiji Aguchi <seiji.aguchi@hds.com>,
David Woodhouse <dwmw2@infradead.org>,
Marco Stornelli <marco.stornelli@gmail.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [RFC] pstore: Don't use persistent store for normal shutdown
Date: Tue, 22 Mar 2011 12:55:53 -0700 [thread overview]
Message-ID: <4d88fec9598644f42@agluck-desktop.sc.intel.com> (raw)
In-Reply-To: <1300783365.2735.12.camel@localhost>
From: Tony Luck <tony.luck@intel.com>
pstore_dump() can be called with many different "reason" codes. Save
the name of the code in the persistent store record.
Also - only worthwhile calling pstore_mkfile for KMSG_DUMP_OOPS - that
is the only one where the kernel will continue running.
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
Artem Bityutskiy said:
> If you ask me, this smells like policy in the kernel. I'd look into the
> direction of having only the mechanisms in the kernel and letting the
> user-space making policy decisions by choosing what he wants to filter
> out and what he wants to store via some pstore interfaces.
Perhaps I'll just leave all the policy out then and keep logging
the same for all dmesg reason codes. Seiji Aguchi sounded quite
lukewarm to the idea of logging less for shutdown/restart etc.
Providing an option that lets the user ask pstore to filter away
the restart/shutdown logs would defeat the purpose for which these
reason codes were added - providing a neat trail that simple tools
can use to show that a system rebooted because some root process
issued a reboot(2) syscall.
Here's a simpler clean up of the fs/pstore/platform.c code that
makes sure that we log a meaningful string for each reason code
(rather than "Oops"!) and that only tries to add an entry to the
mounted filesystem for the KMSG_TYPE_OOPS case (since that is the
only case where the system stays up for some process to see it).
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index ce9ad84..f835a25 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -48,6 +48,10 @@ void pstore_set_kmsg_bytes(int bytes)
/* Tag each group of saved records with a sequence number */
static int oopscount;
+static char *reason_str[] = {
+ "Oops", "Panic", "Kexec", "Restart", "Halt", "Poweroff", "Emergency"
+};
+
/*
* callback from kmsg_dump. (s2,l2) has the most recently
* written bytes, older bytes are in (s1,l1). Save as much
@@ -61,15 +65,20 @@ static void pstore_dump(struct kmsg_dumper *dumper,
unsigned long s1_start, s2_start;
unsigned long l1_cpy, l2_cpy;
unsigned long size, total = 0;
- char *dst;
+ char *dst, *why;
u64 id;
int hsize, part = 1;
+ if (reason < ARRAY_SIZE(reason_str))
+ why = reason_str[reason];
+ else
+ why = "Unknown";
+
mutex_lock(&psinfo->buf_mutex);
oopscount++;
while (total < kmsg_bytes) {
dst = psinfo->buf;
- hsize = sprintf(dst, "Oops#%d Part%d\n", oopscount, part++);
+ hsize = sprintf(dst, "%s#%d Part%d\n", why, oopscount, part++);
size = psinfo->bufsize - hsize;
dst += hsize;
@@ -86,7 +95,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy);
id = psinfo->write(PSTORE_TYPE_DMESG, hsize + l1_cpy + l2_cpy);
- if (pstore_is_mounted())
+ if (reason == KMSG_DUMP_OOPS && pstore_is_mounted())
pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id,
psinfo->buf, hsize + l1_cpy + l2_cpy,
CURRENT_TIME, psinfo->erase);
next prev parent reply other threads:[~2011-03-22 19:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-21 18:24 [RFC] pstore: Don't use persistent store for normal shutdown Luck, Tony
2011-03-21 19:49 ` Seiji Aguchi
2011-03-21 20:27 ` Tony Luck
2011-03-21 21:47 ` Seiji Aguchi
2011-03-21 22:01 ` Tony Luck
2011-03-22 8:42 ` Artem Bityutskiy
2011-03-22 8:54 ` Américo Wang
2011-03-22 19:55 ` Luck, Tony [this message]
2011-03-22 22:17 ` Seiji Aguchi
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=4d88fec9598644f42@agluck-desktop.sc.intel.com \
--to=tony.luck@intel.com \
--cc=Artem.Bityutskiy@nokia.com \
--cc=akpm@linux-foundation.org \
--cc=dwmw2@infradead.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marco.stornelli@gmail.com \
--cc=seiji.aguchi@hds.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