Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6368766rwl; Mon, 9 Jan 2023 07:32:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXtX8kaEDX2RKxhPAbbwr5SCP80AMsYE5whUoHkAQ0dOge1obSFrD1tzPC+d0NFyh6xCAEYY X-Received: by 2002:a05:6a20:c11a:b0:ac:82ff:9f9e with SMTP id bh26-20020a056a20c11a00b000ac82ff9f9emr92893906pzb.22.1673278363082; Mon, 09 Jan 2023 07:32:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673278363; cv=none; d=google.com; s=arc-20160816; b=sgKbfTcOgA0ueblCU0SNv9aYTiLBtxhj0ozelmuEdv+HaRgdDvn5k80u4MI+UDk/OC vppUlKOjquUWPYIOEmY136sLNljc1W5vXnoo8zTuXDoTbVL41XfnuY2+Z1ow0NzWVtbI GWYRkTRULLvHNLLeItw0jccifNIdefHKPcoH5Hv8DQE3rZW8uXKsE1CAk83e31oBU0ZC xkjjpdKqo+pIgdGaknT9oijaj+RMTt3YADuO3Dabw8GxtUoc4zktRjhgheMyVnkhjZA0 QfCnBiwF4kElT/dtrPMFdmDLSSy1GRbNEWUtJKk7irRjk2CVsDB/vJhWuQB9YmJ8sNE2 +cRQ== 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=YIgOk2vZYUEppuqaUX7d/zLpPOAJZJ2Q2hrbqGB8Xww=; b=J+C6QECR4wth/LaJQQ+2H9AlmN25geQhLZsO/jM2KLhjlMOi8GVBky6kBMWmRQlrJo Fn74PoAd4hTg0j2Kibn8jKRGOM46A1LFcvVqleU8vgSjMlygSo6DYXwtNWyQ8lbSdU7P s3OhEuAJ8tJfbd9yKLS5hHWvkhWHLzaYphSM5riip6R+TlAk+TeOfe17gUbMK4K9iycJ tVKATiP5N9QQlBhT4OnHkyZIxwVIbYhH6by1iI+fZ/C4PKPTFem9C3uH7wy5WCJeIepT Xd+fRDDncM+AmEo+kMXQ9GLUxy5tlQ5F+LSi4tDjR2yFe2/hkPxcl83L4JSlPtUaxTWU DhCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=iAttVXlq; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a9-20020a63bd09000000b0046066611352si9360079pgf.502.2023.01.09.07.32.36; Mon, 09 Jan 2023 07:32:43 -0800 (PST) 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=@google.com header.s=20210112 header.b=iAttVXlq; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234974AbjAIOyy (ORCPT + 53 others); Mon, 9 Jan 2023 09:54:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232069AbjAIOyw (ORCPT ); Mon, 9 Jan 2023 09:54:52 -0500 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10BCDD53 for ; Mon, 9 Jan 2023 06:54:51 -0800 (PST) Received: by mail-yb1-xb29.google.com with SMTP id p188so8747199yba.5 for ; Mon, 09 Jan 2023 06:54:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; 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=YIgOk2vZYUEppuqaUX7d/zLpPOAJZJ2Q2hrbqGB8Xww=; b=iAttVXlqOJBUULuAIBDupT8wsqo+pj8RZgiE+4viHriW0AennRfmWsZ43ZooCRNpou 31Sy35//2Zb7i7wliONLBc53yLMAJId9WUGpfFQD/2wEv47+FNyJhfABkEG2TQ4vKMc+ ISoQNxvxAtCFNy0W+OrJ+0deXe48HbNKVpnYCdJ7ExtyPTbur0G1Jbzp5C92kh8OqYtm ksKqa8uhCiXljYR//eDX0Y5UeM8Iu3wUiVK4Jz/+tZfk++nv4cK4gFuQE0dX7Fh+g3mD uZvmJ4rHHHZogCyUiraugNLsPyvY16xJYz6NCBMiEdo4vZ+tZfKUTQ8ViP+mBeg668wB fg6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=YIgOk2vZYUEppuqaUX7d/zLpPOAJZJ2Q2hrbqGB8Xww=; b=kJnaVvExkrCknYKgjZ4PZCKlQKYI5I/xPaiFo6LAMTuw+5ZKbtPufUu9+TZQ/FjpP0 11YVOWUFXUOYT6+ZO1c+wgezNaZtF4mOIu22+rlDGq3PjZEoYUvwbTJ/THUVxqek56Gl sMKyE40aSTy9OaZtXVel8m85n+Q7l0ALby1XOoDGgxG/jlP+NpKorskY7RfcKpu/a9Ql TERTuS7APpg2gBra23XVSbevkcOyOE8afl7b9k3XPSG4CIN5AK2rYx1bIMQ2ePw9Q5Zm ZNeZGITnXOy4ysrMtcWqAZiMJOATF/1XXT5QJaJS+YhPHM9c1MW4tS16OaB9oDUd2ekp MRWA== X-Gm-Message-State: AFqh2kq89tPsr3EThwicrhUFkR7G0K4tajGb36S9JJTrG4Bh3qd2Vd3G U/0ljfwivuI5DjHi6qjBok3TsnbjCV3QWgyw4s/391d3enejRBwG X-Received: by 2002:a25:8f89:0:b0:7b3:bb8:9daf with SMTP id u9-20020a258f89000000b007b30bb89dafmr1083040ybl.427.1673276089915; Mon, 09 Jan 2023 06:54:49 -0800 (PST) MIME-Version: 1.0 References: <20230108025545.338-1-cuiyunhui@bytedance.com> In-Reply-To: From: Eric Dumazet Date: Mon, 9 Jan 2023 15:54:38 +0100 Message-ID: Subject: Re: [External] Re: [PATCH v4] sock: add tracepoint for send recv length To: =?UTF-8?B?6L+Q6L6J5bSU?= Cc: rostedt@goodmis.org, mhiramat@kernel.org, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, kuniyu@amazon.com, xiyou.wangcong@gmail.com, duanxiongchun@bytedance.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, 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 Mon, Jan 9, 2023 at 2:13 PM =E8=BF=90=E8=BE=89=E5=B4=94 wrote: > > On Mon, Jan 9, 2023 at 5:56 PM Eric Dumazet wrote: > > > > > Note: At least for CONFIG_RETPOLINE=3Dy and gcc 12.2, compiler adds man= y > > additional instructions (and additional memory reads), > > even when the trace point is not enabled. > > > > Contrary to some belief, adding a tracepoint is not always 'free'. > > tail calls for example are replaced with normal calls. > > > > > > .popsection > > > > # 0 "" 2 > > #NO_APP > > .L106: > > # net/socket.c:1008: } > > movl %ebx, %eax # , > > popq %rbx # > > popq %rbp # > > popq %r12 # > > ret > > .L111: > > # ./include/trace/events/sock.h:308: DEFINE_EVENT(sock_msg_length, > > sock_recv_length, > > > > Hi Eric, Thanks for your reply, In fact, it is because the > definition of the tracepoint function is inline, > Not just these two tracepoints=EF=BC=8Cright? > > #define __DECLARE_TRACE(name, proto, args, cond, data_proto) \ > ... > static inline void trace_##name(proto) > > Regarding the above issue, I plan to optimize it like this: > > static noinline void call_trace_sock_send_length(struct sock *sk, __u16 f= amily, > __u16 protocol, int ret, int = flags) > { > trace_sock_send_length(sk, family, protocol, ret, 0); > } > > static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *= msg) > { > int ret =3D INDIRECT_CALL_INET(sock->ops->sendmsg, inet6_sendmsg, > inet_sendmsg, sock, msg, > msg_data_left(msg)); > BUG_ON(ret =3D=3D -EIOCBQUEUED); > > if (trace_sock_send_length_enabled()) { A barrier() is needed here, with the current state of affairs. IMO, ftrace/x86 experts should take care of this generic issue ? > call_trace_sock_send_length(sock->sk, sock->sk->sk_family= , > sock->sk->sk_protocol, ret, 0= ); > } > return ret; > } > > What do you think? > > Thanks, > Yunhui