Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6285183rdb; Thu, 14 Dec 2023 13:44:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFWKkyHWWkMGBY12WPQ+m/cU2DkB5V4Tph7NqUss1iJTwjL39ozBErzZVtkEcmHsiBf2nQO X-Received: by 2002:a17:902:e789:b0:1d0:6ffe:9f5 with SMTP id cp9-20020a170902e78900b001d06ffe09f5mr12122300plb.83.1702590267981; Thu, 14 Dec 2023 13:44:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702590267; cv=none; d=google.com; s=arc-20160816; b=OtQ1owp41H0V38q0xEhfbEAqLjqENkndyL9AglvC5Odif/DTEF4HlaYOEMDgb0FvLj gNWawXHWQAcsV2tB/9sY5vQrhow9G8Ihl3h2gkIztcHXaIZcf2Ylucci/w0q9t7JMNxB 8k1XaRcOgVwBtG+c3W2y3kdMtSvdgU6ZR0e8wyBZKVdR//OoIkCJpecAlxe06LrqCCv+ fq/Yw1vjeRmmaMy+qEYM3MF4Er4iUKo/ctXvcJzjsHnqdSNXIiguhPQkurrnWsUn3Rqg nXwnVBPFDgqvjHtPUt4NtS4/fqmw1ijkTpc+24ZqLmMAGqF8mBmlLGMzhXwOh8PeSfL3 cXDA== ARC-Message-Signature: i=1; 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:dkim-signature:dkim-signature:from; bh=EjNlI5JonKv0m/kINdXCywSbWYOfTvFxrSFxNOQW5Ko=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=Vqu9Ussix9ubjDbCYbAbQXBzc4ORBqeOF0xoxnO9au9YWgJcSKtE92rNVOyMVDP7wj D1hCt/AMLobx8fvnudTJPYKp7S9CQ+bqlA6evkezrpqOQEj4LJyH+RovhsB0YX4lKIkq SaAFyqmo8MkwlDwCvW+WrBpZGizE21ysx47OQTxk0icmFFvc2Rkk2H2Pas/Nb9kXoFd/ V43+JVS7iSecz5vimdbJReSD3ozo+BYNvb76HBA/xI7LK1GoI+mnt1Q0x2I8V60o0OIp 6FcOD+6lpkeRuQxeYO7hMXqmfDOS0e3BVRv0Doy7DVdSI2IYjgzKVu4eRCiyHcq5olS4 5PrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Fl9EDpri; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-155-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c12-20020a170903234c00b001cfcf1faaa6si12249016plh.206.2023.12.14.13.44.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 13:44:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Fl9EDpri; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-155-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 A50A1280EBD for ; Thu, 14 Dec 2023 21:44:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC8A57948F; Thu, 14 Dec 2023 21:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Fl9EDpri"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="F1l2H1G/" X-Original-To: linux-kernel@vger.kernel.org Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 D9F646E2C1 for ; Thu, 14 Dec 2023 21:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702590126; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EjNlI5JonKv0m/kINdXCywSbWYOfTvFxrSFxNOQW5Ko=; b=Fl9EDpriC4isCU/BtgR2fdrIobGrK+hq+Ifz9dlN3/a1ySYUNd1l8M8/WQCtjZso2uBmwY Uz7xWkah907tDY34I+G0Rv68veVCA64rwBs8UMzMFc+M92sG8xPSNeA0g6op0LWfTGnChz ITiH2Li9Zl2EVtitjdzhIS4aK60cshGIyCblZ1/0DdbZdVctvHoWpulv1yRRX2inGcKUBK DuyUZH6NSSFdU35rNVJz8t+vO+yF+rDyB7faIZxTKCYvBPVQTzwqbL6NX9AG3GTBfteHGz idEOWRMKsuB2x0026kUWgjX8jIZ91v8kZ5MXyoYvpq96CtrXV5MahJvvRB6Hug== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702590126; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EjNlI5JonKv0m/kINdXCywSbWYOfTvFxrSFxNOQW5Ko=; b=F1l2H1G/fVUwDSZT60vtw3F6/tqAwdlqkl2Nn/lHaRx4HraBC0vfmiFsvJOZUmAE6vQqJM g6/09CwYWZ8gPIDg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v3 07/14] printk: Add this_cpu_in_panic() Date: Thu, 14 Dec 2023 22:47:54 +0106 Message-Id: <20231214214201.499426-8-john.ogness@linutronix.de> In-Reply-To: <20231214214201.499426-1-john.ogness@linutronix.de> References: <20231214214201.499426-1-john.ogness@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 6c2afee5ef62..ac2d9750e5f8 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 22bb45d8f2f2..82dc2c7949b7 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 @@ -2592,26 +2615,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.39.2