Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4834411ybv; Mon, 17 Feb 2020 06:51:27 -0800 (PST) X-Google-Smtp-Source: APXvYqx7JADqtYKS25VtLEn1KPXTkFzlI0X1GiPWxO7nVxnnYKOGRHmomWvIuuh8RXSo1MIgFDaV X-Received: by 2002:aca:5083:: with SMTP id e125mr10316804oib.96.1581951087225; Mon, 17 Feb 2020 06:51:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581951087; cv=none; d=google.com; s=arc-20160816; b=CJqmqwGiFWIZjkFhrzrLBaxSZ4jgATDd0hMi+Tmqq+h2L5B8GaJ3F2qnttnYbKpQgl NgxD2uVU7WQsOEnZOtucbIUYumESS8QGl04rG4aO0hia9X7/7T9R0pzDJ8hYczxNUMXO B0BH84Bmz6USLViC4BlPngVm5fDNIJr6prXtETDkRLd9NPQlvIigISlJlZbXpegoOsfS usJYScQqA/+GipWB/bVI4/kRcUJx2Jpz6VlnDjlwKMVI2LfvWgBzP+JJzZJV0bxJ72mu 9XYHRCjlsHTPoc1d189z4T06r8SvvjpRysrpkJR4lwNilyLZ3cEcrSOmMkL7os2lK8iN 34DQ== 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=VAOLeWYyt/JCXhurg3Dih2JC4q3bnsX0rb1+VbjWH1I=; b=ulf82jPSCVwMoKHjkAZWoW/3si4bIVd09/mjKsP3wLLds6qkJ3t/Bva38JqMYgj6VP QZWIStIUpTk3jy/M/oO7fKHHN+63pUp4tY9nkeF7AfHrpuXuFvW8of9jol8aBi0m3iU4 UFE24QRvEkX4haifJAbkpWUC160pi7t8rf1k3a9e/KJbL+pbkgiZtbTVrZs8tr5o4D+d 4acjglYA5JnpiHmzGVojz/8Ll0mKWf1bdS5lZi9RRJB+hdSQL4AWQnQ1YzA0rU6ejMgy fevmzXX3hPrVpVznsc2AoV54TXbMQmmMiRgcXomFs7NRWUZN96PoLVZ7OdzZYsnkeqUQ 6z5w== 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 e20si6711890oig.199.2020.02.17.06.51.14; Mon, 17 Feb 2020 06:51:27 -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 S1729154AbgBQOuT (ORCPT + 99 others); Mon, 17 Feb 2020 09:50:19 -0500 Received: from mx2.suse.de ([195.135.220.15]:37566 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728375AbgBQOuT (ORCPT ); Mon, 17 Feb 2020 09:50:19 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 23A52B47D; Mon, 17 Feb 2020 14:50:17 +0000 (UTC) Date: Mon, 17 Feb 2020 15:50:16 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Sergey Senozhatsky , lijiang , Peter Zijlstra , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , kexec@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/2] printk: replace ringbuffer Message-ID: <20200217145016.7r6b7i5o6tqkaa2x@pathway.suse.cz> References: <20200205044848.GH41358@google.com> <20200205050204.GI41358@google.com> <88827ae2-7af5-347b-29fb-cffb94350f8f@redhat.com> <20200205063640.GJ41358@google.com> <877e11h0ir.fsf@linutronix.de> <20200205110522.GA456@jagdpanzerIV.localdomain> <87wo919grz.fsf@linutronix.de> <20200214155639.m5yp3rd2t3vdzfj7@pathway.suse.cz> <87blpxbh62.fsf@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87blpxbh62.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 Mon 2020-02-17 12:13:25, John Ogness wrote: > On 2020-02-14, Petr Mladek wrote: > >> I oversaw that devkmsg_open() setup a printk_record and so I did not > >> see to add the extra NULL initialization of text_line_count. There > >> should be be an initializer function/macro to avoid this danger. > >> > >> John Ogness > >> > >> The quick fixup: > >> > >> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > >> index d0d24ee1d1f4..5ad67ff60cd9 100644 > >> --- a/kernel/printk/printk.c > >> +++ b/kernel/printk/printk.c > >> @@ -883,6 +883,7 @@ static int devkmsg_open(struct inode *inode, struct file *file) > >> user->record.text_buf_size = sizeof(user->text_buf); > >> user->record.dict_buf = &user->dict_buf[0]; > >> user->record.dict_buf_size = sizeof(user->dict_buf); > >> + user->record.text_line_count = NULL; > > > > The NULL pointer hidden in the structure also complicates the code > > reading. It is less obvious when the same function is called > > only to get the size/count and when real data. > > OK. > > > I played with it and created extra function to get this information. > > > > In addition, I had problems to follow the code in > > record_print_text_inline(). So I tried to reuse the new function > > and the existing record_printk_text() there. > > > > Please, find below a patch that I ended with. I booted a system > > with this patch. But I guess that I actually did not use the > > record_print_text_inline(). So, it might be buggy. > > Yes, there are several bugs. But I see where you want to go with this: > > - introduce prb_count_lines() to handle line counting > > - introduce prb_read_valid_info() for only reading meta-data and getting > the line count > > - also use prb_count_lines() internally In addition, I would like share the code between record_print_text_inline() and record_print_text(). They both do very similar thing and the logic in far from trivial. Alternative solution would be to get rid of record_print_text() and use record_print_text_inline() everywhere. It will have some advantages: + _inline() variant will get real testing + no code duplication + saving the extra buffer also in console, sysfs, and devkmsg interface. > I will include these changes in v2. I will still introduce the static > inlines to initialize records because readers and writers do it > differently. Sounds good. Best Regards, Petr