Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11997023rwl; Tue, 3 Jan 2023 07:38:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXuLNrLdm5em+bpHF0oscfn6DJNgXGeYEL/a61uCx5hNe3DNkIFsJ7WhnxrhqMMcmwWINb3m X-Received: by 2002:a17:906:838f:b0:81e:8dd4:4ea8 with SMTP id p15-20020a170906838f00b0081e8dd44ea8mr33529515ejx.69.1672760291063; Tue, 03 Jan 2023 07:38:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672760291; cv=none; d=google.com; s=arc-20160816; b=jXYB3yW8+H3j3xLITi9soNhWg2Uy7TNPlvAtarWRuUDBjz/crByq/HxTGU75o5umRU ReiWZnlCfReAbf/WgdmxfzswFn2s0fr1dAWLVsJe3KECivYEvi75RL0s8X6S/u7UB5Vc wVgt1yCeivX2CAaYKDx9oScbbGwFGv4vAo3jINWaIfmolUeRQUSMu7bNssx+clEJi48P D1qk7s9W/HDXgiSHlLFglkLe9mOChhes6VVYqt5sL3h+E4mR7l4I+CjHEfFRqogYqULt DRv1FOnWxJOvQegfQjm6U3WesPJrA99t47g5cK45uuhyIiFsuvKe6xyhpy6u7BG68cD5 PZWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=e7z7CUNlsanp+SPsDxU+kUkk2ziXu09FTtaRiMc8sLk=; b=EfAwF6XI1NZzAXw5cwsMFqWu8FtGYygKSXzWGbRjj3cG4pCXGT6ylvl+kO/LNBjk9C HCTzEh7qnq4alaBAc2hbP34aGRSeauOIoCQ5rdHBRXadew3+UZnNU75KYlqVkFnSaVSL 7vGdjYiMsRKId9oDwMhnn1n98M0Ztk0XiXHW/x/WfDucZ/hR9GVUpze2gNS3QGzQQoAT mPJWfII6rpfBHrp3QLLUOzINcaE8jA3VB/chKGJOvyv9maVfj3QQb56wftYmVuKr6DeS nCO7KYgYBSHFDvLA6O853inmm7zuHyJ2dwL3awoPoOu4HOgb1fkJFRpz3hwVgs1LOxtv 3E0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DlyQin0O; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=0Cxs5uJ8; 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 ds1-20020a170907724100b007bf70b8527asi28384499ejc.563.2023.01.03.07.37.57; Tue, 03 Jan 2023 07:38:11 -0800 (PST) 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=DlyQin0O; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=0Cxs5uJ8; 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 S237653AbjACO6j (ORCPT + 60 others); Tue, 3 Jan 2023 09:58:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238208AbjACO57 (ORCPT ); Tue, 3 Jan 2023 09:57:59 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2C1422E for ; Tue, 3 Jan 2023 06:57:57 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1672757875; 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: in-reply-to:in-reply-to:references:references; bh=e7z7CUNlsanp+SPsDxU+kUkk2ziXu09FTtaRiMc8sLk=; b=DlyQin0OsEKElx4hYsx/267klTWIelW3dGApenDzv6Xruj44R2wal0V8aZbzw7gFYRyeJf OUHqKpo0jSd1lzVjH8dD4qLR1oXTMlRuMzi13zxSmqdTqXVPaG4rEoHJBIf11cAxJXbfiY 7h/oBFQ4K98b/CAos6YT1hDDDZUn8MLbP+PEqdaHpgXAh2bzAakODazlGb6+y3IwqWVJnt ELLso9dEcqd4xEKv+piTu2HStLcfmk3sf9exQC+JUIgnGU+brgDaHIQUdtvWkMna9vWpWv pinlMzhdzH0bgEllcpVb9wYtVT/sJGvmQX+isQyl4h8RkkPjyCVW1+b4Pe5uaw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1672757875; 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: in-reply-to:in-reply-to:references:references; bh=e7z7CUNlsanp+SPsDxU+kUkk2ziXu09FTtaRiMc8sLk=; b=0Cxs5uJ8Vio3XZoYVwkn68Y9s9X4SQK3Mgf8Z2S3g4oX9HY+wqGKFrHlph1+9z1jIlVYis d8diMOARWb4BRpBA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH printk v3 5/6] printk: introduce console_get_next_message() and console_message In-Reply-To: References: <20221221202704.857925-1-john.ogness@linutronix.de> <20221221202704.857925-6-john.ogness@linutronix.de> <87bknva1jg.fsf@jogness.linutronix.de> Date: Tue, 03 Jan 2023 16:03:17 +0106 Message-ID: <87ilhnd5te.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 On 2023-01-03, Petr Mladek wrote: > On Thu 2022-12-22 16:47:39, John Ogness wrote: >> On 2022-12-21, John Ogness wrote: >> > +static bool console_emit_next_record(struct console *con, bool *handover, int cookie) >> > +{ >> > + bool is_extended = console_srcu_read_flags(con) & CON_EXTENDED; >> > + static char dropped_text[DROPPED_TEXT_MAX]; >> > + static struct console_buffers cbufs; >> > + static struct console_message cmsg = { >> > + .cbufs = &cbufs, >> > + }; >> >> @cmsg should not be static. The whole point of the console_message >> wrapper struct is so that it can sit on the stack. > > Well, it might actually be better to keep it static for now. > It always points to static struct console_buffers cbufs anyway. > > It would make sense to have it on stack only when it uses > different buffers. I think we should avoid making things static when it serves no purpose. > Which brings the question. Does it makes sense to use > the same buffers by different struct console_message? > Will it be safe in any situation? > > I did not want to complicate it yesterday. I think that > I have already proposed this. But this brings back > the question whether it makes sense to have two structures > at all. > > I still think that it would be easier and even more safe > to put everything into struct console_message. > > I mean to have: > > struct console_message { > char buf[CONSOLE_EXT_LOG_MAX]; > char scratch_buf[LOG_LINE_MAX]; > unsigned int len; > u64 seq; > unsigned long dropped; > }; The current atomic console proposal allocates 1x cbuf per-cpu and 4x meta-data per-cpu. Different contexts of a cpu will have different meta-data, but all the contexts of a cpu will share the same cbuf. If cbufs become embedded in cmsg, then we would allocate 1x cmsg per-cpu. But the atomic consoles would still need their own 4x per-cpu meta-data. When looking at the proposal code, it looks wrong to have meta-data fields in the cmsg struct that are not being used. But maybe that is acceptable during the "transition phase" until all legacy consoles are gone. For v4 I will drop the console_buffers struct. I will use your suggestion. John