Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1425784lqm; Thu, 2 May 2024 14:41:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9XxmVv0tPsTzohcs1wQQh95T7tt0lMdS2XH4RSi3Mao8JvXo8NTu+TGGrV3+T7Hcql0jdQSAl8glibrZq0r+7/OlE+4BkwFwAE7u79w== X-Google-Smtp-Source: AGHT+IHMTi4FZdSY9ime5E6z2IuVwNgy577JiCs6OBmicSOeU2wkeQ8fqM12nOmjVnbolhNJipcX X-Received: by 2002:a05:6830:1e31:b0:6ef:9347:7d20 with SMTP id t17-20020a0568301e3100b006ef93477d20mr1318152otr.10.1714686106238; Thu, 02 May 2024 14:41:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714686106; cv=pass; d=google.com; s=arc-20160816; b=mSRaGKfGJYWqHH7+VObi/rH+mEp9hvWzcA4NcJxQ+YBqHcnoU+Ye6t6XsHjRPSM0Lr iQ/TZTU/Tlpk5zVUqIQ1+kHAxgBU0HHs9y7Ao3GMstNNvKUHRk31F2bzDyvWwt0b3kxy WWI4HtTkYs/eWMBf62mA/BUfm3m1tD9K/GFftrO2/jxhimU0fLERqPc1tnyLSOSfQA8F NUgOj5Owqxdb9hdmsqohPjSu6FZj/9MIWZs2l8t4ZrOf6nP64Z2wOmwh7X69+WgEUiFL c4JKC+ewS2GCGMHC6zwA0p3lMypfwB+Xm6sXzVVxLImQPScZB6PJfSKKGYCaEX60OhYB 5Mog== 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=xZtMTVl1yOdxUwgi1uSJ5RX46gAn8gugProPBvxHrmg=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=Jr6FsFtfh5jq7QBG2Tmov5dSCK+CAU++fcVfOCUmxh3SorFYH6RiDNTjp8EQFKZia1 tCsKF6U5zfU591HCOWWzA/0nT6nP7j3X2YbtI0HQUwhfIp3bzpITSXr2j8BO/biVbDU/ Z+Prmx+LCIEHhaCYwdxRwuHhgUbEsIp41YNk8LyysBZGC87YhAuY2IwBFfNSL4CMTyek eAt8B7JBpKfOglA+1zTk+g5KCKPXGE5wC4howTO4tN9gMWc8qom+N3emizFCmfGt0zKk PkVSKhXsNwLxcg08I9RNhpVc8zzKL0uDMgMSNxzS8lEmNtMxBLCI+lTUo8Vrp0m7sW7n et5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="yLAB//lY"; 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-166968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166968-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c25-20020a05620a201900b00790f9c80ca4si911643qka.509.2024.05.02.14.41.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 14:41:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="yLAB//lY"; 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-166968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166968-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id ECBF61C2201B for ; Thu, 2 May 2024 21:41:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12AFB1CB323; Thu, 2 May 2024 21:38:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="yLAB//lY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="eUdzEyLe" 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 B2A751C660C for ; Thu, 2 May 2024 21:38:52 +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=1714685934; cv=none; b=DEJsxzH7M3EfI5QRhHQkebayWnPLnMN0F/r5yw1dTHcj+LOstj36ZPcD3hanzuvlyn0ZBn3PbB+2CCZ31uJugIqF9rFroFcNA58kjbRPMp9PLccv0FTRmJHVTRg5NFnFY7ErOxM3qjPkH/oKVEXfj2nm+LFjSPSiCiOSSQvhagI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714685934; c=relaxed/simple; bh=tOlb55GZsIaT9cynpsyj5UhAczLLhu/zc6LG7enM9MM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RsdDEtblRzkSmHOmoWcH48dQeeCkuqGnek8A0IF8+rEgoYgDK7AInxRZ3kJEwSyAIf9LwuCf7okPMuxVzbHYTjVfLgO6FqQAV31/xetEwi4PbNkDMhOBvWfaZsxhN5J8COw3CsdSHlCy9jjSn0jxPNmoX4Umw86poe1atwgSX+M= 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=yLAB//lY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=eUdzEyLe; 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=1714685931; 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=xZtMTVl1yOdxUwgi1uSJ5RX46gAn8gugProPBvxHrmg=; b=yLAB//lYOLxA2VBr+Fmj4UrmcxxotVzWo6MUxgq9r9uOU5+EB8PBuFZiseZ+Ug6U5CQ39f QlhvNuf+72txiBwIe08ugIsqv+IzCUzYNs+YDW9BH8hGxjHJwLXOWovzY4QXOvvuq6p0xk FaO9+sL4sqtl9qgZg62T8pUWR8mkzR1A5IBhdKp3bSj5NfzPHtZqiKdoh+8tyLY6CML7tQ g76jFSS2AVa6CXROmo6t3gqsIC/l0MDs9wLylZ1r8icHZYrwwFnJoO/knQH2fyvqN3qS2+ QoL8C020KapG9y4S9cVohx7dHm39/XUyMHVT0IfRWXHkAATKrGn/Rs+tSWBNtg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1714685931; 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=xZtMTVl1yOdxUwgi1uSJ5RX46gAn8gugProPBvxHrmg=; b=eUdzEyLepH2X4yDnXVKEbC3+f7t8Wp3naT1xcOCcJAY2ZHMAUqswcFhlm3BDJxnhGsj+5x XzZ/FmwwUzt5HKCA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v5 18/30] printk: nbcon: Add helper to assign priority based on CPU state Date: Thu, 2 May 2024 23:44:27 +0206 Message-Id: <20240502213839.376636-19-john.ogness@linutronix.de> In-Reply-To: <20240502213839.376636-1-john.ogness@linutronix.de> References: <20240502213839.376636-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_driver_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 c429f4cfbb2d..e37af5c72d38 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