Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1208969rdg; Fri, 13 Oct 2023 13:44:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8gjoWDUQNzxIiQ9+nnszkjwl0X1n/cvEbxe4tqCs+mrqhG7WsU9iRaJiSFIPmEXkr3mgk X-Received: by 2002:a17:90b:1f8a:b0:27d:5174:442f with SMTP id so10-20020a17090b1f8a00b0027d5174442fmr1300138pjb.6.1697229845555; Fri, 13 Oct 2023 13:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697229845; cv=none; d=google.com; s=arc-20160816; b=iqPsEOJB3PGQuvvSunKr/IFYDIzwOOvP8YBEjJodEB7+RuMyC8uBDbO5TfipOsj0Ya SbLq0lpwIy0xp4Qd014KWxoZmwFKN3rox0pwNp/01PhSBBszZmeddk1UYpna7feTHA7L 4qWwR4TCo3q4K0iT3EveZ2HLa/gepgfBpRw3Lvu/q1CHC5kFoCIxeN2Se+MZ/+EVK1BG qCw6Sp12ImhIo7rsgoCVut12zVZ9UWZmwXArRNrcGxQGAmpBI/5Hta35WPh9VbljT4qB FGwH3fLsxYnUwfQbodEIJYWvs7VDsQQ17IEDhRrIxjoyY1fZTWNWh0nePQe1MUb2ZmqQ Vdcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=mYzxkwxZz9LXzgUZOnKlYZjB7QiQP/AcfRfhCkfffWU=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=wBfjJILRU9rLmwHHMTAxNKwgWaNs3QHrgWrD+2PngMZqgz+z+XAs6wLbaJx2A/a0Ox yEujmZIh5uyL/jgFA2H2cmj0Qr5oqtSn+KCQCosgCw/OVHxAkiWVkcp+7mSox+Zw8Pdj xF+W0jWkpKAXUS/h3lb+e4D0fZrddJLUdqNoWZN2EkDgC2yhx2ODPyGamix87ZDRTvvK RAacMO8VJJsuQIxCSm9aS8VBaoO6EGBst/fij3i6Xwo2WtYZrW/2QwkL3SUuD8/8F6ch E6LRGNjBNIzKBxrro/U+mY+lhMSGZDRaJrpaaBX3jDgxkmnNQsytWCiaYpi2iVgL3la+ hntw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WZF9t0mB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=6hKBtv1g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id my9-20020a17090b4c8900b002776a60ea68si914655pjb.1.2023.10.13.13.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 13:44:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WZF9t0mB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=6hKBtv1g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1599D82D1C34; Fri, 13 Oct 2023 13:44:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231892AbjJMUnx (ORCPT + 99 others); Fri, 13 Oct 2023 16:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbjJMUnt (ORCPT ); Fri, 13 Oct 2023 16:43:49 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05387BB for ; Fri, 13 Oct 2023 13:43:48 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697229826; 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=mYzxkwxZz9LXzgUZOnKlYZjB7QiQP/AcfRfhCkfffWU=; b=WZF9t0mBANVVYkG73VGE2cN9flCFUsOuRIGSTjLh39C2aw1HMcMzyIPfC/MmiyXrLYaK5g R0bY39rCL7Fzd3cmOUf3Ex4hjJSypZFhxMpCeZ/xxkpTO359ocBukhcahue4qNpr4e/P9Y 6HT4UK6SUSfrwtZVyytH9FPP1EFwpOt0hcFycJWR7Oaeg9ToQj6Apk56GD3nhDGd1XQVb6 k595uNASeRsswgmi1n28OH5L2xnTVM0Ga+UAUvNcHnvW/AfH40GirLApj/OR70xIqxiZFr IAhU2Hx3Avw6LcE9mS0Y5fujZo6T52AUBcYizxwwkL4tFZeY7/SqIdVJIEdbFw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697229826; 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=mYzxkwxZz9LXzgUZOnKlYZjB7QiQP/AcfRfhCkfffWU=; b=6hKBtv1gpM+ovw3KsKEpHuHn+ASfz/FSSRdq218lNqAJ7oTvpZYhdN2xIgzOq3BWX1rVIJ Ob1sJiFebcu1iiAQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 2/4] printk: Add this_cpu_in_panic() Date: Fri, 13 Oct 2023 22:49:38 +0206 Message-Id: <20231013204340.1112036-3-john.ogness@linutronix.de> In-Reply-To: <20231013204340.1112036-1-john.ogness@linutronix.de> References: <20231013204340.1112036-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INVALID_DATE_TZ_ABSURD, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 13 Oct 2023 13:44:03 -0700 (PDT) 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 --- 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 7d4979d5c3ce..2397734c0fd2 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -105,3 +105,4 @@ struct printk_message { }; bool other_cpu_in_panic(void); +bool this_cpu_in_panic(void); diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index abb6a50ee26f..19b752880879 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -351,6 +351,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 @@ -2610,26 +2633,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