Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp1075944lqh; Fri, 29 Mar 2024 06:40:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURDWh4KHBAn0v3z0SjSyvNX9hKvh7OR1rTWDkIEWKjw+FNh05WErSXYnrym6N7cRyqoB3nff+2H0RTK61jFPT1DD9A7R0Fv1QNv7roGg== X-Google-Smtp-Source: AGHT+IGoQZvCpAwKCGyhIf+DGmaPmxezuelmIUHxLk5y4b5tPrUW48ZTBrV9YuR8MfL1kIQ+cWO1 X-Received: by 2002:a05:6a00:a90:b0:6e6:57a9:f8b1 with SMTP id b16-20020a056a000a9000b006e657a9f8b1mr7555391pfl.9.1711719602675; Fri, 29 Mar 2024 06:40:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711719602; cv=pass; d=google.com; s=arc-20160816; b=JeEo4MTfB6TKQld29G6iA2nkycc0EqYLvKWE2U87zjLf+VWo/XNSlv0F79QzzJD8yi /EVJ5UMVXhY+7GqF9D1mZ+yOH+kr9DnFAPrAZV/9/FUx4h1jGvAzTc6zLytfYkn0pAc4 Xp3KlwCAXsT8vPgbAJhJzRaIIveytcFvkCYA7UGEyD+B4VhUrHFR8VG8IVwrnA7LOFqr m/3GHjvTCRq44HtwJWjgJjcj/ZEYMUvKx0Sr9ihCI+R4ApdtDK88JoYrF/7XdlQ6ymaz uN0FcOxb0R9DKe0JQ+9S/xBMoh9QZESjgQKVQYfx6QzjNl4dCpKEod7bRRuAa/RkXF27 QOpA== 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=7Bgk8VlBJpC5WSQJQGIQ5NZr2k8Mf8QSTzEBygCa3cM=; fh=j+aMbK7eLMI2KMaRmGMOCTxfEkIc4TPOnxEcnsSirNc=; b=ze0eNEji0VGEkU7qfsSZVKlfhVwee+GiSa199/Io6r+bnqPi//+h/AxYFaKLVHrRhd EQfvRPvPd6M9S1e6NKbxVOU/TZXoU4kyvYdaZbYgRp4OkLX7Ny3zOCTHmIOd+5pSXxRA 1A9xZ5zOuu+j05o3ZWlWonaPfy6bGj405mNjZfygcxGm6O03SnLVLQ6ebujyM3rF4+NV duoGuGq90syNtLVRhQ1aFw89Imzy+7xr08dJ1P0prBiwk9vR7vXsw/6JFTEFl2DmNH// CGzbsjdxEI8N7fVgIHGf5hcJJe0VTTk0qw8SZlkJ7uwroSi81hpSeUuDkHSNaR5rXROo h0AQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UY7AlprN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124729-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124729-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l19-20020a637013000000b005dc8554d500si3684562pgc.62.2024.03.29.06.40.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 06:40:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124729-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UY7AlprN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124729-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124729-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 367992898D1 for ; Fri, 29 Mar 2024 13:35:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7DA221782F0; Fri, 29 Mar 2024 12:40:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UY7AlprN" 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 91DAB178233; Fri, 29 Mar 2024 12:40:22 +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=1711716022; cv=none; b=NIjRjT9w4Cfq9khPdvTxACJp8o82loynqA0s9r8C44PPJazFu3mqJlj22SEi9Xxc7sw0tx1c2z6lE61ZKwYI5Fjf7AtSDIntMp5kvW6CO12vY6na3XEb2puZZ4zLWcrF+jzv7LiQCr/Gdln5FvXGQOFGgIiozg+3pLcWuzp9K94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716022; c=relaxed/simple; bh=Wn5WD+2CFhXCxhgEcc1PzJJjaGHw/EsSXxUvY9AwRzE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=icRFZYEV/rMqKLew4c1hMnp1/frKRFImpvW2RcDUu5OQdhd2F4HGEopepWQaaTQ+H38Jndtqv08C6kHXQIQOIxvp1gsB+01KtBfbzNrfXAy0TVvZR+3+b4lkll5wp+Apjxl6tG4TX2G0QMYg2vzXTCo1R0NaSRy7VZftqIbB8g0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UY7AlprN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD771C43399; Fri, 29 Mar 2024 12:40:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716022; bh=Wn5WD+2CFhXCxhgEcc1PzJJjaGHw/EsSXxUvY9AwRzE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UY7AlprNnnws0egM2RLyRlbwJ1zPgkYZ2dnZG/9cF+S1E9MnEUOFSB6v8neKtv1Ou H3ugrGWa0W23E9WEfurDao17VHhsS4V4GMIfYKovKoHrfNcYwvojWQirq/7JL2Wkq/ Cwd7qFWX3CLM2NbXRQZtj1/rhNj5x70wrYX5My1ACN0ppC6gNBWLiiuonOJgoNv32w 1t0dTokJr0ZsPBXF7SH6VusCW++l7ECRMeC1s+YjbhyUOFgt9lfHtY28ayjX9XVOj7 XGSqP/HDUkrsJSi5anwPIRCCYQrEvT/eAS6aeCrIn/dpQBbzC1G4YkONirDxAqwauz yEHJAqUVU+tXA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: John Ogness , Petr Mladek , Sasha Levin Subject: [PATCH AUTOSEL 6.8 20/98] printk: Add this_cpu_in_panic() Date: Fri, 29 Mar 2024 08:36:51 -0400 Message-ID: <20240329123919.3087149-20-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329123919.3087149-1-sashal@kernel.org> References: <20240329123919.3087149-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 X-stable-base: Linux 6.8.2 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 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 d9f20d222293b..742fb479b1d60 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 @@ -2600,26 +2623,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