Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1592517pxb; Tue, 8 Feb 2022 23:25:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHdYzsvH+IW1n2Fi2icqepMl/q2JylhRpkIeuBNylmfGDkbJdfpFMnWYjntojNBhA47ewt X-Received: by 2002:a65:6296:: with SMTP id f22mr872349pgv.320.1644391539633; Tue, 08 Feb 2022 23:25:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644391539; cv=none; d=google.com; s=arc-20160816; b=Mdae5ldMYspjnAiI0CUAZL3VOSD114eX9AGAgooHlFfOk980OVg7H2PGGJUI51NG/J wtlA5g44YsaBMTrEa8foAd1RnakeZzHeOsIa6J0oV67eo5MptUhsyMUaSahc25VJErLO NaNt6Y0RRLKqo0OveIJ/+++nDlOLq75qYn5QYZqZyupF6/wYN0fzpG1ut/00bWQz9YP3 WBzAhdq358KIEk2pkomIvUV6eTQfTdvZMNH/9ClDgCyJxNVIXAmcMvQs4sP9yBfIig4e r5XoHW3G6ti2g0FcDOZksZ1GTD/QQPQnFjX6eYcG0fLczPd1Xe/+PtJ+Z3oXrby0VULr 7l8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=qGJnNbLPzK7UyDbI79WZ4oMXPkEl5Okr72aVK5OpkZU=; b=YjnsNPc9/WBzh8gALxEwJS5egvA6A0/WkiXk3KcSzh7YaPPtYtH3VtZobeDpH+Ud5o 6kR8IBXjsUC2gkZXVJbg8IZVoMGD42N3/p2zLNY7eSEsiSg7A+sRmYUZknyFWbIwCcXX 0FqBusVgQ933PHA1wOmy7ysnBZyI9+4HS6Av8m/aWreOuZ/ilvdYP460OWZgdvP880lh jVPw2FMBJky/W+3dZVJKfsKmqPXHjWy0T/MPeQDiCt8vfwGTeNmLTw4NiHiRW5DPTuHu /ACJpK86Asvy6yY+GfoZvRuidvB9f5m9cwuuWvYmDgFEnOkmg97qg6oTLyUFseyXjpNy B49g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u1si17206677plg.402.2022.02.08.23.25.26; Tue, 08 Feb 2022 23:25:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348004AbiBHNSl (ORCPT + 99 others); Tue, 8 Feb 2022 08:18:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376344AbiBHM5Z (ORCPT ); Tue, 8 Feb 2022 07:57:25 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 99DF0C03FED0; Tue, 8 Feb 2022 04:57:21 -0800 (PST) Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxL+M6ZwJik0oIAA--.26524S5; Tue, 08 Feb 2022 20:51:08 +0800 (CST) From: Tiezhu Yang To: Baoquan He , Jonathan Corbet , Andrew Morton , Marco Elver , Andrey Ryabinin Cc: Xuefeng Li , kexec@lists.infradead.org, linux-doc@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] panic: unset panic_on_warn inside panic() Date: Tue, 8 Feb 2022 20:51:04 +0800 Message-Id: <1644324666-15947-4-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1644324666-15947-1-git-send-email-yangtiezhu@loongson.cn> References: <1644324666-15947-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9DxL+M6ZwJik0oIAA--.26524S5 X-Coremail-Antispam: 1UD129KBjvJXoW7Cr4UuFy7ury7WrWrWFW3Jrb_yoW8AryDpF nxKFWDKr4kKr1rXa97Jw4vyryYvws5Xa4xCas7Ar4Fyan8tFn8JrZ7CFy2q34Yg34xXayY vr1qqry3K3W8JaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPl14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r106r15McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04 v7MxkIecxEwVAFwVW5JwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC2 0s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI 0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv2 0xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2js IE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZF pf9x0JUhBMNUUUUU= X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 In the current code, the following three places need to unset panic_on_warn before calling panic() to avoid recursive panics: kernel/kcsan/report.c: print_report() kernel/sched/core.c: __schedule_bug() mm/kfence/report.c: kfence_report_error() In order to avoid copy-pasting "panic_on_warn = 0" all over the places, it is better to move it inside panic() and then remove it from the other places. Signed-off-by: Tiezhu Yang --- kernel/panic.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/panic.c b/kernel/panic.c index 55b50e0..95ba825 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -185,6 +185,16 @@ void panic(const char *fmt, ...) int old_cpu, this_cpu; bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers; + if (panic_on_warn) { + /* + * This thread may hit another WARN() in the panic path. + * Resetting this prevents additional WARN() from panicking the + * system on this thread. Other threads are blocked by the + * panic_mutex in panic(). + */ + panic_on_warn = 0; + } + /* * Disable local interrupts. This will prevent panic_smp_self_stop * from deadlocking the first cpu that invokes the panic, since @@ -576,16 +586,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint, if (regs) show_regs(regs); - if (panic_on_warn) { - /* - * This thread may hit another WARN() in the panic path. - * Resetting this prevents additional WARN() from panicking the - * system on this thread. Other threads are blocked by the - * panic_mutex in panic(). - */ - panic_on_warn = 0; + if (panic_on_warn) panic("panic_on_warn set ...\n"); - } if (!regs) dump_stack(); -- 2.1.0