Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2357562lqz; Tue, 2 Apr 2024 15:15:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXh3X58oTbLkiAGuCkkLqG9QvYR8DoPK8dsB450UM7TmPulkEpd5yPtr9dDybupeAko3FtnKZMz/3EnxyG7qVYZtqC0v7OEA5jaiGG4Cg== X-Google-Smtp-Source: AGHT+IF9aFxpGUn4eWqmTpB4kj6Ue8XoDrzYxLTtAUQILA7dPDK6R/uqeDYInCeVldjEc7v0uMg9 X-Received: by 2002:a05:6808:118b:b0:3c3:b10c:efad with SMTP id j11-20020a056808118b00b003c3b10cefadmr14214865oil.27.1712096105160; Tue, 02 Apr 2024 15:15:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712096105; cv=pass; d=google.com; s=arc-20160816; b=MRnd1J6uWlkP0pv7GFcrPMV7WtewcYrOgHFji+U02CfhfIQHgM3ZC41OZRc/Hf+tuf BwA/9lOPMKJjliGbrY2lMlyH2H0Yhvz8E8dKGldOQZV/GUu7rP9cBmgSbN58R+7Ql9fE CHgnd9xIrV29nqUaqqXLVIQtviEBGT2jvZxYZKyxgxo1kiHMjRd986dvBzqbDgEGKVi6 tJKSc+w6v2aspPXpXcO06x2yXLw90J9c6c4ISKzDUaoxVwcyYfYCJ3NMNmLxIUQyYiBy 3tlDcoocYBoQoT3Z55H30gVIh9PgDtwPPjTl31S/bZLlXl4YHjPXRFrK998R4vn0bAq8 uvOQ== 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=MJEBBwWx+7a9Zf6U00LLvkq51McCiYjQLaxDLROSFw4=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=HfVBuwUsomuScqD2c2V4K89JhQ0hUjBS3qfZxgdTeNI6rEmdlCoGzIgHu/UEQytWVS P/F4nI27O4TLAkFIpbCZ2lsaFUEVaRfcRvkzVW5GI2Bskxj/p0UVj26OeKozxyix1Q4O htwXML0f7jTXvEkrWDb2D2T2auSxQVBysVn1/1C6azG7k+/9YyppsCLjshTB4VE1lGQ2 qj6hhFri8dMGlv9iL++L1QEqvH683Sv6GcUmaYw3tJTVbkFHzFAlYohE35FHt8JYhEzD jPgyVPI9gHFQiVQc/nqa+n+OmQ+HlQv8HZdSWyPM9JRtit9yJjEVB7vnvFR8IT1RTg98 0z0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iVqydypU; 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-128778-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128778-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 v2-20020a05622a130200b004313fb77480si13334335qtk.360.2024.04.02.15.15.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 15:15:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128778-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=iVqydypU; 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-128778-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128778-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 D875C1C221D6 for ; Tue, 2 Apr 2024 22:15:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A79416190E; Tue, 2 Apr 2024 22:11:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="iVqydypU"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zFndZ9+h" 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 892C316079C for ; Tue, 2 Apr 2024 22:11:45 +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=1712095907; cv=none; b=cGljrNoOl7zGV1TBg4dNYa6CHfhBE26lV+dYCD4aLiTuPt3AOkP6dtHsaUT/uPObuLjW3NFMP02BfkmPEZ7NA1ffhGm6I/6lHs7KUf0LSglDwWfQh7ggU4IurAFjaDty1bpFWYuGb9uydkbM2lufOSPPDpjutNF2917H3gi/MEU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712095907; c=relaxed/simple; bh=/yzLu1pIIII3CwMbKuTCCS8fK4EldDhvROOaEuVQjWA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kau4q9xgeGatmizdiZHBw9ako/DblJNX+tukknNOaLxpt0EUE8mM26rhYxys5bEAXRWwqLS0j0PxwQf+AhJb7JUL2G0k2tc3+pMmNei1qLIOkvCr/MS7ql5n5KTPG3yKHCY1xVOJzbYzR935LBv5ihgG1rXwdOxp+ZyYlGgUS/k= 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=iVqydypU; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zFndZ9+h; 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=1712095904; 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=MJEBBwWx+7a9Zf6U00LLvkq51McCiYjQLaxDLROSFw4=; b=iVqydypUc7tJSDm6VB9QaXe/HXQ5DEwl210/4AxLpwljFtDmsSN//45eB0hNGYdxPPPPf6 ZW4tVFFVt7Wb4wEfjk+JXJ+v3KyMDR64Gc4ANWk5O/lYRu9/OPA1U7UCJbtiTcFGVkAwUp y+bgkmFe0fN0fLnTW52dX3+cK+/V2kOlF+6ySyulcwjujOi6UVwYBUBGBQSNNDTAb5//bd hEQilKsodOpvulQrvVDtE3Fu2DivKoDpwg2/ptrIqrwnuA+TgF62Ogu8p6Y4nhSLASzHq2 hEDjTSfN5dYN7kjvYUIRfBR+wTwRsZSk5uW5AHlFYLBVwl3sCSiN0HgRVrwL2Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712095904; 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=MJEBBwWx+7a9Zf6U00LLvkq51McCiYjQLaxDLROSFw4=; b=zFndZ9+h4vcpEiCP4WGOKnhKSrlI9j9E+NdpsnYdNYmJgrGqOTD4vBUNhvwy1EG1OKAGHu P3LjnK4RZMIRECDQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v4 18/27] printk: nbcon: Assign priority based on CPU state Date: Wed, 3 Apr 2024 00:17:20 +0206 Message-Id: <20240402221129.2613843-19-john.ogness@linutronix.de> In-Reply-To: <20240402221129.2613843-1-john.ogness@linutronix.de> References: <20240402221129.2613843-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 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_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 | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h index acf53c35b7a0..bcf2105a5c5c 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -86,6 +86,7 @@ void nbcon_seq_force(struct console *con, u64 seq); bool nbcon_alloc(struct console *con); void nbcon_init(struct console *con); void nbcon_free(struct console *con); +enum nbcon_prio nbcon_get_default_prio(void); void nbcon_atomic_flush_pending(void); bool nbcon_legacy_emit_next_record(struct console *con, bool *handover, int cookie); @@ -143,6 +144,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) { } static inline void nbcon_free(struct console *con) { } +static inline enum nbcon_prio nbcon_get_default_prio(void) { return NBCON_PRIO_NONE; } static inline void nbcon_atomic_flush_pending(void) { } static inline bool nbcon_legacy_emit_next_record(struct console *con, bool *handover, int cookie) { return false; } diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c index 599fff3c0ab3..fe5a96ab1f40 100644 --- a/kernel/printk/nbcon.c +++ b/kernel/printk/nbcon.c @@ -967,6 +967,22 @@ static bool nbcon_atomic_emit_one(struct nbcon_write_context *wctxt) return ctxt->backlog; } +/** + * 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_legacy_emit_next_record - Print one record for an nbcon console * in legacy contexts @@ -1001,7 +1017,7 @@ bool nbcon_legacy_emit_next_record(struct console *con, bool *handover, stop_critical_timings(); ctxt->console = con; - ctxt->prio = NBCON_PRIO_NORMAL; + ctxt->prio = nbcon_get_default_prio(); progress = nbcon_atomic_emit_one(&wctxt); @@ -1032,7 +1048,7 @@ static bool __nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq) ctxt->console = con; ctxt->spinwait_max_us = 2000; - ctxt->prio = NBCON_PRIO_NORMAL; + ctxt->prio = nbcon_get_default_prio(); if (!nbcon_context_try_acquire(ctxt)) return false; -- 2.39.2