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 60BF8C43219 for ; Wed, 30 Mar 2022 12:17:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347046AbiC3MSz (ORCPT ); Wed, 30 Mar 2022 08:18:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344359AbiC3Lzv (ORCPT ); Wed, 30 Mar 2022 07:55:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DF162E681; Wed, 30 Mar 2022 04:53:55 -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 5B16AB81BBA; Wed, 30 Mar 2022 11:53:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57BF8C34111; Wed, 30 Mar 2022 11:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648641233; bh=JJbMh+5Qrz0CUtp6vkYydDvvRBp669xI8AfT2Ao7+cQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OIl1qBekhK/LAAIQB+5CYtl3g7PxfJ0XHtlG9QLm30L4DsoBYtIySppYNXKL/U2RX hx6aw7DPNShDbofa/VlIiTCtbaQ3C12DU0+Cf95V7TtgYNBzb/CTrjREwiGK3rEXED ZoR4xFAc5HI3/k90TG4sgW7NlgxKo6ZmaqGcgrHZY/dl78pEefc3lOmDv9bVaNIV87 26D4sOz6X+7wQCZEYg8UTv23NS4Ip9bO0iC6rOjCF3KSLodujC9J2aw4qV3esyeSaP mZY+yVgEZ4OwJja8ITS3SEwIV+W1AykpAek+7DnOQKfLE6cc+HGSss7ukplSeLCube J1vGbFaXvTFmA== 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 4.14 10/20] printk: Add panic_in_progress helper Date: Wed, 30 Mar 2022 07:53:26 -0400 Message-Id: <20220330115336.1672930-10-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220330115336.1672930-1-sashal@kernel.org> References: <20220330115336.1672930-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: linux-kernel@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 31b5e7919d62..1d7325f09004 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -247,6 +247,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