From: Arjan van de Ven <arjan@linux.intel.com>
To: "Tony Luck" <tony.luck@intel.com>
Cc: "Ingo Molnar" <mingo@elte.hu>,
linux-kernel@vger.kernel.org,
"Andrew Morton" <akpm@linux-foundation.org>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
protasnb@gmail.com, tytso@thunk.org
Subject: Re: Top kernel oopses/warnings this week
Date: Mon, 17 Dec 2007 15:47:27 -0800 [thread overview]
Message-ID: <20071217154727.404e4bc4@laptopd505.fenrus.org> (raw)
In-Reply-To: <12c511ca0712171526h242a7de8vadec78cd48747bd@mail.gmail.com>
On Mon, 17 Dec 2007 15:26:46 -0800
"Tony Luck" <tony.luck@intel.com> wrote:
> On Dec 17, 2007 3:17 PM, Arjan van de Ven <arjan@linux.intel.com>
> wrote:
> >
> > Tony Luck wrote:
> > >> + static char target[80];
> > > ...
> > >> + sprintf(target,
> > >> "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
> > >> + "%02x%02x%02x%02x%02x%02x",
> > >
> > > [80] is overkill ... [37] bytes should be enough (unless I went
> > > cross-eyed counting the "%02x" :-)
> > >
> >
> > %02x doesn't guarantee that it's at most 2, but at LEAST 2...
>
> How will you fit a number that requires >2 hex digits into an
> "unsigned char"?
eh eh because at first it was a signed char but I fixed that bug later
updated patch attached; using 38 to have a hard 0 at the end in case sprintf does
something weird and 2 cpus race over oopsing (I don't want to add locking to the oops codepath
if I can avoid it; the worst case with 38 is a truncated UUID string)
Subject: [patch] terminate the oops printing with a defined string/uuid
From: Arjan van de Ven <arjan@linux.intel.com>
Right now, it's hard for automated tools to determine when an oops has
ended; there's no clear marker for this. In addition, there's no good
way to find out if an oops is unique. Sometimes it's the same oops
just reported multiple times, while other times it's a different
instance of the crash with the same signature. Printing the boot UUID
as part of the end string resolves this ambiguity.
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
drivers/char/random.c | 35 ++++++++++++++++++++++++++++++++++-
include/linux/random.h | 1 +
kernel/panic.c | 2 ++
3 files changed, 37 insertions(+), 1 deletion(-)
Index: linux-2.6.24-rc5/drivers/char/random.c
===================================================================
--- linux-2.6.24-rc5.orig/drivers/char/random.c
+++ linux-2.6.24-rc5/drivers/char/random.c
@@ -1176,8 +1176,41 @@ static int max_read_thresh = INPUT_POOL_
static int max_write_thresh = INPUT_POOL_WORDS * 32;
static char sysctl_bootid[16];
+/**
+ * get_boot_uuid - return a string pointer to a system wide boot UUID
+ *
+ * Returns a pointer to the boot UUID. This UUID is unique per system
+ * boot but persistent for one boot session.
+ *
+ * The memory returned via the return pointer is static allocated and
+ * owned by the random.c driver; this should not be kfree()'d.
+ *
+ * Locking: none
+ */
+ */
+char *get_boot_uuid(void)
+{
+ static char target[38];
+ unsigned char *uuid;
+
+ if (sysctl_bootid[8] == 0)
+ generate_random_uuid(sysctl_bootid);
+ /* sysctl_bootid is signed, to print we need unsigned .. */
+ uuid = sysctl_bootid;
+
+ if (target[0] == 0) {
+ sprintf(target, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
+ "%02x%02x%02x%02x%02x%02x",
+ uuid[0], uuid[1], uuid[2], uuid[3], uuid[4],
+ uuid[5], uuid[6], uuid[7], uuid[8], uuid[9],
+ uuid[10], uuid[11], uuid[12], uuid[13], uuid[14],
+ uuid[15]);
+ }
+ return target;
+}
+
/*
- * These functions is used to return both the bootid UUID, and random
+ * These functions are used to return both the bootid UUID, and random
* UUID. The difference is in whether table->data is NULL; if it is,
* then a new UUID is generated and returned to the user.
*
Index: linux-2.6.24-rc5/include/linux/random.h
===================================================================
--- linux-2.6.24-rc5.orig/include/linux/random.h
+++ linux-2.6.24-rc5/include/linux/random.h
@@ -71,6 +71,7 @@ unsigned long randomize_range(unsigned l
u32 random32(void);
void srandom32(u32 seed);
+char *get_boot_uuid(void);
#endif /* __KERNEL___ */
Index: linux-2.6.24-rc5/kernel/panic.c
===================================================================
--- linux-2.6.24-rc5.orig/kernel/panic.c
+++ linux-2.6.24-rc5/kernel/panic.c
@@ -19,6 +19,7 @@
#include <linux/nmi.h>
#include <linux/kexec.h>
#include <linux/debug_locks.h>
+#include <linux/random.h>
int panic_on_oops;
int tainted;
@@ -272,6 +273,7 @@ void oops_enter(void)
void oops_exit(void)
{
do_oops_enter_exit();
+ printk("---[ end of trace %s ]---\n", get_boot_uuid());
}
#ifdef CONFIG_CC_STACKPROTECTOR
next prev parent reply other threads:[~2007-12-17 23:47 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-14 18:46 Arjan van de Ven
2007-12-14 18:58 ` Dave Jones
2007-12-14 21:57 ` Andrew Morton
2007-12-14 22:25 ` Natalie Protasevich
2007-12-15 0:38 ` Arjan van de Ven
2007-12-14 22:12 ` Jon Masters
2007-12-15 15:49 ` Stefan Richter
2007-12-15 18:21 ` Arjan van de Ven
2007-12-15 19:44 ` Stefan Richter
2007-12-17 18:25 ` Zach Brown
2007-12-17 18:41 ` Arjan van de Ven
2007-12-17 2:51 ` Dave Jones
2007-12-17 12:33 ` Jon Masters
2007-12-17 13:13 ` Stefan Richter
2007-12-17 16:40 ` Arjan van de Ven
2007-12-17 17:23 ` Ingo Molnar
2007-12-17 21:36 ` Arjan van de Ven
2007-12-17 21:58 ` Theodore Tso
2007-12-17 22:58 ` Tony Luck
2007-12-17 23:17 ` Arjan van de Ven
2007-12-17 23:26 ` Tony Luck
2007-12-17 23:47 ` Arjan van de Ven [this message]
2007-12-18 0:21 ` Linus Torvalds
2007-12-18 0:39 ` Arjan van de Ven
2007-12-18 2:31 ` Theodore Tso
2007-12-18 6:58 ` Arjan van de Ven
2007-12-18 17:53 ` Matt Mackall
2007-12-18 18:28 ` Theodore Tso
2007-12-18 18:45 ` Linus Torvalds
2007-12-18 10:11 ` Jon Masters
2007-12-18 18:06 ` Arjan van de Ven
2007-12-18 18:13 ` Matt Mackall
2007-12-18 18:19 ` Arjan van de Ven
2007-12-18 17:48 ` Matt Mackall
2007-12-18 23:37 ` Arjan van de Ven
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=20071217154727.404e4bc4@laptopd505.fenrus.org \
--to=arjan@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=protasnb@gmail.com \
--cc=tony.luck@intel.com \
--cc=torvalds@linux-foundation.org \
--cc=tytso@thunk.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
all inboxes | Powered by JetHome®