Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp617886ybn; Wed, 25 Sep 2019 05:16:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1zKn8jpeIu+4fYnLrrGdAKk943gtmue+Ss89xeuN0EBrFmrXcXx788VUxhIWfkCkcFVD0 X-Received: by 2002:a05:6000:105:: with SMTP id o5mr3368640wrx.51.1569413761292; Wed, 25 Sep 2019 05:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569413761; cv=none; d=google.com; s=arc-20160816; b=S8mV/hTb2oxyg2rvxG4aQX+s0K3/K7jSYsj1T6DIks560cuoNUEY1hpLqmQ1yZK8fZ apYJymCFiXpkKaAJPNJd21ufVnCUXseIWcYC1dc7aHQXrhrp1/eRGJq6Vqj1daGI7GIg Ls7eLXzymTGS+kzbu26vZjBTAvPeBESWSBl6zmeu2caq6Pxp3Pg4Pt+s6ebF8t4UZ/WW Rov5mi1+tRCLPBVbugcYKEvAkuh3n8iMKN50CwSOz6jnKPy7SuUXZHC17xKZZIOh3RvH 4cTP++wbIVvrSSHFCMpDMbdnr+QI0keltOuEMW/uGjyk0+tc71qliE/qJqODQZBaqTld 8ubA== 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=vfBoF7uB4S8/24J3B8Ahk2wR4U3AynjCtjF6tbFH6Ak=; b=NU+aZ6zuGAPJ4fJE0ldmWnumxDPvpjUwXGka7QgTWeX0d7nS6ldAYJ3l5EAIS7A2t1 Vs0bxkQS65jfBfj8fU0GIVU5O+BZlv4PXj+t/1LMvmxZcQrbvCFceBOcw9JdonWS9Kfa Gt1+8TiwVOjwoTdcvoBmb32zG03ijEJ5W3HDGMdbFcFNt7Ej4tOyCCi2oqG6fnqg58mI 3K95FRpqfWwU9CNqqVpxIk3SehUl5iX4kA3Gco+VDiuhsxBJ3qMZ9Sm132/kUusxt89R DeOnTGLviwYzG2ClTtWasF6PI7xD/zUZzYM3AATBRrhI7VNBTCjyY/B0Af7LHelT1CtO gxXQ== 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 r24si3006585edy.417.2019.09.25.05.15.37; Wed, 25 Sep 2019 05:16:01 -0700 (PDT) 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 S1732193AbfIWLjk (ORCPT + 99 others); Mon, 23 Sep 2019 07:39:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:49518 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726146AbfIWLjk (ORCPT ); Mon, 23 Sep 2019 07:39:40 -0400 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 18329AAB0; Mon, 23 Sep 2019 11:39:38 +0000 (UTC) Date: Mon, 23 Sep 2019 13:39:36 +0200 From: Petr Mladek To: He Zhe Cc: Sergey Senozhatsky , sergey.senozhatsky@gmail.com, rostedt@goodmis.org, linux-kernel@vger.kernel.org, John Ogness Subject: Re: [PATCH] printk: Fix unnecessary returning broken pipe error from devkmsg_read Message-ID: <20190923113936.73lhmpxurynem62e@pathway.suse.cz> References: <1568813503-420025-1-git-send-email-zhe.he@windriver.com> <20190923100513.GA51932@jagdpanzerIV> <027b2f0d-b7dc-4e76-22a7-ce80c9a0aade@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <027b2f0d-b7dc-4e76-22a7-ce80c9a0aade@windriver.com> 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 2019-09-23 18:45:18, He Zhe wrote: > > > On 9/23/19 6:05 PM, Sergey Senozhatsky wrote: > > On (09/18/19 21:31), zhe.he@windriver.com wrote: > >> When users read the buffer from start, there is no need to return -EPIPE > >> since the possible overflows will not affect the output. > >> > > [..] > >> - if (user->seq < log_first_seq) { > >> + if (user->seq == 0) { > >> + user->seq = log_first_seq; > >> + } else if (user->seq < log_first_seq) { > >> /* our last seen message is gone, return error and reset */ > >> user->idx = log_first_idx; > >> user->seq = log_first_seq; > > A tough call. > > > > User-space wants to read messages which are gone: log_first_seq > user->seq. > > > > I think returning EPIPE is sort of appropriate; user-space, possibly, > > can printf(stderr, "Some /dev/kmsg messages are gone\n"); or something > > like that. > > Yes, a tough call. I was looking at the similar part of RT kernel and thought > that handling was better. > https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git/tree/kernel/printk/printk.c?h=linux-5.2.y-rt#n706 Adding John into CC. He takes care of printk() in RT kernel. > IMHO, the EPIPE is used to inform user-space when the buffer has overflown and > there is a inconsistency/break between what has been read and what has not. What is the motivation for the change, please? Have you just noticed the inconsistency between normal and RT kernel? Or was there any bug report? We need to be careful to do not break user space. And this patch modifies the existing behavior. > When user-space just wants to read the buffer from sequence 0, there would not > be the inconsistency. > > I think it is NOT necessary to inform user-space, when it just wants to read > from the beginning of the buffer, that the buffer has changed since the time > point when it issues the action of reading. Who would set sequence 0, please? IMHO, the patch is wrong. devkmsg_open() initializes user->seq to a valid sequence number. We should return -EPIPE when user->seq == 0 during devkmsg_open() and the first messages got lost before the first read. > But if that IS what we want, the RT > kernel needs to be changed so that mainline and RT kernel act in the same way. I agree. Best Regards, Petr