From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ic8vt-00034C-EB for kexec@lists.infradead.org; Tue, 03 Dec 2019 14:13:42 +0000 From: John Ogness Subject: Re: [RFC PATCH v5 1/3] printk-rb: new printk ringbuffer implementation (writer) References: <20191128015235.12940-1-john.ogness@linutronix.de> <20191128015235.12940-2-john.ogness@linutronix.de> <20191202154841.qikvuvqt4btudxzg@pathway.suse.cz> Date: Tue, 03 Dec 2019 15:13:36 +0100 In-Reply-To: <20191202154841.qikvuvqt4btudxzg@pathway.suse.cz> (Petr Mladek's message of "Mon, 2 Dec 2019 16:48:41 +0100") Message-ID: <87fti1bipb.fsf@linutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Petr Mladek Cc: Andrea Parri , Sergey Senozhatsky , Peter Zijlstra , Greg Kroah-Hartman , Brendan Higgins , linux-kernel@vger.kernel.org, Steven Rostedt , Sergey Senozhatsky , Thomas Gleixner , Linus Torvalds , kexec@lists.infradead.org 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? The current printk implementation silently ignores empty messages. > 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. > 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. John Ogness _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec