From nobody Mon Apr 6 04:44:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81CFCECAAD3 for ; Sat, 10 Sep 2022 22:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230484AbiIJWa3 (ORCPT ); Sat, 10 Sep 2022 18:30:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230470AbiIJW3G (ORCPT ); Sat, 10 Sep 2022 18:29:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF1284362D for ; Sat, 10 Sep 2022 15:28:16 -0700 (PDT) Message-ID: <20220910222301.939249419@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1662848894; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=1gLj17SVnYEqJIpQXxtTYqtNvfOkCPZwAPnJd+DRrik=; b=eEVBRaEBQWd/tHXCwHaKJwdtLXqBe1gkIMqlIfFXi/TOnbKB6kpVOYZmWDZvB/fhRTVwSm UqhqOwvxvakJv1KsCkZG5qUq35E8kPz5Htuo0dFY8AVvIATpufeqxac/KfAT3ay8v9udmC W6ulZcXKomKLQrQTnf2iWT44OAhbLoTC6tsYZKiGNyfcq7yEQJlFuWQ7ulbib6R2AYU/la O4LLXGimYc4qowbG9KDPpFJ0UuJQNqfIwRCGfzynW9jvAb8DvghDLRxkG98YDF0lQIf1y6 8ugoonVE6y6Fywz0SV5r+//r2Y1PiGpBHvygvgn9qhFzDeXcYtwBfQobuR9kjw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1662848894; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=1gLj17SVnYEqJIpQXxtTYqtNvfOkCPZwAPnJd+DRrik=; b=npjxPp0NuVdubxR6QH6WlgL8ozDbJVxX7Sr4Lxr7gb1jAaYUjKSfONfYaDEwkstcLjN4t8 1v7MnWA0br5mUCAA== From: Thomas Gleixner To: LKML Cc: John Ogness , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Peter Zijlstra , "Paul E. McKenney" , Daniel Vetter , Greg Kroah-Hartman , Helge Deller , Jason Wessel , Daniel Thompson , John Ogness Subject: [patch RFC 27/29] printk: Add write context storage for atomic writes References: <20220910221947.171557773@linutronix.de> MIME-Version: 1.0 Date: Sun, 11 Sep 2022 00:28:13 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: John Ogness The number of consoles is unknown at compile time and allocating write contexts on stack in emergency/panic situations is not desired either. Allocate a write context array (one for each priority level) along with the per CPU output buffers. Signed-off-by: John Ogness Signed-off-by: Thomas Gleixner --- include/linux/console.h | 7 +++++++ 1 file changed, 7 insertions(+) --- a/include/linux/console.h +++ b/include/linux/console.h @@ -253,6 +253,7 @@ struct cons_outbuf_desc { * @CONS_PRIO_NORMAL: Regular printk * @CONS_PRIO_EMERGENCY: Emergency output (WARN/OOPS...) * @CONS_PRIO_PANIC: Panic output + * @CONS_PRIO_MAX: The number of priority levels * * Emergency output can carefully takeover the console even without consent * of the owner, ideally only when @cons_state::unsafe is not set. Panic @@ -265,6 +266,7 @@ enum cons_prio { CONS_PRIO_NORMAL, CONS_PRIO_EMERGENCY, CONS_PRIO_PANIC, + CONS_PRIO_MAX, }; =20 struct console; @@ -327,12 +329,17 @@ struct cons_write_context { =20 /** * struct cons_context_data - console context data + * @wctxt: Write context per priority level * @txtbuf: Buffer for storing the text * * Used for early boot embedded into struct console and for * per CPU data. + * + * The write contexts are allocated to avoid having them on stack, e.g. in + * warn() or panic(). */ struct cons_context_data { + struct cons_write_context wctxt[CONS_PRIO_MAX]; struct cons_text_buf txtbuf; };