Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp925111pxa; Wed, 12 Aug 2020 17:25:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa+iiCpNkpkwqHrPNSYYeXHZf6kKx+DwfegfzpIwK4HZ/TutZy5buRVTU+45tCQhyoqSXO X-Received: by 2002:a50:e809:: with SMTP id e9mr2409754edn.133.1597278314315; Wed, 12 Aug 2020 17:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597278314; cv=none; d=google.com; s=arc-20160816; b=mhOO3rrZaxvnn3JMK82HwUZWPxIwIfR+8U6wRyXhN4i6mv2s32C3oXokzP4N4yKCJh WU/gmfk+Tsoc4rZFF6lRWTVz7V5+PfG+UYoYTWDcO7gsHMosR4lRvJIkR5nj5DLIPt8E aL+8VUkcvd3bzcnbY/U5ovwUhPdpiVOM1jAtA/esa4E1z39aROpai7T2sOq0fkjCLGw4 X/LPohg1jW6aGYC3taYcdQr2VPXGs/5IWv/6Xm9LL+FAybJnKfDT2bj0BkI7ixNDnjF/ x8DRfj5iVT/i/dUpdmaXnACNhH8tNosPdlGOdb+ZMeAl/3MystXfhMO112LOe16DjpxT DERg== 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=T6cBMmvGDUSJmOhpFTOJY1Nvmk9svDWb0crnONfsRcg=; b=YERgTv2ffqxsemEgCupb3Hr8m684dRBDpvwFHEj0prvLFIlX/+RCbtfJ7nK8xOe5la vzG8DndEPxW9hwJFCx0xrGsdpdgWg1eLwwPEMvFlimRPa7R6S6MRQh8SbF5SpJgdZ9Pb 2AFTBaRHoajC69KSNYDp88oqITi7f7rLGSSAXJETFr8CbWurwBvq18zQ6ddCcybI1aG9 heQG4imYlB9F0XZa7lYG6w8RnuXHAmo5NJMh0/yeItlKPBYxUlBq5QWZJj/oUZaK8H4t AMH0Xql6CNtGR0vuSgIIIWIIjqUrC/b0fxpj+ML7dNEbZyOYAxRW3/aK8kmgawddHLNP v9+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="tPvWf1/u"; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e header.b="F7M/8Cb9"; 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 24si2877446edv.581.2020.08.12.17.24.49; Wed, 12 Aug 2020 17:25:14 -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="tPvWf1/u"; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e header.b="F7M/8Cb9"; 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 S1726567AbgHMAYH (ORCPT + 99 others); Wed, 12 Aug 2020 20:24:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbgHMAYH (ORCPT ); Wed, 12 Aug 2020 20:24:07 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AEA2C061383 for ; Wed, 12 Aug 2020 17:24:07 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1597278242; 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=T6cBMmvGDUSJmOhpFTOJY1Nvmk9svDWb0crnONfsRcg=; b=tPvWf1/uSjOuVeRO3Z9Yaulwt779rs1oJYXB5HPTf+btDUoofO5xwuNZZgX5MwyoT+B5RP WCDF3BmNAkt1V5LjpJmuhstr995Ij3FlvqaL+xHs956BVev5DZvBuFLVra0Myf37dxNsSH i5rwrR60hbCwgHceGDRzFOICFld/Hp9mCkc0r+XQ1HtnkSlvLtR7Oxja5biMnHHSf84AnU vYC5aTCuH0PYgXjjSIz8rfL/GGMGkAjRs42iOUZLAPp3o3X4YQTeLLvyUzHJ5/CTEtzGXE tZiPuFq1OegoBLpU08RgS38pvRFq0M7tJpqgQRrfhfPh1MUwxthR2LFP/IMejg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1597278242; 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=T6cBMmvGDUSJmOhpFTOJY1Nvmk9svDWb0crnONfsRcg=; b=F7M/8Cb9meZTlnO2bFm10TBxaHceqURrhXtctSbptC0KFrURa6iXEw+tMfct0mD2v+1Lq4 Izbtejnq/0Sa/SDw== To: Petr Mladek Cc: 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: <20200812163908.GH12903@alley> References: <20200717234818.8622-1-john.ogness@linutronix.de> <87blkcanps.fsf@jogness.linutronix.de> <20200811160551.GC12903@alley> <20200812163908.GH12903@alley> Date: Thu, 13 Aug 2020 02:30:02 +0206 Message-ID: <87v9hn2y1p.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-12, Petr Mladek wrote: > So, I have one crazy idea to add one more state bit so that we > could have: > > + committed: set when the data are written into the data ring. > + final: set when the data block could not longer get reopened > + reuse: set when the desctiptor/data block could get reused > > "final" bit will define when the descriptor could not longer > get reopened (cleared committed bit) and the data block could > not get extended. I had not thought of extending data blocks. That is clever! I implemented this solution for myself and am currently running more tests. Some things that I changed from your suggestion: 1. I created a separate prb_reserve_cont() function. The reason for this is because the caller needs to understand what is happening. The caller is getting an existing record with existing data and must append new data. The @text_len field of the info reports how long the existing data is. So the LOG_CONT handling code in printk.c looks something like this: if (lflags & LOG_CONT) { struct prb_reserved_entry e; struct printk_record r; prb_rec_init_wr(&r, text_len, 0); if (prb_reserve_cont(&e, prb, &r, caller_id)) { memcpy(&r.text_buf[r.info->text_len], text, text_len); r.info->text_len += text_len; if (lflags & LOG_NEWLINE) r.info->flags |= LOG_NEWLINE; if (r.info->flags & LOG_NEWLINE) prb_commit_finalize(&e); else prb_commit(&e); return text_len; } } This seemed simpler than trying to extend prb_reserve() to secretly support LOG_CONT records. 2. I haven't yet figured out how to preserve calling context when a newline appears. For example: pr_info("text"); pr_cont(" 1"); pr_cont(" 2\n"); pr_cont("3"); pr_cont(" 4\n"); For "3" the calling context (info, timestamp) is lost because with "2" the record is finalized. Perhaps the above is invalid usage of LOG_CONT? 3. There are some memory barriers introduced, but it looks like it shouldn't add too much complexity. I will continue to refine my working version and post a patch so that we have something to work with. This looks to be the most promising way forward. Thanks. John Ogness