Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp759437rwd; Mon, 12 Jun 2023 23:11:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5dWqrX2uICWnfZt2e5H9pTm892R3vNuSd4sfM9pipnbnuhRzgPLkHKAlB5DJBK8EenOuDN X-Received: by 2002:a17:907:6d08:b0:978:992e:efc4 with SMTP id sa8-20020a1709076d0800b00978992eefc4mr10533352ejc.8.1686636710119; Mon, 12 Jun 2023 23:11:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686636710; cv=none; d=google.com; s=arc-20160816; b=SQ0F5kMfv99lQGxEt06hcBcxbQVMirv9JzDb0d95SylZcGIx1t8/jcLxIXL00C+6pX qVqJjVqRWVpPvXRKjzBApPnDUHnAg4fmHTbL7rO8KNL9YAyB+B8VyR9VobseOl2S9j+W LD2CJrOn4zR0eSYqhhHNihC7rZlee92MkB2vH8VM9GlpNkLFL6AcS0VAL4nKbcx32GOw W/UHIq3hCb7PFi3LW3JtulMdp3KbVx9HFARMnRnw3Vu3XeUhHISVcZu8BX18ZZZjoOej i1LLCviOGZ9kcQCMxG+5b08pzgwTx5030GXZ8Yq74tO0if0nd46lWohdcHmeHB824Huj 6XLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=pnWtW/ElDXGPeeUTMVZo+NOre0OXSgOJd8mjZ41ZIeI=; b=QNVq/qnvzyndPMeGA0s+x/ku6m481Vr9gf5BtetpPg00NpS1P11TLfrz/Z0Ri/F0R3 K98wpgUBhaOjjMWtKVhuFZEJfHp44WtZ20YdQjrPYacJMPq1vYM9+4rYAxfVeDit/pdf vxC5gY6rtwczth2iyud3GuXIITgOInpALd/I1RwHQD/P3Y9CBlRKIabh6wlbw+MAbkky d+w6XeAHoUXezY0bDYizMQqmdb1MnV1++GDjXzMM0PsS5TbLLi15Wk+0lZSivy3TP+5n wqz3nJUK53cJoHo4h7fDfjm9yT2wfFZEf74wE9LWdt7r60AnPPUnbkpIrB4Rstpb4wY/ 0w9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=iVi2RF7A; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rl11-20020a170907216b00b0097886add37asi6369501ejb.980.2023.06.12.23.11.24; Mon, 12 Jun 2023 23:11:50 -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=@gmail.com header.s=20221208 header.b=iVi2RF7A; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240011AbjFMFwq (ORCPT + 99 others); Tue, 13 Jun 2023 01:52:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233225AbjFMFwp (ORCPT ); Tue, 13 Jun 2023 01:52:45 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1570493; Mon, 12 Jun 2023 22:52:44 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id 5b1f17b1804b1-3f736e0c9b1so53336605e9.3; Mon, 12 Jun 2023 22:52:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686635562; x=1689227562; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pnWtW/ElDXGPeeUTMVZo+NOre0OXSgOJd8mjZ41ZIeI=; b=iVi2RF7AC3GEQKcNXSzQ+N+muvrDe7wYIoGFL/z160heGt9CG9Mujh3JFiPan8LxmY wa/I9uplZsrhtfMcFTJkfM6ocy255EyPIkhPb7u99+dKNr1vQKPpWUP0oBxLJRi3Hmdw gBz4H6CdvufVa83zAP1AQQt8BWpndCf7yhN+AsSlMv2BbFzIuEpp4Yxiw+gmhIPq/cTC kVo8PCEPlRs/pC43r6l16r4YJshAyaZT+6S832TOSkxleY4PaaYJfjCambPWYv0HJVxm kFaeAF+Ud3gy2vvOPd+dxcbfGsC2ZdJ80jJGvPdbPv+92I5ecG/jYj6id+q2vNlM9gO1 pwIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686635562; x=1689227562; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pnWtW/ElDXGPeeUTMVZo+NOre0OXSgOJd8mjZ41ZIeI=; b=fhWDpdLbnMbrBMVMejOANn4hmRxn3XlkVjLPIRGwdMip+0YreaaWAAFLT6T69TOvtG +j9IufMjGE57fIoAb9WZMieDLTViulXoWslDU+l5mHTzaSlMmQYClbVKQyABl95nH348 rCpMv1TQME9KICMFeKtkUvDDejzRNhF8R3oYyoQJcis1WGJkA0rJNUA5Y8ARimUfPrTq P0yQINSifZB+5eLBW7oBPIs0R/+givRDpM+FcrdWF64lfUuG5F6mOzI4Ux1TXe9HP91o ILVHNEassQWL8MMJJt9WZcRaA0mPl4gEe6EJKIEk+Qbhls2UojpjCwUgdgdilXEbFLeo amsw== X-Gm-Message-State: AC+VfDzz46nFE8tufPvCgWStLWwCQPgy2O+cF/XgIaP0Hi1OPNoHpWTU p8XfrKMVC/iqLYly2eVn+8gk1aiXJBMiZ2h5CvUV0Pt8cG+F X-Received: by 2002:a05:6000:1282:b0:30f:c6c3:e6d9 with SMTP id f2-20020a056000128200b0030fc6c3e6d9mr2941734wrx.46.1686635562254; Mon, 12 Jun 2023 22:52:42 -0700 (PDT) MIME-Version: 1.0 References: <20230608011554.1181097-1-sunliming@kylinos.cn> <20230608011554.1181097-2-sunliming@kylinos.cn> <20230608171921.GA74@W11-BEAU-MD.localdomain> In-Reply-To: <20230608171921.GA74@W11-BEAU-MD.localdomain> From: sunliming Date: Tue, 13 Jun 2023 13:52:29 +0800 Message-ID: Subject: Re: [PATCH 1/3] tracing/user_events: Fix incorrect return value for writing operation when events are disabled To: Beau Belgrave 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SCC_BODY_URI_ONLY,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: X-Mailing-List: linux-kernel@vger.kernel.org Beau Belgrave =E4=BA=8E2023=E5=B9=B46=E6=9C=889= =E6=97=A5=E5=91=A8=E4=BA=94 01:19=E5=86=99=E9=81=93=EF=BC=9A > > On Thu, Jun 08, 2023 at 09:15:52AM +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 -EFAULT when events are disabled. > > > > 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_even= ts_user.c > > index 1ac5ba5685ed..970bac0503fd 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 -EFAULT; > > > > I'm not sure this is a good idea. Imagine this scenario: > A user process writes out a user_event and it hits a fault that gets > returned as errno (EFAULT). > > The user process is likely to either forget it and say, not worth > retrying, or it will retry (potentially in a loop). > > If the process does retry and it's now disabled, it might try many > times. > > I think that -ENOENT is a better error to use here. That way a user > process will know it got disabled mid-write vs a fault that might want > to be re-attempted. > > Thanks, > -Beau > I think you are right. I have resend the V2 version of this series of patches based on suggestions, patches link : https://lore.kernel.org/linux-trace-kernel/20230609030302.1278716-1-sunlimi= ng@kylinos.cn/T/#t Thanks. > > return ret; > > } > > -- > > 2.25.1