Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp3588714rwn; Sat, 10 Sep 2022 15:32:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR5GhPwyyhASfbG6PycWaUreYIOcfALB0wQAInmq4rnPn/pesrP7MZhbIJPKnSe9UGW3UQNw X-Received: by 2002:a05:6402:2712:b0:448:e383:1f37 with SMTP id y18-20020a056402271200b00448e3831f37mr16791263edd.375.1662849157217; Sat, 10 Sep 2022 15:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662849157; cv=none; d=google.com; s=arc-20160816; b=yElW94Ey1blZvWzFkwHsbYM8begDPSvw53jmtKSY9+U5gNCfGENtQxrQCaMo3ha3NO 4N034whYpKSrQfouZyUkP75CK1qL07pPJ0TTJ1s8EloqtrFY+AxhWZ9FhGsNkgCt9Zo7 CrFFCrXe3MzhIe2XzTTeg4NZ/jFuuzLsHU0q1o3VQu+BRFN5w4uh/y0T2nomeyoFNZvl Ne7OYXgbP6fhaUzSmQsm/n1XQ17wm/ZXMhDkHnXIzxHitK1/9aRNILjMnAEA9jvzeeci Iw0wjZ/5BY+GS5YgDduztQ7CfzKpLTizeIaPu6SrwG3xdQRJu496A/Ru9QfG3yUM1V42 lTdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=1gLj17SVnYEqJIpQXxtTYqtNvfOkCPZwAPnJd+DRrik=; b=BdXzo/0rKU6bIUFEwF3g/W6k13O+t6vNNX9KSMKXSsm4JqNJdyyybQRYq7JNzhZBKW 0vi8/MJGsRldQZl082U9kfLJTavRcjlsNPc5MtM4O2DoKUB8Rjkb+2xjDxZbX5uTZu8d z58AwUbz/oRwN0G1EsQs8IwoBP7VWR/xGs5axoqqkgg61nx9Li24vxBoSJwoKHGke6fK Xn9Znug6NFmRiIwjRAhA346xbQZZZnuaFUmzPeCBXSRmwDiwGV7s/i4D1W2qYd26vfRa 1wA6uN4kQMYP/tqvoV2HbwUPv/1iGLlTLFDl2LDpKssx8p1xKVXCQE/pnflox5mD02Jo 5GiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eEVBRaEB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a170906780b00b00741a3548ca5si3385530ejm.761.2022.09.10.15.32.12; Sat, 10 Sep 2022 15:32:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eEVBRaEB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230480AbiIJWa2 (ORCPT + 99 others); Sat, 10 Sep 2022 18:30:28 -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 Content-Type: text/plain; charset=UTF-8 Date: Sun, 11 Sep 2022 00:28:13 +0200 (CEST) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, }; struct console; @@ -327,12 +329,17 @@ struct cons_write_context { /** * 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; };