[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220801100509.62282-1-xuqiang36@huawei.com>
Date: Mon, 1 Aug 2022 10:05:09 +0000
From: Xu Qiang <xuqiang36@...wei.com>
To: <pmladek@...e.com>, <akpm@...ux-foundation.org>,
<gpiccoli@...lia.com>, <elver@...gle.com>, <mcgrof@...nel.org>,
<tangmeng@...ontech.com>, <yangtiezhu@...ngson.cn>,
<john.ogness@...utronix.de>, <bigeasy@...utronix.de>
CC: <linux-kernel@...r.kernel.org>, <guohanjun@...wei.com>,
<weiyongjun1@...wei.com>
Subject: [PATCH -next] panic: Add register_panic_notifier and unregister_panic_notifier
Add two methods to manipulate panic_notifier_list and export them.
Subsequently, panic_notifier_list is changed to static variable.
Signed-off-by: Xu Qiang <xuqiang36@...wei.com>
---
include/linux/panic_notifier.h | 3 +++
kernel/panic.c | 12 ++++++++++++
2 files changed, 15 insertions(+)
diff --git a/include/linux/panic_notifier.h b/include/linux/panic_notifier.h
index 41e32483d7a7..9543d498b90b 100644
--- a/include/linux/panic_notifier.h
+++ b/include/linux/panic_notifier.h
@@ -5,6 +5,9 @@
#include <linux/notifier.h>
#include <linux/types.h>
+int register_panic_notifier(struct notifier_block *nb);
+int unregister_panic_notifier(struct notifier_block *nb);
+
extern struct atomic_notifier_head panic_notifier_list;
extern bool crash_kexec_post_notifiers;
diff --git a/kernel/panic.c b/kernel/panic.c
index c6eb8f8db0c0..b848ec4ca6e2 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -199,6 +199,18 @@ static void panic_print_sys_info(bool console_flush)
ftrace_dump(DUMP_ALL);
}
+int register_panic_notifier(struct notifier_block *nb)
+{
+ return atomic_notifier_chain_register(&panic_notifier_list, nb);
+}
+EXPORT_SYMBOL(register_panic_notifier);
+
+int unregister_panic_notifier(struct notifier_block *nb)
+{
+ return atomic_notifier_chain_unregister(&panic_notifier_list, nb);
+}
+EXPORT_SYMBOL(unregister_panic_notifier);
+
/**
* panic - halt the system
* @fmt: The text string to print
--
2.17.1
Powered by blists - more mailing lists