[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110125002439.12637.8515.stgit@mike.mtv.corp.google.com>
Date: Mon, 24 Jan 2011 16:24:39 -0800
From: Mike Waychison <mikew@...gle.com>
To: Greg KH <greg@...ah.com>, torvalds@...ux-foundation.org
Cc: San Mehat <san@...gle.com>, Aaron Durbin <adurbin@...gle.com>,
Duncan Laurie <dlaurie@...gle.com>,
linux-kernel@...r.kernel.org, Tim Hockin <thockin@...gle.com>
Subject: [PATCH v1 1/6] Add oops notification chain.
From: Aaron Durbin <adurbin@...gle.com>
Later firmware patches in this series would like to be able to be
notified whenever an oops occurs on the system, so that it can be
recorded in the boot log.
This patch introduces a notifier_block called "oops_notifier_list"
so that drivers can register to get called whenever an Oops is
triggered.
Signed-off-by: Aaron Durbin <adurbin@...gle.com>
Signed-off-by: Mike Waychison <mikew@...gle.com>
---
include/linux/kernel.h | 3 +++
include/linux/notifier.h | 3 +++
kernel/panic.c | 15 +++++++++++++++
3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d07d805..2e56fed 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -183,6 +183,9 @@ extern void oops_enter(void);
extern void oops_exit(void);
void print_oops_end_marker(void);
extern int oops_may_print(void);
+struct notifier_block;
+extern int register_oops_notifier(struct notifier_block *nb);
+extern int unregister_oops_notifier(struct notifier_block *nb);
NORET_TYPE void do_exit(long error_code)
ATTRIB_NORET;
NORET_TYPE void complete_and_exit(struct completion *, long)
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index 2026f9e..2a121bb 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -217,6 +217,9 @@ static inline int notifier_to_errno(int ret)
#define SYS_HALT 0x0002 /* Notify of system halt */
#define SYS_POWER_OFF 0x0003 /* Notify of system power off */
+#define OOPS_ENTER 0x0000 /* Notify OOPs has been entered */
+#define OOPS_EXIT 0x0001 /* Notify OOPs has exited */
+
#define NETLINK_URELEASE 0x0001 /* Unicast netlink socket released */
#define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */
diff --git a/kernel/panic.c b/kernel/panic.c
index 991bb87..45a50bb 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -37,6 +37,7 @@ int panic_timeout;
EXPORT_SYMBOL_GPL(panic_timeout);
ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
+static ATOMIC_NOTIFIER_HEAD(oops_notifier_list);
EXPORT_SYMBOL(panic_notifier_list);
@@ -321,6 +322,7 @@ void oops_enter(void)
/* can't trust the integrity of the kernel anymore: */
debug_locks_off();
do_oops_enter_exit();
+ atomic_notifier_call_chain(&oops_notifier_list, OOPS_ENTER, NULL);
}
/*
@@ -355,6 +357,7 @@ void oops_exit(void)
do_oops_enter_exit();
print_oops_end_marker();
kmsg_dump(KMSG_DUMP_OOPS);
+ atomic_notifier_call_chain(&oops_notifier_list, OOPS_EXIT, NULL);
}
#ifdef WANT_WARN_ON_SLOWPATH
@@ -431,5 +434,17 @@ EXPORT_SYMBOL(__stack_chk_fail);
#endif
+int register_oops_notifier(struct notifier_block *nb)
+{
+ return atomic_notifier_chain_register(&oops_notifier_list, nb);
+}
+EXPORT_SYMBOL_GPL(register_oops_notifier);
+
+int unregister_oops_notifier(struct notifier_block *nb)
+{
+ return atomic_notifier_chain_unregister(&oops_notifier_list, nb);
+}
+EXPORT_SYMBOL_GPL(unregister_oops_notifier);
+
core_param(panic, panic_timeout, int, 0644);
core_param(pause_on_oops, pause_on_oops, int, 0644);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists