Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1877044lqb; Sun, 26 May 2024 23:41:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVJ/v3ShHd4eCcM6mNOF3bXJ6UeBtRVb+liZ80+6hU5C/GDTU8ekeZAM+QuZTeLYpI0ai/FSin6KtZeiYMjRQXSckxKxSWJX1mz18VeDQ== X-Google-Smtp-Source: AGHT+IH9dwTcAzyaCNxHrOQ70WYhQ7OO3YK4z9Yu7HLzm0wNTc6w5IJHjhadUPi7EXpTfn89bMvE X-Received: by 2002:a05:6a20:1042:b0:1ac:d96a:4fd6 with SMTP id adf61e73a8af0-1b212d5f500mr7994856637.23.1716792107902; Sun, 26 May 2024 23:41:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716792107; cv=pass; d=google.com; s=arc-20160816; b=ADgoYfR7uaKhaos4LSHUZdCl7b2VHEzzOQv/H85E9yqh4r28G7tC4S8diDWwaCDr31 5LuCZFCtKGmBqwnMnN1df8X2BZLce6Qpnsn0d+AScL60nc05UvIccY2QE/sLG7hvbXb5 8DPEwHNn6ZiOlY2VLwuxtdYCg/MyPIlLA77A3Gg/heU6sb3nir0ZriXzdNYNmvbn5TAQ P/HXv6eHWKyllRvOe2a3iLMW5pYaeHPtAb0QqYWZzy3wWUVHjAZfFfnllS0uCj1ZY552 qimSEtRPMh/bEPBL6dA9t6DAjnOm29SI8uFolHJ+p6o5NuO4qev0eGHSZnbgIf4NGHUH Bpew== 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:dkim-signature:dkim-signature:from; bh=OXVGPLDxDMAPJlIbkXd901VLd/8W6fOa0g3BKtOGhG0=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=ro2juP4zQIbgIfpdye71XXnN2rWNGTPHMDvD9owrjt1dgu1InkS+OWybIuDN0mNFLL XoWbCLQxm9isqix1epQQlaMG+AxbLIznEvyQJefCgQPn+lnC6wsfa6GvGyBPrHP+a2EZ Twfw9Cqri3U28jpkReVyBaqfwEZR+oVoCTge1c24v1grucStCbADS82ZYa+dcpfMYBu8 XfTnssoN1gAgh8We4hrpao69bQ6uK/o1LpKUmtKHYRcWrNPmfViMpGJiZbnoznMxqnTP +uO+urcjQEIdiLxAEth4VuyMTReIK/DtT/mHE4sNS5bFlC4q7PqjhfJTlQGihN1qJ3go E56Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CeAHKzSW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-190092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190092-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c788021si56869795ad.130.2024.05.26.23.41.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 23:41:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190092-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=@linutronix.de header.s=2020 header.b=CeAHKzSW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-190092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190092-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 1DD922824E3 for ; Mon, 27 May 2024 06:41:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B67513AD05; Mon, 27 May 2024 06:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CeAHKzSW"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="g2+bdbP4" 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 5051E2032A for ; Mon, 27 May 2024 06:38:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716791907; cv=none; b=o9uz1DI3IRk26bTfUgsZ6dBqkxdUTNDUkwWQjYHUdEm86rVYSM/qbUUCjVTuyjxHX62YT0md5/EqlcaEmmzO67ivXoUo8+vhOGcRI25wzZrkYSI6QQV7Hh9w+iODzA24z8wt0iXw8CzVZ07+n6Z09IjMFx/erGQ/tuYEni7SY4M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716791907; c=relaxed/simple; bh=zIdDnOXlkpAr4wXXrW1lnomWo/FU9/LQB9BST474AnQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CnOU06aPI9Jfi+sW/UmYCFDn/C+K9mofQqzq7RFDri9511PWKS7bl801skJXPnNvQTtAGmQeAGpmL5DwdS78zyu2LmvLpeFCGCL/dAvcxMAOjb7en5FrMLRmggIRBPr6pRLTd+LijlqZgz3AnGeby1EQTvP0op7+l/JgWYgOYdk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CeAHKzSW; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=g2+bdbP4; arc=none smtp.client-ip=193.142.43.55 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=1716791903; 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=OXVGPLDxDMAPJlIbkXd901VLd/8W6fOa0g3BKtOGhG0=; b=CeAHKzSW4cdqmhGzQqDTLKQs3MLS8+yqSD9TyagAHAb48WpOHu7+9d6ylcBV18Y6tAe/cC kZH4LhzGSyJ74JI5qnjizOS7uUi6zJnH3tqO2I9RDXFQSykhvdTUZC5BrZTUnPuhERNVsE W3aNLskrADDwyf5yP9/wT3J7K9MEZiKlAjWkwQQm/Ka3Qu/uCfcCrfB0jW2hLtnemwR6LP 7m1yqNGO47ueqJpL0nOUmc/9GBSEoE2kKivVQwPBmG7rNVAH1k0Rbh60vK0OxX/wzG1JJ2 tA6JCSqYbZNgSIPo5CteWm1bQWr6T2y9wuFg5qGMIqjXcDiLicguHXth2tESQg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1716791903; 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=OXVGPLDxDMAPJlIbkXd901VLd/8W6fOa0g3BKtOGhG0=; b=g2+bdbP45Z9sijA0WWF4y8B8XwyWGIA41osK/rA15KPnTEk1GETSpS5E79cHK9JDLyMSHn iAKyc36TtgC6PACQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v6 18/30] printk: nbcon: Add helper to assign priority based on CPU state Date: Mon, 27 May 2024 08:43:37 +0206 Message-Id: <20240527063749.391035-19-john.ogness@linutronix.de> In-Reply-To: <20240527063749.391035-1-john.ogness@linutronix.de> References: <20240527063749.391035-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 Add a helper function to use the current state of the CPU to determine which priority to assign to the printing context. The EMERGENCY priority handling is added in a follow-up commit. It will use a per-CPU variable. Note: nbcon_device_try_acquire(), which is used by console drivers to acquire the nbcon console for non-printing activities, will always use NORMAL priority. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- kernel/printk/internal.h | 2 ++ kernel/printk/nbcon.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h index e2de2d262db4..5826cd4eed58 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -84,6 +84,7 @@ void nbcon_seq_force(struct console *con, u64 seq); bool nbcon_alloc(struct console *con); void nbcon_init(struct console *con, u64 init_seq); void nbcon_free(struct console *con); +enum nbcon_prio nbcon_get_default_prio(void); /* * Check if the given console is currently capable and allowed to print @@ -138,6 +139,7 @@ static inline void nbcon_seq_force(struct console *con, u64 seq) { } static inline bool nbcon_alloc(struct console *con) { return false; } static inline void nbcon_init(struct console *con, u64 init_seq) { } static inline void nbcon_free(struct console *con) { } +static inline enum nbcon_prio nbcon_get_default_prio(void) { return NBCON_PRIO_NONE; } static inline bool console_is_usable(struct console *con, short flags) { return false; } diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c index 5c75ba28e80c..85bebea1a326 100644 --- a/kernel/printk/nbcon.c +++ b/kernel/printk/nbcon.c @@ -937,6 +937,22 @@ static bool nbcon_emit_next_record(struct nbcon_write_context *wctxt) return nbcon_context_exit_unsafe(ctxt); } +/** + * nbcon_get_default_prio - The appropriate nbcon priority to use for nbcon + * printing on the current CPU + * + * Context: Any context which could not be migrated to another CPU. + * Return: The nbcon_prio to use for acquiring an nbcon console in this + * context for printing. + */ +enum nbcon_prio nbcon_get_default_prio(void) +{ + if (this_cpu_in_panic()) + return NBCON_PRIO_PANIC; + + return NBCON_PRIO_NORMAL; +} + /** * nbcon_alloc - Allocate buffers needed by the nbcon console * @con: Console to allocate buffers for -- 2.39.2