From nobody Tue Apr 14 21:16:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23F10C433FE for ; Sat, 19 Nov 2022 08:05:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232643AbiKSIFH (ORCPT ); Sat, 19 Nov 2022 03:05:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiKSIFD (ORCPT ); Sat, 19 Nov 2022 03:05:03 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A99AE6DCF6 for ; Sat, 19 Nov 2022 00:05:01 -0800 (PST) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NDmQS5JjDzmVw8; Sat, 19 Nov 2022 16:04:32 +0800 (CST) Received: from huawei.com (10.175.112.208) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 19 Nov 2022 16:04:57 +0800 From: Xu Qiang To: , , , , , , , , , , CC: , , Subject: [PATCH RESEND] panic: Add register_panic_notifier and unregister_panic_notifier Date: Sat, 19 Nov 2022 08:03:05 +0000 Message-ID: <20221119080305.111863-1-xuqiang36@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 #include =20 +int register_panic_notifier(struct notifier_block *nb); +int unregister_panic_notifier(struct notifier_block *nb); + extern struct atomic_notifier_head panic_notifier_list; =20 extern bool crash_kexec_post_notifiers; diff --git a/kernel/panic.c b/kernel/panic.c index 75fe389e8814..8f34dbd389cf 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -200,6 +200,18 @@ static void panic_print_sys_info(bool console_flush) ftrace_dump(DUMP_ALL); } =20 +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 --=20 2.17.1