Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp9507488rwb; Thu, 24 Nov 2022 14:12:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf5vpegH2w0ByY0uzNwahPFTz/aCOBoW4FJL8lsUaL6Gip7aTkPn+Yafv3JHYiHw5UFJVow5 X-Received: by 2002:a05:6402:cba:b0:46a:3666:97e9 with SMTP id cn26-20020a0564020cba00b0046a366697e9mr8154186edb.311.1669327978870; Thu, 24 Nov 2022 14:12:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669327978; cv=none; d=google.com; s=arc-20160816; b=HBYA6Y2YT5AXXccZhu9azPDNpVSSxtrgzkLsxDMKSCUB9De4lIz25/r1QEIuwXOAcO OpPeyIokkRTDaHCxS3va5vXvRs8sSipIF6QRHEsMOT5X0iOSvgrnIpY1x66OjGwb1YAe IQaFuwiyUZjU30rybUy1xWJTj3enbTfVqr1ysrHoYPLH3Ght5dtZlfjVE3kMVcAK1dsY bIdj/8k+YeVbH/ixfcvtRQHwnpTE8y945701J7uU1JR+ozRiaI27Qhx6Eb26dF2gykM/ mD0xG/XVgNH765eRPpou1iT4ycXzk/P/h+7oUHYT32nEqoi2WsppAkZvTl+U11tG4Y3M l4sQ== 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=STjMXZbqhHt2AZsaB++TQDIVnU1zjXIbAYWgnK6f29A=; b=xV7kSuCPFNVm69suv7ohJ5Dle7h24PRBh1UT99qbahJGm4DYMDo2zVRNWvFpm7IyP4 FcUi31XnY4POczUxiagocSBwG+i88hLw+HnWFStfI91z4Cj8R1vlpNS11eVcDUUp90in Yz1xLHphbxVKNgKQlwEwSKWX++biUOR7NiMq29/1oX5tdQlnOrF7Ubc13AkYWXeEf4Fp GuBniu9J+2p9H6pG532+EgqtShDJTa1Px0zLkE5kolG/ZCFDs26R96LAesazVdBPByrJ dOFSWD1nhVgezLi3XqMCLh50DGGkeMQI1pU/fG77FKllq0LWtND2rIyW6vU/7mHDlNwG YXgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=U5uUaZoy; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=flApnUH7; 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 e15-20020aa7d7cf000000b00467ad3f4426si1308882eds.312.2022.11.24.14.12.36; Thu, 24 Nov 2022 14:12:58 -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=U5uUaZoy; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=flApnUH7; 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 S229514AbiKXVPW (ORCPT + 87 others); Thu, 24 Nov 2022 16:15:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbiKXVPV (ORCPT ); Thu, 24 Nov 2022 16:15:21 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC67492091 for ; Thu, 24 Nov 2022 13:15:19 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669324518; 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=STjMXZbqhHt2AZsaB++TQDIVnU1zjXIbAYWgnK6f29A=; b=U5uUaZoyr+zoIr7ZFLM925jn9+16NoI+eic8QdQWa8rDmgtAedwsyi3kDxPob+Bzd0Lwiv j8tANCbtLXcYd7mZKrKe4CO2CoZ1fgvrceyaMSf9Tug6T+B9ruq2lYCdYyV9AIspk/2okh ecGEk3GuP5XXJnuoFO59CIDI0uOqHoVzd0tkiDWdmvVNj8onm0/QFwAXvIXmntnWaziePn Su796FGyr2VtY3650f97GLUDh1yXFjk0zuFJMyLrkdV97ti0ILSMaAysgyDyrlKLjBl5zc 1iky8DoCPdXQuHkBto+t2kYjcqjqNdNUPU8O9NIGeGw8c+n0GpGkTxN/kqe4qQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669324518; 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=STjMXZbqhHt2AZsaB++TQDIVnU1zjXIbAYWgnK6f29A=; b=flApnUH7mrhia1zsMHaTWo7TBeO3TBJ8PJfpIbPMcTlZGSAeoPWUtDR63MnQEpSuiurTm2 6B3osPTBsNMOPqDg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: Re: [PATCH printk v2 6/7] printk: Use an output buffer descriptor struct for emit In-Reply-To: References: <20221123231400.614679-1-john.ogness@linutronix.de> <20221123231400.614679-7-john.ogness@linutronix.de> Date: Thu, 24 Nov 2022 22:21:08 +0106 Message-ID: <87o7swkqar.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 2022-11-24, Petr Mladek wrote: > I wish, this change was done in two patches. 1st introducing and > using struct console_message. 2nd moving the code into separate > console_get_next_message(). OK. >> + if (cmsg->is_extmsg) { >> + write_text = &cbufs->ext_text[0]; >> + write_text_size = sizeof(cbufs->ext_text); >> + len = info_print_ext_header(write_text, write_text_size, r.info); >> + len += msg_print_ext_body(write_text + len, write_text_size - len, >> + &r.text_buf[0], r.info->text_len, &r.info->dev_info); >> + } else { >> + write_text = &cbufs->text[0]; >> + len = record_print_text(&r, console_msg_format & MSG_FORMAT_SYSLOG, printk_time); >> + } >> + >> + cmsg->outbuf = write_text; >> + cmsg->outbuf_len = len; > > Please, remove "write_text" variable and use cmsg->outbuf directly. > It would safe one mental transition of buffer names: > > cbufs->text -> write_text -> cmsg->outbuf > > vs. > > cbufs->text -> cmsg->outbuf I originally had the non-extended case without @write_text. I felt like it was harder to follow what actually got set. Really the main objective of the function is to set @outbuf and @outbuf_len. I felt like moving that outside of the if/else block made it clearer what is going on. But I can go back to having each if/else branch set those fields in their own way. > PS: Please, wait a bit with updating the patches. I have got yet > another idea when seeing the code around dropped messages. > But I have to sleep over it. Don't worry. I always wait until you finish the full review before touching anything. ;-) > My concern is that the message about dropped messages need not > fit into the smaller "cbufs->text" buffer. It might be better > to put it into the bigger one. This series _does_ put the dropped messages in the bigger one. > We might actually always use the bigger buffer as the output > buffer. The smaller buffer might be only temporary when formatting > the extended messages. > > We could replace > > struct console_buffers { > char ext_text[CONSOLE_EXT_LOG_MAX]; > char text[CONSOLE_LOG_MAX]; > }; > > with > > struct console_buffers { > char outbuf[CONSOLE_EXT_LOG_MAX]; > char readbuf[CONSOLE_LOG_MAX]; > }; > > Normal consoles would use only @outbuf. Only the extended console > would need the @readbuf to read the messages before they are > formatted. The "problem" with this idea is that record_print_text() creates the normal output in-place within the readbuf. So for normal messages with no dropped messages, we still end up writing out the readbuf. > I guess that struct console_message won't be needed then at all. Since we sometimes output the in-place readbuf and sometimes a newly written buffer, it is nice that console_message can abstract that out. Also, right now @is_extmsg is the only input variable. For thread/atomic consoles, the input variables @seq and @dropped will be added. console_message will then have its own copy of all the information needed to let itself get filled and console_get_next_message() will no longer require the console as an argument. This is important for the thread/atomic consoles because it removes all locking constraints from console_get_next_message(). For _this_ series, console_get_next_message() still requires holding the console_lock because it is accessing con->seq and con->dropped. I could have added @seq and @dropped to console_message for this series, but for the legacy consoles it looks like a lot of unnecessary copying. Only with the thread/atomic consoles does the benefit become obvious. > It might help to remove several twists in the code. A lot of this is preparation for the thread/atomic consoles. It is a little bit twisty because it is primarily designed for the new consoles. The trick is to get us from old to new without things getting crazy in between. I appreciate your comments. You see things from the perspective of the "legacy consoles", which is helpful for us to keep things clean and maintainable during the transition. John