Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2892867rwd; Fri, 16 Jun 2023 09:27:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5gT4ZTHa5K1xkemiOKLmIyPCeGq9OQAakWJ9Sa+F7xmvY+uUTjTyTUvnYdToPwBmzIkyMo X-Received: by 2002:a9d:65d7:0:b0:6af:870c:b71b with SMTP id z23-20020a9d65d7000000b006af870cb71bmr2595707oth.27.1686932822502; Fri, 16 Jun 2023 09:27:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686932822; cv=none; d=google.com; s=arc-20160816; b=BzzGDIQiq23f7srRaWywHysEGdVJCWfwsdfKLhLQeMCQoqAAsgxx0gOeAjVSH4p2Ar 2Ff/yvfsGjsLTKIibWQTDNMU8gWzvyulScMXN8kBO0rQgIh8Wif2yqvZNBqLSqZNVRZj oPBoiegj7jcuLvk38X4yhg/K2IdKAL2EoZxbMRzSPm3NKHHfyz20PXr3ijjIQo4oDIUv WGgz5pey2NNohy8MUloJJeUap69Dp3URO8tJYqYuBs0gPgeZmX2gAKlru4LKVtCjG6/z bPrDKPJS46CxUb/w7Iwvf4IFcfzrVgfAB0xQRQ1YrG+JHBveslnCLsKEHZ9gXvIY6RgS l9Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-filter; bh=Edk+Pe6dwWUZBN6lSPEQX7bkpxex/hiXHOA1uOpPkwE=; b=PVbtMyUHeKQfnNj2pfrwKF4N0jkpjNqgcOteBsmh9uqb1TxkmHXusfFj5HkK4aNvpa uWKD2Ulf9qR4hvJ0fKQ7xODQ/ZqoRsZqhFllv8fyTkHOSW+fSUF83sv2zmadg/bIBu/R HmakrK94V0EtCadXrWv35BSIbFjC+WR7d1i8Hh2q7lyHSGBENnsVRw++9kyGAt58iuGK OgnetJAInhHVYr2//BADT7HLY2EmUZDKXarNgaTlNWOcvJX3/3BHHc3PMrvu+5kl4wR3 TihoPcz/ZVODTEtN0mcORzI1goJ6NsnjWUeelWV7wIRpaK2DfsQl11bvtuYh2venWPIR gZQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=E5LoPW3o; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k197-20020a633dce000000b005533d6d9ac7si2193176pga.584.2023.06.16.09.26.46; Fri, 16 Jun 2023 09:27:02 -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; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=E5LoPW3o; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229540AbjFPQI5 (ORCPT + 99 others); Fri, 16 Jun 2023 12:08:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjFPQIw (ORCPT ); Fri, 16 Jun 2023 12:08:52 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 320602132; Fri, 16 Jun 2023 09:08:51 -0700 (PDT) Received: from W11-BEAU-MD.localdomain (unknown [76.135.27.212]) by linux.microsoft.com (Postfix) with ESMTPSA id 6925A20FF4EB; Fri, 16 Jun 2023 09:08:50 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6925A20FF4EB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1686931730; bh=Edk+Pe6dwWUZBN6lSPEQX7bkpxex/hiXHOA1uOpPkwE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=E5LoPW3oKOYnFRFodgCb2JIWTgMcTLH+kzuuAzQFIzAoYif9rLOtJ69ZTYldyOOu2 eSIbQFTVEF5xrcRPAqPP2/GT6JBqSv3a+FPtKZOQZlX4PdgzyiYAkyQnCGrfOlRZTA NtAGF2gtuCz/14xwYnf34enPt5hm3fLTvm1t6ms0= Date: Fri, 16 Jun 2023 09:08:45 -0700 From: Beau Belgrave To: sunliming Cc: mhiramat@kernel.org, rostedt@goodmis.org, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kelulanainsley@gmail.com Subject: Re: [PATCH v2 1/3] tracing/user_events: Fix incorrect return value for writing operation when events are disabled Message-ID: <20230616160845.GA88@W11-BEAU-MD.localdomain> References: <20230609030302.1278716-1-sunliming@kylinos.cn> <20230609030302.1278716-2-sunliming@kylinos.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230609030302.1278716-2-sunliming@kylinos.cn> X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 09, 2023 at 11:03:00AM +0800, sunliming wrote: > The writing operation return the count of writes whether events are > enabled or disabled. This is incorrect when events are disabled. Fix > this by just return -ENOENT when events are disabled. > When testing this patch locally I found that we would occasionally get -ENOENT when events were enabled, but then become disabled, since writes do not have any locking around the tracepoint checks for performance reasons. I've asked a few peers of mine their thoughts on this, whether an error should result when there are no enabled events. The consensus I've heard back is that they would not consider this case an actual error, just as writing to /dev/null does not actually return an error. However, if you feel strongly we need this and have a good use case, it seems better to enable this logic behind a flag instead of having it default based on my conversations with others. Thanks, -Beau > Signed-off-by: sunliming > --- > 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..92204bbe79da 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 -ENOENT; > > return ret; > } > -- > 2.25.1