From mboxrd@z Thu Jan 1 00:00:00 1970 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 D4532C433EF for ; Wed, 30 Mar 2022 11:49:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343981AbiC3LvA (ORCPT ); Wed, 30 Mar 2022 07:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344048AbiC3LuO (ORCPT ); Wed, 30 Mar 2022 07:50:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FEA926E559; Wed, 30 Mar 2022 04:47:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3A21EB81C35; Wed, 30 Mar 2022 11:47:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24238C3410F; Wed, 30 Mar 2022 11:47:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648640854; bh=1E7Fub2AHPG39Wqa1gCOB9ASJq+I2LHljK6ApW8LEGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ewcof4tN0tz3n4YH0RPFBjHmHUjPoioLiJaoooARSfE96Rio6YSWoATzBBIWvUK11 2zbizAj4af1GfGTsgHU1RMW0RYVv7wNAsgx9taemwCpWWo5kwXrr2m0BTjAbul4w94 ruBVs3xa3gNt9B1tfhW98opiIOO+Fgxt8X8B9g74HXJBnGAinmgZ7TjhHGuIwB2VMf 85pqz3cu0Uketakejxv8wM0aMjt4dZ9k5RlWdrYODb/dGiZKIYe4LsAKgc0xHvh9G+ xCPD13zkIAcXBJwH3XZuXoDitYHVBzAv5gLU5wAiz4lQRMgAr0cyMopKb1ufc5coD1 0hnxKXyewnWUA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Stephen Brennan , Petr Mladek , Sergey Senozhatsky , Sasha Levin , gregkh@linuxfoundation.org, linux@roeck-us.net Subject: [PATCH AUTOSEL 5.17 31/66] printk: Add panic_in_progress helper Date: Wed, 30 Mar 2022 07:46:10 -0400 Message-Id: <20220330114646.1669334-31-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220330114646.1669334-1-sashal@kernel.org> References: <20220330114646.1669334-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Stephen Brennan [ Upstream commit 77498617857f68496b360081dde1a492d40c28b2 ] This will be used help avoid deadlocks during panics. Although it would be better to include this in linux/panic.h, it would require that header to include linux/atomic.h as well. On some architectures, this results in a circular dependency as well. So instead add the helper directly to printk.c. Suggested-by: Petr Mladek Signed-off-by: Stephen Brennan Reviewed-by: Petr Mladek Reviewed-by: Sergey Senozhatsky Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20220202171821.179394-2-stephen.s.brennan@oracle.com Signed-off-by: Sasha Levin --- kernel/printk/printk.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 82abfaf3c2aa..0f8918f5f22a 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -257,6 +257,11 @@ static void __up_console_sem(unsigned long ip) } #define up_console_sem() __up_console_sem(_RET_IP_) +static bool panic_in_progress(void) +{ + return unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID); +} + /* * This is used for debugging the mess that is the VT code by * keeping track if we have the console semaphore held. It's -- 2.34.1