Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1777443ybn; Thu, 26 Sep 2019 02:00:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9C1xkfCvIUce/Bn90CSa1rEfKtPLykrtYbpvwu6XlPZuV3xyNSrcLfp1vIddYRbnZ/baG X-Received: by 2002:a05:6402:2022:: with SMTP id ay2mr2324082edb.109.1569488433634; Thu, 26 Sep 2019 02:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569488433; cv=none; d=google.com; s=arc-20160816; b=zj+GqalRllBmVuVCHivVz5+sOEjczUyBchp8BFD7OWcb/MD3qJ9dBa7Ubbmy0QcAQk Xg86tXUMeG2t/5RDjSmA/p48pykEumwK4Vwq3y1N/fp3s9S8A0TS4IN71e9VV00KeM+a 0eXvF3Tic1evX3MK6HySVljwQ8AdzW4u0mLmUpFSDwznLPGy1K55Sk8StmTNW8Vh0j08 GvkKgUGoYsdfLyX/kKmXdXBJG4SZU8VaYyxYNrzQSdjQK64kXwq56u0VrrX/vvA7L4AQ L6AEgBOQTJyfeyG4pTU4EychWvdcYWXqN5PP8ZD/2gHvxaAQiYmBfSdTXTAvVxDmycvi cVTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=xQkfsqs49z6yXsP63iLL6ATz+M0+iN+CBK7ywrZ4tfM=; b=lj68m7lF1OXiT1MSB29l1AfaTxev7x3WxRcLy7Ossa2iZ39Gjlj1phKDJS+3n7cPua sSGwO2gAcFiaE7q+gf5TIhfmJ1osCgUqxFRlZbZwdmO1l7N5UwnyXwAABn2B3FlalVHR 3lMlDUX/UQN8V7ouRajjFIpw9pK3bT2ZNZpUA8JLX5EybS7+odICXzWf0rmO5OY3fd4a ibHH/ugN37o+b9xcqjDYNeLcudRDS3yhb1AooVuZk86AW8SXdaP6QVicDrxR4FJnoMbl gWtN2Gj3gh/oQ5+qR7Rrf4GlTfSxj5XUbAQimjg6AN6mOftLHyMFioB+VeR9u4bSD1r+ IDJA== 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 b3si600092eju.357.2019.09.26.02.00.09; Thu, 26 Sep 2019 02:00:33 -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 S2442110AbfIXXtN (ORCPT + 99 others); Tue, 24 Sep 2019 19:49:13 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:35652 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388576AbfIXXtN (ORCPT ); Tue, 24 Sep 2019 19:49:13 -0400 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1iCuYQ-00018W-9p; Wed, 25 Sep 2019 01:49:10 +0200 From: John Ogness To: Cc: , Subject: Re: [PATCH RT] printk: devkmsg: read: Return EPIPE when the first message user-space wants has gone References: <20190924072639.25986-1-zhe.he@windriver.com> Date: Wed, 25 Sep 2019 01:49:08 +0200 In-Reply-To: <20190924072639.25986-1-zhe.he@windriver.com> (zhe he's message of "Tue, 24 Sep 2019 15:26:39 +0800") Message-ID: <8736gls1aj.fsf@linutronix.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-09-24, wrote: > From: He Zhe > > When user-space wants to read the first message, that is when user->seq > is 0, and that message has gone, it currently automatically resets > user->seq to current first seq. This mis-aligns with mainline kernel. > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/testing/dev-kmsg#n39 > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/printk/printk.c#n899 > > We should inform user-space that what it wants has gone by returning EPIPE > in such scenario. > > Signed-off-by: He Zhe Signed-off-by: John Ogness > --- > kernel/printk/printk.c | 12 ++++-------- > 1 file changed, 4 insertions(+), 8 deletions(-) > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index e3fa33f2e23c..58c545a528b3 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -703,14 +703,10 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, > goto out; > } > > - if (user->seq == 0) { > - user->seq = seq; > - } else { > - user->seq++; > - if (user->seq < seq) { > - ret = -EPIPE; > - goto restore_out; > - } > + user->seq++; > + if (user->seq < seq) { > + ret = -EPIPE; > + goto restore_out; > } > > msg = (struct printk_log *)&user->msgbuf[0];