From patchwork Sat Nov 19 08:03:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Qiang X-Patchwork-Id: 23231 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp608336wrr; Sat, 19 Nov 2022 00:14:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf5kowG4bB3jtVTlx73vjtYdkptGCSMSFqOKQEbiEO3kpQ5o37uJg/TMnjcMz2iSk8ntyxuv X-Received: by 2002:a05:6402:114c:b0:457:35d4:ac66 with SMTP id g12-20020a056402114c00b0045735d4ac66mr8911096edw.415.1668845642502; Sat, 19 Nov 2022 00:14:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668845642; cv=none; d=google.com; s=arc-20160816; b=m/+x+hnxKMQ6RQtxZsKpWvFqFQamgrW51MWxGGeBeWOGpobQSIvpPjTyZTTsQhdxpr 5Xx8pELg9w/aFBofJxt1ujuLt2UxxxLQesxolBePoZP5LXaw/GsZUNlB0NjIDIiSNHT9 OpQM9BEXw1dERJeTHQLHPnxhuqh0BcFyDeeU5fo5MkX0hi3+BAlZ8K+870kP5Hzz8e6F TXev54SOG4uEI1N9XBS5yw++AVUUctSd8G/x8PPg7nf2ByTY5+RRXOhnV57L1Ot+9LwB 1vyAj9EgQFI3GxUeNIeO/Ky7yBtKYPzqrBcCAytbz+jtXP9asoqOtahD9+9mx6LkL5OY 1bwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=C4haBfL7TIO/Jn1z4v863j+5BqS1jrdU1wrB0zTCuv0=; b=kKZ15fOP/Wgq2A9L2rJkky6ZGtcUxA7NusoEIOIYnwHYPh/jlZbz1RxUXqLEZQhanv jf5HItepZ9RFI8YIG42+O4H4ucnjjeS94Le/ER14EVs+f/S1iwTV3iSAyDjEmD3PWYce ilNZQYNTkHnzgxEuL6RHqe7sGEf9sLG9nJDJHIQ0/uX0ry742322zW49wUX7eMEpPMvt X8q1yQ5UZtkhdJWJ1CgdJcfvszQfApnwUfFsMKtTeqDjIgaiGjaQBEsMTiRsTJa8UoHV Ka51ilg0ZxKCTEqxiybTWfSWP0SNFPVFiFwpMy9DG0rg5staqlK2+8oLLzZ5Am0cmUab IpZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w20-20020a05640234d400b0045945eed10asi78291edc.5.2022.11.19.00.13.38; Sat, 19 Nov 2022 00:14:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233092AbiKSIFG (ORCPT + 99 others); Sat, 19 Nov 2022 03:05:06 -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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749911488675212694?= X-GMAIL-MSGID: =?utf-8?q?1749911488675212694?= 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 +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 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); } +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