Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1012468rwl; Thu, 5 Jan 2023 07:37:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXvBW3bnDYKyL1rkK1XD0oOiHs2h9VRL6KoU4yfKaMiF0gQzgj630k45NgS/oetQ9FpVS0P2 X-Received: by 2002:a17:90b:905:b0:225:dfb6:e8a0 with SMTP id bo5-20020a17090b090500b00225dfb6e8a0mr44320943pjb.38.1672933028455; Thu, 05 Jan 2023 07:37:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672933028; cv=none; d=google.com; s=arc-20160816; b=Nfhhj2wB1GlmcINZOyheCc2HkAv/ELwFmxueld6YhRKgvmnlLER7DxVVBn5kvppbMA 54v1pMW4bRipxmMjDLraQZdcq6vLdpF4EHSC2ntNe99B3g0tEpubJ70UW/HPEMWvpLv/ vtSfFWkthG2KE6iCwZd1cs2jHaJf9FnwOS2GhPcONcOvIdTHbNnqKvUw7PPeKzogwIeO +inoofLLxNnra1qvXU+4vGIdQjm6ovID0bcf6a/vyN55Wzx3IL2dvH6FM9yXVPvCpt+D 399kc4aGYqvD7rPaH3p6BBTTF4GBwED4TW+MTV6DGvxNZPrsDvNM5Ir+AEc190H+5Nd+ 6CPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=HnQ6VyXRKW3tyaLX6G3V+iyMhPkP3LSQm7J+d2Nw5Zg=; b=fzDK5+dztZINpQP1PBsaTko1n3oNGMoy/wpCHzTMlEbkk63SZBUAjXgQzbAvu8jk7j 9UD3WPqD56vuMhlixU/IKOPX0cePBvdeWnTsBHcCSSBHxeAwtsIR7uU8xnnWustEAxya 7YOidUMByhGxwBHYBJLW60KN3xNGX1WVmlHWoJuyLMaGW6HyfmuUD8nEweVKJlBqDtHd Py+RgxMbU+RJqhPuWHg1tixVIzkbRnMRQbavJv5TqHBJ7dm/J7kHcF1rRbnWcn/o7Lfu eFEvS1jKqJ/uX4HhQnyW2FrLO5KY2szDYA8sZj9L2fvBHAzNu+4g1GsaaB3JBPa0RdlJ Vyeg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bo12-20020a17090b090c00b00225f76112d4si2155231pjb.59.2023.01.05.07.37.00; Thu, 05 Jan 2023 07:37:08 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234694AbjAEPZy (ORCPT + 57 others); Thu, 5 Jan 2023 10:25:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234813AbjAEPZg (ORCPT ); Thu, 5 Jan 2023 10:25:36 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F08825C938 for ; Thu, 5 Jan 2023 07:25:14 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 634A7246F7; Thu, 5 Jan 2023 15:24:56 +0000 (UTC) Received: from suse.cz (unknown [10.100.201.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 1D87B2C149; Thu, 5 Jan 2023 15:24:56 +0000 (UTC) Date: Thu, 5 Jan 2023 16:24:55 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH printk v4 5/8] printk: introduce printk_get_next_message() and printk_message Message-ID: References: <20230105103735.880956-1-john.ogness@linutronix.de> <20230105103735.880956-6-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230105103735.880956-6-john.ogness@linutronix.de> X-Spam-Level: X-Spamd-Bar: / Authentication-Results: smtp-out2.suse.de; none X-Rspamd-Server: rspamd2 X-Spamd-Result: default: False [0.00 / 50.00] X-Spam-Score: 0.00 X-Rspamd-Queue-Id: 634A7246F7 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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 Thu 2023-01-05 11:43:32, John Ogness wrote: > Code for performing the console output is intermixed with code that > is formatting the output for that console. Introduce a new helper > function printk_get_next_message() to handle the reading and > formatting of the printk text. The helper does not require any > locking so that in the future it can be used for other printing > contexts as well. > > This also introduces a new struct printk_message to wrap the struct > printk_buffers, adding metadata about its contents. This allows > users of printk_get_next_message() to receive all relevant > information about the message that was read and formatted. > > Why is struct printk_message a wrapper struct? > > It is intentional that a wrapper struct is introduced instead of > adding the metadata directly to struct printk_buffers. The upcoming > atomic consoles support multiple printing contexts per CPU. This > means that while a CPU is formatting a message, it can be > interrupted and the interrupting context may also format a (possibly > different) message. Since the printk buffers are rather large, > there will only be one struct printk_buffers per CPU and it must be > shared by the possible contexts of that CPU. > > If the metadata was part of struct printk_buffers, interrupting > contexts would clobber the metadata being prepared by the > interrupted context. This could be handled by robustifying the > message formatting functions to cope with metadata unexpectedly > changing. However, this would require significant amounts of extra > data copying, also adding significant complexity to the code. > > Instead, the metadata can live on the stack of the formatting > context and the message formatting functions do not need to be > concerned about the metadata changing underneath them. > > Note that the message formatting functions can handle unexpected > text buffer changes. So it is perfectly OK if a shared text buffer > is clobbered by an interrupting context. The atomic console > implementation will recognize the interruption and avoid printing > the (probably garbage) text buffer. Great description! > Signed-off-by: John Ogness Reviewed-by: Petr Mladek Best Regards, Petr