[ltt-dev] [PATCH v3 1/1] add tracepoints of panic and kexec

Zhaolei zhaolei at cn.fujitsu.com
Mon Dec 29 20:53:04 EST 2008


Instrumentation of following panic and kexec related events are added:
	panic
	kernel_kexec
	crash_kexec

It is useful for build flight-recorder program based on lttng infrastructure.

Signed-off-by: Zhao Lei <zhaolei at cn.fujitsu.com>
---
 include/trace/notifier.h |   17 +++++++++++++++++
 kernel/kexec.c           |    8 ++++++++
 kernel/panic.c           |    7 +++++++
 3 files changed, 32 insertions(+), 0 deletions(-)
 create mode 100644 include/trace/notifier.h

diff --git a/include/trace/notifier.h b/include/trace/notifier.h
new file mode 100644
index 0000000..0eb721b
--- /dev/null
+++ b/include/trace/notifier.h
@@ -0,0 +1,17 @@
+#ifndef _TRACE_NOTIFIER_H
+#define _TRACE_NOTIFIER_H
+
+#include <linux/tracepoint.h>
+#include <linux/kexec.h>
+
+DECLARE_TRACE(notifier_panic,
+	TPPROTO(const char *fmt, va_list args),
+	TPARGS(fmt, args));
+DECLARE_TRACE(notifier_kernel_kexec,
+	TPPROTO(struct kimage *image),
+	TPARGS(image));
+DECLARE_TRACE(notifier_crash_kexec,
+	TPPROTO(struct kimage *image, struct pt_regs *regs),
+	TPARGS(image, regs));
+
+#endif
diff --git a/kernel/kexec.c b/kernel/kexec.c
index aef2653..4de87cc 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -30,6 +30,7 @@
 #include <linux/pm.h>
 #include <linux/cpu.h>
 #include <linux/console.h>
+#include <trace/notifier.h>
 
 #include <asm/page.h>
 #include <asm/uaccess.h>
@@ -37,6 +38,9 @@
 #include <asm/system.h>
 #include <asm/sections.h>
 
+DEFINE_TRACE(notifier_kernel_kexec);
+DEFINE_TRACE(notifier_crash_kexec);
+
 /* Per cpu memory for storing cpu states in case of system crash. */
 note_buf_t* crash_notes;
 
@@ -1062,6 +1066,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
 
 void crash_kexec(struct pt_regs *regs)
 {
+	trace_notifier_crash_kexec(kexec_crash_image, regs);
+
 	/* Take the kexec_mutex here to prevent sys_kexec_load
 	 * running on one cpu from replacing the crash kernel
 	 * we are using after a panic on a different cpu.
@@ -1428,6 +1434,8 @@ int kernel_kexec(void)
 {
 	int error = 0;
 
+	trace_notifier_kernel_kexec(kexec_image);
+
 	if (!mutex_trylock(&kexec_mutex))
 		return -EBUSY;
 	if (!kexec_image) {
diff --git a/kernel/panic.c b/kernel/panic.c
index 12c5a0a..d1be86c 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -21,6 +21,9 @@
 #include <linux/debug_locks.h>
 #include <linux/random.h>
 #include <linux/kallsyms.h>
+#include <trace/notifier.h>
+
+DEFINE_TRACE(notifier_panic);
 
 int panic_on_oops;
 int tainted;
@@ -68,6 +71,10 @@ NORET_TYPE void panic(const char * fmt, ...)
 	unsigned long caller = (unsigned long) __builtin_return_address(0);
 #endif
 
+	va_start(args, fmt);
+	trace_notifier_panic(fmt, args);
+	va_end(args);
+
 	/*
 	 * It's possible to come here directly from a panic-assertion and not
 	 * have preempt disabled. Some functions called from here want
-- 
1.5.5.3






More information about the lttng-dev mailing list