All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xu Qiang <xuqiang36@huawei.com>
To: <pmladek@suse.com>, <akpm@linux-foundation.org>,
	<gpiccoli@igalia.com>, <elver@google.com>, <mcgrof@kernel.org>,
	<tangmeng@uniontech.com>, <yangtiezhu@loongson.cn>,
	<john.ogness@linutronix.de>, <bigeasy@linutronix.de>
Cc: <linux-kernel@vger.kernel.org>, <guohanjun@huawei.com>,
	<weiyongjun1@huawei.com>
Subject: [PATCH -next] panic: Add register_panic_notifier and unregister_panic_notifier
Date: Mon, 1 Aug 2022 10:05:09 +0000	[thread overview]
Message-ID: <20220801100509.62282-1-xuqiang36@huawei.com> (raw)

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@huawei.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


             reply	other threads:[~2022-08-01 10:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01 10:05 Xu Qiang [this message]
2022-08-01 12:11 ` [PATCH -next] panic: Add register_panic_notifier and unregister_panic_notifier Guilherme G. Piccoli
2022-08-01 13:58   ` xuqiang (M)
2022-08-01 14:25     ` Guilherme G. Piccoli

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=20220801100509.62282-1-xuqiang36@huawei.com \
    --to=xuqiang36@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=elver@google.com \
    --cc=gpiccoli@igalia.com \
    --cc=guohanjun@huawei.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=pmladek@suse.com \
    --cc=tangmeng@uniontech.com \
    --cc=weiyongjun1@huawei.com \
    --cc=yangtiezhu@loongson.cn \
    /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.