Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1123633pxa; Thu, 13 Aug 2020 00:45:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEktto9Q1O0YpagM1C+9EWFUu5QrDweWPfisPAXJVQEVYSa2muJs4LmDxeTXPq36Ubswpv X-Received: by 2002:a17:907:aaa:: with SMTP id bz10mr3554792ejc.304.1597304729057; Thu, 13 Aug 2020 00:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597304729; cv=none; d=google.com; s=arc-20160816; b=BxPSK73DhQGb1saZeqxlzYBivkvFp3S8HCragHTQXfD5qWpjeHoadZ4RvqInzORQJO 1Y1bIC5QKYyxdVB3/09Z2ULTQBa3smtJhJ7mCJfh7ouqUuOzUs+zuNncftYJUlzyeKOr jxS/2KFW7TPtvVu6Cecmi3jGzwkdKigPtTtUqjZklLbH+s9ISvAbpUAm7XxQzP0p24bD gt6+raC/s401OqGEe8cqYLcJjmmWvX0ZovRa+GU3TiHO4HGDPicRnnF/kYOOuqtvc3Lq JN6PuL38dydIgSycLYyPZLLCq4XvZW6Vy/Ax1uL7kOsqSQSRxYSHHpBBQl9hwDemhz4K ZbCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=xwAqU//1A3R+DJkuFK8D981mTCm47eLPJEs5PgpmP9k=; b=ofUW7TvhAJhRPtfWARUQ4F1v/OOGG9wZsRtQRdJxVUBlaCrbpevvqr6ncWvr4vBT5S AhackjdhH1H+x8ZdZlsrNWry4lwVXpZIddbWuF46DY7UZyHHjXUXHysxPVE9KyuLmufV oDoL40QtA+atW2xIoygVYg/Qt9pjtjwvZeHvIkNxVnj/dkxyobf64v7pi/J9pzBXgNbX JvMRGq0mrM1YTpbHy2Xnf5XWZJSk3bhrXMLeRP5E7CEGQWqwaJAlqtpwJaAz7no5MYZI E+QEzc939MPuaGylks8d3sYo5+Emyhf0/D7eKP1a0H3r+oOPl0ddiIomTP+oqmz59Db+ Bedw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JDgXNAvB; dkim=neutral (no key) header.i=@linutronix.de header.b=rWwIStof; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lo6si2797775ejb.584.2020.08.13.00.45.06; Thu, 13 Aug 2020 00:45:29 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JDgXNAvB; dkim=neutral (no key) header.i=@linutronix.de header.b=rWwIStof; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726112AbgHMHo3 (ORCPT + 99 others); Thu, 13 Aug 2020 03:44:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726048AbgHMHo2 (ORCPT ); Thu, 13 Aug 2020 03:44:28 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A021C061757 for ; Thu, 13 Aug 2020 00:44:28 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1597304666; 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=xwAqU//1A3R+DJkuFK8D981mTCm47eLPJEs5PgpmP9k=; b=JDgXNAvBhNk7sR7EzwEc33vq9Lw8Usil2bJSf+xGy78xRTZa1mb7JbaUerHQlJvov8bdiW 7FY0pDMbtSdFEjk3GLTa/ou1+hf29dbq583M+dLloPbI/AihV1u/ft57SFze7ndul95X6R tulbwjxr3i+dl0kpLQe1OMtq0t/Q4gTIb1sZBiG/pLPGlaVTxvLIUlOdYPIefin43DKhsp jTFELLi3TP6UuqLwZ7T7JnWMbYh3bibtSWwgS6+yVxz0imH+XtvLauLgEpQa/mtv6WmEUV xWRJN80hCA9Lu/ZOYfAsfjKHG30ilXoEc2+GfXowupqNIkmFw748kYfx5G/B8w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1597304666; 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=xwAqU//1A3R+DJkuFK8D981mTCm47eLPJEs5PgpmP9k=; b=rWwIStofMz+NLlwO+Tl2ilc3Yyj+GtzqpIP8SXEkLp3BQ0QflC7HoMs0sV6IjEhJcAa0KJ iKD/3V2YvH11FiCg== To: Sergey Senozhatsky Cc: Petr Mladek , Linus Torvalds , Sergey Senozhatsky , 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 In-Reply-To: <20200813051853.GA510@jagdpanzerIV.localdomain> 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> Date: Thu, 13 Aug 2020 09:50:25 +0206 Message-ID: <875z9nvvl2.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. - 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? John Ogness