Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1399500ybl; Tue, 3 Dec 2019 06:37:36 -0800 (PST) X-Google-Smtp-Source: APXvYqxTmrr1T3EhMu1+C5gpfbQmAjkD/XU1s7wSvKaspFu1W2GzosFcfLjyYFSYoJbToDoSyZoa X-Received: by 2002:a05:6830:1248:: with SMTP id s8mr3316912otp.202.1575383856589; Tue, 03 Dec 2019 06:37:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575383856; cv=none; d=google.com; s=arc-20160816; b=rgPG0wM2+dITpaa5BuEtjg7mAnGN4NSeQcEX+reul5nIhRJ6El46fzk2T8506Q57b3 Ut20ZhRJ4vV6pxMp7w//9kolghLdHiMDA/IU9SVMbpNUHVQ/mYqP0K69/csuUYuUrekV XXSZycTRhpmeQMcH/QnIxqQGSyaNg9QASPd8xMRg/RorrVkmh/DebWxiZWIZFaJl1f19 Oq3Sytn8zDYyXg+ZeeUp5VBxMowda9tH8xFN/q/yDk/nr74hysxFHtzvzQ44IwXvzvn0 Ug/W8f6uZMPAxbdOY8WmfCje8KVVgM1b/dFHoxlT4pdIorx4NyF6TjriBfOJk9kp1sFR BNfg== 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=PZ0DIATHBtg1G5jz9+sa5ZTepapTT8w8OcAjZc/YqO4=; b=AE+HEMMrDArnMZXFHRCnS15nWlUzxpO++PHDqiCnjEbKN/FnjgJxW7fY+IpD+lYzEW WJoBCzpR0kbhtVG0Yo6N+Xp7TM3RMb6O5GUJpWMV2aTmmghJD7OZb21dIBNB0jbuWp3H erGQqrBPlg2z1n3/45Y8HyoEoJg0VasjctKCkHbmreVTE2VKvgtuyTHjm35BcYaTJ74B x39PvhWZFmhJFg/XwS4n5Tner5xRhEeDrzBlhQOZtlp9iRVAcqVfii8mtLDaN/Hj8Tm1 90cjCjFH4G8doWy4QI/A3zF3jqoHqAlXseIaKlcKd1CkWLj31zNQSE99YgpnDoydkjs7 hBNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l125si1397660oih.223.2019.12.03.06.37.21; Tue, 03 Dec 2019 06:37:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726598AbfLCOgj (ORCPT + 99 others); Tue, 3 Dec 2019 09:36:39 -0500 Received: from mx2.suse.de ([195.135.220.15]:34784 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725957AbfLCOgi (ORCPT ); Tue, 3 Dec 2019 09:36:38 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C21A3B365; Tue, 3 Dec 2019 14:36:36 +0000 (UTC) Date: Tue, 3 Dec 2019 15:36:35 +0100 From: Petr Mladek To: John Ogness Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , Sergey Senozhatsky , Brendan Higgins , kexec@lists.infradead.org Subject: Re: [RFC PATCH v5 1/3] printk-rb: new printk ringbuffer implementation (writer) Message-ID: <20191203143635.cc6hh6bscr6kw4zw@pathway.suse.cz> References: <20191128015235.12940-1-john.ogness@linutronix.de> <20191128015235.12940-2-john.ogness@linutronix.de> <20191202154841.qikvuvqt4btudxzg@pathway.suse.cz> <87fti1bipb.fsf@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87fti1bipb.fsf@linutronix.de> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2019-12-03 15:13:36, John Ogness wrote: > On 2019-12-02, Petr Mladek wrote: > >> +/* > >> + * Sanity checker for reserve size. The ringbuffer code assumes that a data > >> + * block does not exceed the maximum possible size that could fit within the > >> + * ringbuffer. This function provides that basic size check so that the > >> + * assumption is safe. > >> + */ > >> +static bool data_check_size(struct prb_data_ring *data_ring, unsigned int size) > >> +{ > >> + struct prb_data_block *db = NULL; > >> + > >> + /* Writers are not allowed to write data-less records. */ > >> + if (size == 0) > >> + return false; > > > > I would personally let this decision to the API caller. > > > > The code actually have to support data-less records. They are used > > when the descriptor is reserved but the data block can't get reserved. > > Exactly. Data-less records are how the ringbuffer identifies that data > has been lost. If users were allowed to store data-less records, that > destinction is no longer possible (unless I created some extra field in > the descriptor). Does it even make sense for printk to store data-less > records explicitly? From my POV, it does not make much sense. > The current printk implementation silently ignores empty messages. I am not able to find it. I only see that empty continuous framgments are ignored in log_output(). Normal empty lines seems to be strored. Well, I can't see any usecase for this. I think that we could ignore all empty strings. > > The above statement might create false feeling that it could not > > happen later in the code. It might lead to bugs in writer code. > > Then let me change the statement to describe that data-less records are > used internally by the ringbuffer and cannot be explicitly created by > writers. Sounds godo to me. > > Also reader API users might not expect to get a "valid" data-less > > record. > > Readers will never see them. The reader API implementation skips over > data-less records. Yeah. They will see bump in the seq number. We would need to distinguish empty records and lost records as you wrote above. It looks better to ignore empty records already during write. Best Regards, Petr