All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Waychison <mikew@google.com>
To: Greg KH <greg@kroah.com>, torvalds@linux-foundation.org
Cc: San Mehat <san@google.com>, Aaron Durbin <adurbin@google.com>,
	Duncan Laurie <dlaurie@google.com>,
	linux-kernel@vger.kernel.org, Tim Hockin <thockin@google.com>
Subject: [PATCH v1 1/6] Add oops notification chain.
Date: Mon, 24 Jan 2011 16:24:39 -0800	[thread overview]
Message-ID: <20110125002439.12637.8515.stgit@mike.mtv.corp.google.com> (raw)
In-Reply-To: <20110125002433.12637.51091.stgit@mike.mtv.corp.google.com>

From: Aaron Durbin <adurbin@google.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@google.com>
Signed-off-by: Mike Waychison <mikew@google.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);


  reply	other threads:[~2011-01-25  0:24 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-25  0:24 [PATCH v1 0/6] google firmware support Mike Waychison
2011-01-25  0:24 ` Mike Waychison [this message]
2011-01-25  2:06   ` [PATCH v1 1/6] Add oops notification chain Greg KH
2011-01-25 20:01     ` Mike Waychison
2011-01-25 21:36       ` Jeff Garzik
2011-01-25 21:43         ` Aaron Durbin
2011-01-25 21:54           ` Jeff Garzik
2011-01-25 22:21             ` Aaron Durbin
2011-01-26  2:48               ` Greg KH
2011-01-26 21:50                 ` Mike Waychison
2011-01-25  0:24 ` [PATCH v1 2/6] Introduce CONFIG_GOOGLE_FIRMWARE Mike Waychison
2011-01-25  0:24 ` [PATCH v1 3/6] driver: Google EFI SMI Mike Waychison
2011-01-25  3:17   ` Greg KH
2011-01-25 23:12     ` Mike Waychison
2011-01-26  2:46       ` Greg KH
2011-01-26 23:58         ` Mike Waychison
2011-01-27  1:22           ` Mike Waychison
2011-01-27 23:41             ` Mike Waychison
2011-01-28  2:56               ` Greg KH
2011-02-20  4:44               ` Matt Domsch
2011-02-21 13:58                 ` Matthew Garrett
2011-01-27 10:43           ` Alan Cox
2011-01-27 19:22             ` Mike Waychison
2011-01-28  2:55               ` Greg KH
2011-01-28  2:59           ` Greg KH
2011-01-25  0:24 ` [PATCH v1 4/6] driver: Google Bootlog Mike Waychison
2011-01-25  0:49   ` Alan Cox
2011-01-25  1:38     ` Mike Waychison
2011-01-25  9:43       ` Alan Cox
2011-01-25  0:25 ` [PATCH v1 5/6] Allow prepending to the dmesg Mike Waychison
2011-01-25  1:01   ` Andrew Morton
2011-01-25  0:25 ` [PATCH v1 6/6] driver: Google Memory Console Mike Waychison
2011-01-25  2:00   ` Greg KH
2011-01-25  3:01 ` [PATCH v1 0/6] google firmware support Greg KH
2011-01-25 19:58   ` Mike Waychison
2011-01-26  2:47     ` Greg KH

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=20110125002439.12637.8515.stgit@mike.mtv.corp.google.com \
    --to=mikew@google.com \
    --cc=adurbin@google.com \
    --cc=dlaurie@google.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=san@google.com \
    --cc=thockin@google.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 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.