[v3,1/3] tracing/user_events: Fix incorrect return value for writing operation when events are disable
Message ID | 20230621060827.151564-2-sunliming@kylinos.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4157064vqr; Tue, 20 Jun 2023 23:27:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5j6oH0KzoqzZX3NMWD0vpYBnizcJsgxfRMXDcRJndJ+MKpGZpLS6/NKow4LchL0QTibkkU X-Received: by 2002:a17:903:41c3:b0:1b1:ac87:b47a with SMTP id u3-20020a17090341c300b001b1ac87b47amr18609060ple.65.1687328879157; Tue, 20 Jun 2023 23:27:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687328879; cv=none; d=google.com; s=arc-20160816; b=Y4c1WL01Wmsi6rUoHJAS78JfFcQcoswPM1csTtfmMGE9d5ESJ4cVzmetDNdP3cz517 FyyF/PeIS3Fdks8ARgeJjdcYtz+IZ8wTjF1ZOzfiPVHKKppDll9crJ3cS3z7OcFJt8Mg bzNS7UvTTQk1/YtYZapI8A3ueV4VSrlCkPJ3DXzPE911T6XN6yWQiPtZiJsitdpdTHED gevjp+Oahcx4PL6jMWZ+uIgkNNqdl33NLrhZ3BaFmGuzBdvizS+v8+dOUNllPSo9kgJ7 1/O6NTLsE66apzujw1wsyP18JgMX6jePEED3SQc6lcCb6FUaIZUrf9z9F3yb1IxDE33O oZpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=n5/ibBv767hMPWz9rN9brRTXkDseA5y39L5B6lIVEsY=; b=y84jWNtphJ2JSeRMUpc0SpR8OhUecixpg5VkTGInnbnf2NgPoMVXzUThxSRplBlRdb bjYmRoJvCKhxLCQCDy9N7Wb1WuRJUQY4NrKu9C0r2rMyBOv1DRMcLxzkE+nXx72Iizho 9ChGQr/1rrHGmSvYJB5QB6s7nSQWA0AKWWO6PqRS/wt2u6djDI0pI5d7onvhl79v/khx xaHkaZN9KfF2gP8vNdTvTiJKs+R7XacPUCjm3OOJ4+viwV3G2UQfzpwCOUzjWn2JXG2j BfchqsnBhj6XDe5+qNxg9TZsU8+BuXsAK5jGu6eDqX4LxkJytO1H7yo4V0RuWGbSN8lH 6awQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a170902eec600b001b3d2717f7bsi3417032plb.61.2023.06.20.23.27.45; Tue, 20 Jun 2023 23:27:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230151AbjFUGIp (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Wed, 21 Jun 2023 02:08:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbjFUGIj (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 21 Jun 2023 02:08:39 -0400 Received: from mail-oi1-f196.google.com (mail-oi1-f196.google.com [209.85.167.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BE30172C; Tue, 20 Jun 2023 23:08:39 -0700 (PDT) Received: by mail-oi1-f196.google.com with SMTP id 5614622812f47-3a03ff70c1aso836538b6e.1; Tue, 20 Jun 2023 23:08:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687327718; x=1689919718; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n5/ibBv767hMPWz9rN9brRTXkDseA5y39L5B6lIVEsY=; b=VZSPm7x4p9SqeUbWPbzoYr3PEsy0B6fXgeEqrT4qw96zCt4RQlEaiwDGQijlrB9SxA gxwexRxJnP0+VP2YrHQScojJFmaZ8q6+ROc61buctbnzxeA1FRK6WuZ2BKX6/eSDn/55 N+axYlh37HUqDOEzMf3WzZ/rCzRJ6cjfAO/nysHQeBmHMAEIsiMHDgUdT4g2Y9ZLxUBS XUQqtqjh+4w2Pru+yvT4CKkIPtHdIw0y9hJEH009SyGPTGADEMeLLGcuHl7ZXCRCnatI zH4Hlb1YojHjnP9l7+iNllOTUFwJ0EfF2Kqe1VuSpPa/NRQKFltYL2O3Q5edba1YNPBe dRgw== X-Gm-Message-State: AC+VfDxleMMxJmY0cbmVQv5JYsT2mGAl1GjPjacn/nthHnIJqiwnF9Fm jI5XA33X/l9M5xU0NxSqpg== X-Received: by 2002:a05:6808:f88:b0:39e:1d17:d689 with SMTP id o8-20020a0568080f8800b0039e1d17d689mr14321758oiw.56.1687327718239; Tue, 20 Jun 2023 23:08:38 -0700 (PDT) Received: from localhost.localdomain ([116.128.244.169]) by smtp.gmail.com with ESMTPSA id d28-20020a630e1c000000b00528da88275bsm2323621pgl.47.2023.06.20.23.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 23:08:37 -0700 (PDT) From: sunliming <sunliming@kylinos.cn> To: rostedt@goodmis.org, mhiramat@kernel.org, beaub@linux.microsoft.com Cc: kelulanainsley@gmail.com, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, sunliming <sunliming@kylinos.cn> Subject: [PATCH v3 1/3] tracing/user_events: Fix incorrect return value for writing operation when events are disable Date: Wed, 21 Jun 2023 14:08:24 +0800 Message-Id: <20230621060827.151564-2-sunliming@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230621060827.151564-1-sunliming@kylinos.cn> References: <20230621060827.151564-1-sunliming@kylinos.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769292567106180162?= X-GMAIL-MSGID: =?utf-8?q?1769292567106180162?= |
Series |
tracing/user_events: Fix incorrect return value for
|
|
Commit Message
sunliming
June 21, 2023, 6:08 a.m. UTC
The writing operation return the count of writes regardless of whether events
are enabled or disabled. Switch it to return 0 to indicates that the event
is disabled.
Signed-off-by: sunliming <sunliming@kylinos.cn>
---
kernel/trace/trace_events_user.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Wed, Jun 21, 2023 at 02:08:24PM +0800, sunliming wrote: > The writing operation return the count of writes regardless of whether events > are enabled or disabled. Switch it to return 0 to indicates that the event > is disabled. > > Signed-off-by: sunliming <sunliming@kylinos.cn> This looks good to me. Acked-by: Beau Belgrave <beaub@linux.microsoft.com> Thanks! > --- > kernel/trace/trace_events_user.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c > index 1ac5ba5685ed..c085ff829a58 100644 > --- a/kernel/trace/trace_events_user.c > +++ b/kernel/trace/trace_events_user.c > @@ -1957,7 +1957,8 @@ static ssize_t user_events_write_core(struct file *file, struct iov_iter *i) > > if (unlikely(faulted)) > return -EFAULT; > - } > + } else > + return 0; > > return ret; > } > -- > 2.25.1
On Wed, 21 Jun 2023 14:08:24 +0800 sunliming <sunliming@kylinos.cn> wrote: > The writing operation return the count of writes regardless of whether events > are enabled or disabled. Switch it to return 0 to indicates that the event > is disabled. > > Signed-off-by: sunliming <sunliming@kylinos.cn> > --- > kernel/trace/trace_events_user.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c > index 1ac5ba5685ed..c085ff829a58 100644 > --- a/kernel/trace/trace_events_user.c > +++ b/kernel/trace/trace_events_user.c > @@ -1957,7 +1957,8 @@ static ssize_t user_events_write_core(struct file *file, struct iov_iter *i) > > if (unlikely(faulted)) > return -EFAULT; > - } > + } else > + return 0; > sunliming, If you missed the conversation about the pull request with Linus, he pointed out (correctly) that we were mistaken to tell you to return zero. It should return an error if the ring buffer is disabled. But instead of returning -EFAULT, let's follow the behavior of trace_marker and return -EBADF. This way user space has a better idea why it failed. Care to send another update? Thanks! -- Steve > return ret; > }
diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 1ac5ba5685ed..c085ff829a58 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1957,7 +1957,8 @@ static ssize_t user_events_write_core(struct file *file, struct iov_iter *i) if (unlikely(faulted)) return -EFAULT; - } + } else + return 0; return ret; }