Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2483568lqp; Sun, 24 Mar 2024 22:57:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVDoDCnoV1kTCm7adTSgYi40AHeQo/rcW/XbbRJtY0lTK/rmpcQF7KALyc/jO/ccML6i3iDvddUey7sJq1mkazPep8gh8ad0hiwVwgiMg== X-Google-Smtp-Source: AGHT+IFwhrwlGOmQrAcjtZNpmIbWQiRl5Ii14rbCgYrvuiGCIWDqiP0KLQExWUghM1RQxcWsYfji X-Received: by 2002:a17:906:944:b0:a46:f538:4009 with SMTP id j4-20020a170906094400b00a46f5384009mr3777642ejd.66.1711346234425; Sun, 24 Mar 2024 22:57:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711346234; cv=pass; d=google.com; s=arc-20160816; b=QsJsYa/I6FFWUerx4jGpZHsD1u7WChIyPkG6ybPVlYB39OAK9EkfzzjGiR8ccwTCn/ tmcT0XTVlTjO7IfFbRfyyCHBkKrFNYrMm8QSv7Ar4jaHBoKULC0oJY6TI5WKzPPyrsAR yfcVPC1bswMNdSEfPHnv6OHTznk3oQuJhAG1qiCsHgDphcasbmmM0jIlrmqXmE74YuVW sFlquF//8+Ce4OZ334LVlKfqUC66SA29f0DTkluY39IJPdEHrBvmbc7+wZpI4cRS3HlF NBBeTTil4+QBDtsYWlEDOx3go8X3qilQ8EqpxrqiwDoE3tJPOJbvz5tIshUPDcXcBNdu I2Sw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=x+eCvLAaw4NgVmo3odqFdiGShWu3ssuFXOgSzf+fUWs=; fh=j+aMbK7eLMI2KMaRmGMOCTxfEkIc4TPOnxEcnsSirNc=; b=HJKXnX7vZHODionryKyhTEK7IvHjI1MsqcvkHgTNmihYzrpnb91iYEhRnSfq5mAqS2 AA+ZTr0bv3S0YA5elASodYZPNXz3kscCdfxg+76nm074kxyfiypliuoPVQ56Uy1Hp8ps 2nmW5GFGpkWJiS7Xm4JDmVpeTH+5aRJZxKNygXmzDHIVDvi+/6shWoXctfHyZ23bhZkg 5seir9pSGsGhBwegF9Q0E/3gYXadsnxfC9j+llb27iW4eySyf2A1U4Jyo6exCXpPnoOA xlw6pp/LTHj/ZbW8m7M3s7pkVrnFtIJ/g7AQ5FLsJHGEaO6Lt9V0PCWumicDBvtZlOfW WPlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XLkkDB18; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113664-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ka4-20020a170907990400b00a48e7ac1324si832285ejc.138.2024.03.24.22.57.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 22:57:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XLkkDB18; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113664-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 223841F2B2A8 for ; Mon, 25 Mar 2024 05:12:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A67AE1DD2B6; Sun, 24 Mar 2024 22:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XLkkDB18" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95C9A1442F7; Sun, 24 Mar 2024 22:50:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320657; cv=none; b=slYdNtkZu05BM4Ii+VphTQVkt9PaylzntQzDqnhXjAD/RStFm5UXuFwaZMOwAdUKHmbbDdPyGDTYp+II8sfaARGuLbpw4WSkD+IfX0A59vONqDN27+40K7y8SDA/Ry0eUtjPX4lgLKxAI9qDOxl01qy+YuDYic/JqsOlHcaWWDE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320657; c=relaxed/simple; bh=weL9bKStwrCWZ03fP6/Vywm6N8qOPfvGjjZrxMDFsZM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e/gDzC1XnrfEmObpTZW0QY8qu2Ygud5TlKngrs95Bzo5lMwWEXK9O6/Ri4IZLmbhRe1Ruig/tuvDj1zk0aHUSXRhF6xO8FrZEykIK+11Hfq2ptJvhDAZVg4irffGvx/iUa3LKx29sd/S8CALiaBPPFWcwbFnaYXwbU5VaxwXILQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XLkkDB18; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0CE6C433F1; Sun, 24 Mar 2024 22:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320657; bh=weL9bKStwrCWZ03fP6/Vywm6N8qOPfvGjjZrxMDFsZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XLkkDB18rD9KqXBpk6dFU7jEFe/bCXNvPCGo5f9Ml+NUEOVnDvH6n3WhYFqtooQ24 ZucsrfRj0z7zE6US2WuNyBDbPB0e506PqsGwAL3GDAdmdtNr5wusUilOGT7guBkhdM yLM+F3B5TxUXJR7u8Oa6V7WBjLh+3k7JvoebiNC++hiQ55flJ13hcPV6ovvWRtpEdW +lEt6kMFlj1CuX6BXVZV8P6fboE52FGjN19FUFoTsz5qcdBDxZFWI3qpbWkF96o0aY XiVhS8YqxOtrI6zsBA+H57u0iPxiBm4LS3bAKOwji2ZUdbox5kXyDEtqr4lq+fc5Ng wTh9ZFl+U12ww== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: John Ogness , Petr Mladek , Sasha Levin Subject: [PATCH 6.7 219/713] printk: Add this_cpu_in_panic() Date: Sun, 24 Mar 2024 18:39:05 -0400 Message-ID: <20240324224720.1345309-220-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: John Ogness [ Upstream commit 36652d0f3bf34899e82d31a5fa9e2bdd02fd6381 ] There is already panic_in_progress() and other_cpu_in_panic(), but checking if the current CPU is the panic CPU must still be open coded. Add this_cpu_in_panic() to complete the set. Signed-off-by: John Ogness Reviewed-by: Petr Mladek Link: https://lore.kernel.org/r/20240207134103.1357162-8-john.ogness@linutronix.de Signed-off-by: Petr Mladek Stable-dep-of: b1c4c67a5e90 ("printk: ringbuffer: Skip non-finalized records in panic") Signed-off-by: Sasha Levin --- kernel/printk/internal.h | 1 + kernel/printk/printk.c | 43 +++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h index 6c2afee5ef620..ac2d9750e5f81 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -130,6 +130,7 @@ struct printk_message { }; bool other_cpu_in_panic(void); +bool this_cpu_in_panic(void); bool printk_get_next_message(struct printk_message *pmsg, u64 seq, bool is_extended, bool may_supress); diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index d9420207282ac..b7e50f8438df3 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -347,6 +347,29 @@ static bool panic_in_progress(void) return unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID); } +/* Return true if a panic is in progress on the current CPU. */ +bool this_cpu_in_panic(void) +{ + /* + * We can use raw_smp_processor_id() here because it is impossible for + * the task to be migrated to the panic_cpu, or away from it. If + * panic_cpu has already been set, and we're not currently executing on + * that CPU, then we never will be. + */ + return unlikely(atomic_read(&panic_cpu) == raw_smp_processor_id()); +} + +/* + * Return true if a panic is in progress on a remote CPU. + * + * On true, the local CPU should immediately release any printing resources + * that may be needed by the panic CPU. + */ +bool other_cpu_in_panic(void) +{ + return (panic_in_progress() && !this_cpu_in_panic()); +} + /* * This is used for debugging the mess that is the VT code by * keeping track if we have the console semaphore held. It's @@ -2601,26 +2624,6 @@ static int console_cpu_notify(unsigned int cpu) return 0; } -/* - * Return true if a panic is in progress on a remote CPU. - * - * On true, the local CPU should immediately release any printing resources - * that may be needed by the panic CPU. - */ -bool other_cpu_in_panic(void) -{ - if (!panic_in_progress()) - return false; - - /* - * We can use raw_smp_processor_id() here because it is impossible for - * the task to be migrated to the panic_cpu, or away from it. If - * panic_cpu has already been set, and we're not currently executing on - * that CPU, then we never will be. - */ - return atomic_read(&panic_cpu) != raw_smp_processor_id(); -} - /** * console_lock - block the console subsystem from printing * -- 2.43.0