From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 911B7C433E0 for ; Thu, 9 Jul 2020 11:13:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 743752076A for ; Thu, 9 Jul 2020 11:13:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726923AbgGILNX (ORCPT ); Thu, 9 Jul 2020 07:13:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:42888 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbgGILNN (ORCPT ); Thu, 9 Jul 2020 07:13:13 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 28EA8AEFC; Thu, 9 Jul 2020 11:13:11 +0000 (UTC) Date: Thu, 9 Jul 2020 13:13:11 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , kernel test robot , Peter Zijlstra , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , Paul McKenney , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, lkp@lists.01.org Subject: Re: [printk] 18a2dc6982: ltp.kmsg01.fail Message-ID: <20200709111310.GD11164@alley> References: <20200707145932.8752-5-john.ogness@linutronix.de> <20200709071411.GR3874@shao2-debian> <20200709083323.GA572@jagdpanzerIV.localdomain> <874kqhm1v8.fsf@jogness.linutronix.de> <20200709105906.GC11164@alley> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200709105906.GC11164@alley> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2020-07-09 12:59:06, Petr Mladek wrote: > On Thu 2020-07-09 12:20:35, John Ogness wrote: > > On 2020-07-09, Sergey Senozhatsky wrote: > > > On (20/07/09 15:14), kernel test robot wrote: > > > [..] > > > > > > Took me a while to find the FAIL-ed test: > > > > > >> kmsg01.c:393: INFO: TEST: read returns EPIPE when messages get overwritten > > >> kmsg01.c:398: INFO: first seqno: 0 > > >> kmsg01.c:411: INFO: first seqno now: 881 > > >> kmsg01.c:425: FAIL: read returned: 77: SUCCESS (0) > > > > > > So this is seq number related > > > https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/logging/kmsg/kmsg01.c#L383 > > > > Excellent test. > > > > Since the messages are above the expected average size, the dataring is > > wrapping before the descriptor ring. This means that the initial > > descriptors are still there, but their data is gone. Initially I would > > generate an EPIPE for this, but it was changed. Here is the thread [0] > > we had about this. > > I see. IMHO, the following should do the job. The check is done only > when the above prb_read_valid() succeeded. Therefore the printk_record > has to include a valid value. And it must be the first valid record > when some messages were lost. > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index 62fc1abd9c4d..5d4760b5c671 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -775,9 +775,9 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, > logbuf_lock_irq(); > } > > - if (user->seq < prb_first_seq(prb)) { > + if (user->seq < r->info->seq) { > /* our last seen message is gone, return error and reset */ > - user->seq = prb_first_seq(prb); > + user->seq = r->info->seq; > ret = -EPIPE; > logbuf_unlock_irq(); > goto out; I though more about it. IMHO, it will be better to modify prb_first_seq() to do the same cycle as prb_next_seq() and return seq number of the first valid entry. IMHO, basically any caller in printk.c expects this behavior. For example, devkmsg user would expect reading valid entry after doing SEEK_SET. I would also expect to get valid record right after opening devkmsg, etc. The current prb_first_seq() is needed only _prb_read_valid(). For, this I would rename the original function to prb_tail_seq(). Best Regards, Petr From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mx2.suse.de ([195.135.220.15]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtUUK-0006HL-Mj for kexec@lists.infradead.org; Thu, 09 Jul 2020 11:13:13 +0000 Date: Thu, 9 Jul 2020 13:13:11 +0200 From: Petr Mladek Subject: Re: [printk] 18a2dc6982: ltp.kmsg01.fail Message-ID: <20200709111310.GD11164@alley> References: <20200707145932.8752-5-john.ogness@linutronix.de> <20200709071411.GR3874@shao2-debian> <20200709083323.GA572@jagdpanzerIV.localdomain> <874kqhm1v8.fsf@jogness.linutronix.de> <20200709105906.GC11164@alley> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200709105906.GC11164@alley> 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: John Ogness Cc: Andrea Parri , Sergey Senozhatsky , Paul McKenney , kernel test robot , Peter Zijlstra , Greg Kroah-Hartman , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Steven Rostedt , Sergey Senozhatsky , lkp@lists.01.org, Thomas Gleixner , Linus Torvalds On Thu 2020-07-09 12:59:06, Petr Mladek wrote: > On Thu 2020-07-09 12:20:35, John Ogness wrote: > > On 2020-07-09, Sergey Senozhatsky wrote: > > > On (20/07/09 15:14), kernel test robot wrote: > > > [..] > > > > > > Took me a while to find the FAIL-ed test: > > > > > >> kmsg01.c:393: INFO: TEST: read returns EPIPE when messages get overwritten > > >> kmsg01.c:398: INFO: first seqno: 0 > > >> kmsg01.c:411: INFO: first seqno now: 881 > > >> kmsg01.c:425: FAIL: read returned: 77: SUCCESS (0) > > > > > > So this is seq number related > > > https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/logging/kmsg/kmsg01.c#L383 > > > > Excellent test. > > > > Since the messages are above the expected average size, the dataring is > > wrapping before the descriptor ring. This means that the initial > > descriptors are still there, but their data is gone. Initially I would > > generate an EPIPE for this, but it was changed. Here is the thread [0] > > we had about this. > > I see. IMHO, the following should do the job. The check is done only > when the above prb_read_valid() succeeded. Therefore the printk_record > has to include a valid value. And it must be the first valid record > when some messages were lost. > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index 62fc1abd9c4d..5d4760b5c671 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -775,9 +775,9 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, > logbuf_lock_irq(); > } > > - if (user->seq < prb_first_seq(prb)) { > + if (user->seq < r->info->seq) { > /* our last seen message is gone, return error and reset */ > - user->seq = prb_first_seq(prb); > + user->seq = r->info->seq; > ret = -EPIPE; > logbuf_unlock_irq(); > goto out; I though more about it. IMHO, it will be better to modify prb_first_seq() to do the same cycle as prb_next_seq() and return seq number of the first valid entry. IMHO, basically any caller in printk.c expects this behavior. For example, devkmsg user would expect reading valid entry after doing SEEK_SET. I would also expect to get valid record right after opening devkmsg, etc. The current prb_first_seq() is needed only _prb_read_valid(). For, this I would rename the original function to prb_tail_seq(). Best Regards, Petr _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec