Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1151168pxa; Thu, 13 Aug 2020 01:42:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSiysOgXb1BFyWd10e5nRNvOu1Nlz/4P3wtROrpfkcpWt+cWcFET/t0lCcCtIxIklzNJFx X-Received: by 2002:a17:906:da19:: with SMTP id fi25mr3599679ejb.405.1597308156012; Thu, 13 Aug 2020 01:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597308156; cv=none; d=google.com; s=arc-20160816; b=T7zRsI/KRTreYlxpk0hTrEegfxeIUmxoVVpyMKVHPZq3Jl+4O9ZRrlXGZQ+Has3Iwf YZhvDdDdXmHjHFn9H/y/KW78kRsn2FhwTwpY/Weu+7YHSBz+sIYoynKDReUTRigZkHkj ruOKew0asPX4JArR2M/WWI2qh9crpqgnR5UI0T66fLUHork2Z5z1+E7z+Crnh6i/RTaA +XbKq5GWE0oSdybB5l9vjJuUx/Y3r1qjlxNinV8Ag6CU0DMKKSpo/klym0qEbf7menvd 8R0CWeC9KOjCff5vGfkI7EqXRtQo9AHnqTDpeb0xi1rIzHioYoGr2e7KkoLe47wgl+NJ wqaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Y09AHCGY5bHbHvFSxgTTFuI7Q2P8tQpi9yd6CY8Yf3U=; b=qlfxsd2z8anrsb6hmvkKLkSGm/bbNG8yOwzSHCMjJZlb3s3eunILA5EgwVYYA+58TV YNHJmdFDgaIvw9+CSGfnkvP1B9VRuV8b2qehqoqoUh+tnIV0B+T6K6ws+Kol0mBA0/LU UNS4nJ89MV3QBm4KgescVLYldOIQl3c9ByZ799TV57lY1FFoN3Z8rg7GBLKc6xR2ZLKD LESyYJG7hlPBUAtbCP+mXIsC8hUWxS4DfVdQTSptZHfOaEV92iyyFJ13NjZsf0PXfH+D ksWjgTm3YrnqEl43C/sLmRpm6tG+z3gt3Mm/5LYDUPRvvxKgtdcMMpc+WGOBRnNYE7+I jQjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si2746814ejd.62.2020.08.13.01.42.12; Thu, 13 Aug 2020 01:42:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726144AbgHMIlk (ORCPT + 99 others); Thu, 13 Aug 2020 04:41:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:36216 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbgHMIlj (ORCPT ); Thu, 13 Aug 2020 04:41:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 94B7CB5DA; Thu, 13 Aug 2020 08:41:59 +0000 (UTC) Date: Thu, 13 Aug 2020 10:41:36 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Linus Torvalds , Sergey Senozhatsky , Steven Rostedt , Greg Kroah-Hartman , Peter Zijlstra , Thomas Gleixner , kexec@lists.infradead.org, Linux Kernel Mailing List Subject: Re: POC: Alternative solution: Re: [PATCH 0/4] printk: reimplement LOG_CONT handling Message-ID: <20200813084136.GK12903@alley> References: <20200717234818.8622-1-john.ogness@linutronix.de> <87blkcanps.fsf@jogness.linutronix.de> <20200811160551.GC12903@alley> <20200812163908.GH12903@alley> <87v9hn2y1p.fsf@jogness.linutronix.de> <20200813051853.GA510@jagdpanzerIV.localdomain> <875z9nvvl2.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <875z9nvvl2.fsf@jogness.linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2020-08-13 09:50:25, John Ogness wrote: > On 2020-08-13, Sergey Senozhatsky wrote: > > This is not an unseen pattern, I'm afraid. And the problem here can > > be more general: > > > > pr_info("text"); > > pr_cont("1"); > > exception/IRQ/NMI > > pr_alert("text\n"); > > pr_cont("2"); > > pr_cont("\n"); > > > > I guess the solution would be to store "last log_level" in task_struct > > and get current (new) timestamp for broken cont line? > > (Warning: new ideas ahead) > > The fundamental problem is that there is no real association between > the cont parts. So any interruption results in a broken record. If we > really want to do this correctly, we need real association. > > With the new finalize flag for records, I thought about perhaps adding > support for chaining data blocks. > > A data block currently stores an unsigned long for the ID of the > associated descriptor. But it could optionally include a second unsigned > long, which is the lpos of the next text part. All the data blocks of a > chain would point back to the same descriptor. The descriptor would only > point to the first data block of the chain and include a flag that it is > using chained data blocks. > > Then we would only need to track the sequence number of the open record > and new data blocks could be added to the data block chain of the > correct record. Readers cannot see the record until it is finalized. Note that we still must try to append the continuous piece into the same data block. We could not concatenate them in the reader API because it would create the problem with unused/skipped sequence numbers. Also it would complicate the reader code. It would need to know whether a record has already been printed together with a previous one. > Also, since only finalized records can be invalidated, there are no > races of chains becoming invalidated while being appended. > > My concerns about this idea: > > - What if the printk user does not correctly terminate the cont message? > There is no mechanism to allow that open record to be force-finalized > so that readers can read newer records. This is a real problem. And it is the reason why the cont buffer is currently flushed (finalized) by the next message from another context. > - For tasks, the sequence number of the open record could be stored on > the task_struct. For non-tasks, we could use a global per-cpu variable > where each CPU stores 2 sequence numbers: the sequence number of the > open record for the non-task and the sequence number of the open > record for an interrupting NMI. Is that sufficient? Yeah, it would be possible. Anyway, this would fix an already existing problem. It might get complicated and tricky. I am afraid that it comes from the "perfection is the enemy of good" department. A good compromise might be to just store "loglevel" from the previous message in the given context. It could then be used for pr_cont() messages in the same context. Anyway, I would solve this later because it is already existing problem. Best Regards, Petr