Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8821828rwl; Tue, 10 Jan 2023 20:15:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXuykod8rD0E56tfExhZE1WXN/b3aVCNf1utdZc93+22DI0NfgR6TQwBENLklNS1A4xkmlJN X-Received: by 2002:a17:906:99d0:b0:84d:43e4:479b with SMTP id s16-20020a17090699d000b0084d43e4479bmr10215423ejn.36.1673410541564; Tue, 10 Jan 2023 20:15:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673410541; cv=none; d=google.com; s=arc-20160816; b=VvBDPL4HzGyI8qzljHIZcytdbXBJy0IQHoe04p9P4eurZOgXbI5jl/KI/EdpMneNzk pLAfzsJdyhYbJ48MXouO9Vw7mqoPaKtqy4N3q+TN/BzHWWAQZ1el6nHUQZWjzmoyqmbR 3KjxBwy/wqhO/Q0Zc27JzXpK+AVGJ934o28/yqaXzN73xD7v9iM89E6SYOINQZyZ12Jb T+ptLAd+M0RwvU6xe0zWLn3Rr0yBALcq8kC0y91d907rEIp9p1nNyEukq/FfufeU6a0l cTGCjJBpYQpsed20p6moHHSwhPnaY3gxOUudXKkPmjIK90FN6rqkh9AgqS1y/N1Gs0aV Rdiw== 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=VQOEXukn20hgpPjJ+OLqtGzuCJHE3pnunV9JohjE5Tc=; b=LuhDRkFGG5ck4bt4O3p5vVnAeKYmqEQN/ve7aAnH2PAQoXlXikCMYfqDKwIvPcm85t 1h7FA6iMBqTUEBvfmo02cabGMnkTONce2aczg4RmZPQaYAe2ImOddVYABu8ZqsUu6ci8 ybsWrQAHxGweiR4Sa/eWu3aipTBq51x+uKhTV2k7wJonln6Q7AqIXJ9sSo1vfgubbM9o drYxD6ua5GFRX85Z3YqX9cEE/ueLLu/zZciXN7Hvku8GSxG7RyMglkT86VydRFa3hsva amArJlLL4HVPSBw9Moy5mJXsFmdMKG7gcbQXL+A29qHCLzaLfNhIM+1QNg4bZXPX8IQr Jt8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=XkN9DGFQ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fy15-20020a1709069f0f00b007c0870b3739si9950210ejc.938.2023.01.10.20.15.28; Tue, 10 Jan 2023 20:15:41 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=XkN9DGFQ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231174AbjAKDyA (ORCPT + 53 others); Tue, 10 Jan 2023 22:54:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230015AbjAKDx6 (ORCPT ); Tue, 10 Jan 2023 22:53:58 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2D4DFCDD for ; Tue, 10 Jan 2023 19:53:36 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id co23so13823292wrb.4 for ; Tue, 10 Jan 2023 19:53:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.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=VQOEXukn20hgpPjJ+OLqtGzuCJHE3pnunV9JohjE5Tc=; b=XkN9DGFQRtzmQXS8sE2gm0e69v1OxxFkqEZ2dZbFKJxPhuYhDSk3Rzj4nxJqgDP/x4 mFvqA32CcyapU+ZKOhga2o7c/v3i+vdOT2rY6ev2S2U96Fx9EqqxF29ijBvVgFt3rnjf LsJIakdCBeJoaAT2Gi9NmI3t1AeB7PgAeQMiX0GTSYYdMVhFEoPxyMsSx96i1uVW/Xgs thaM0wIFAvYZ0/aueVXBOnKrDtY5q91WQ0IowrBit1xnGTpjtbFhwRgjiF+Pu47W6uBL eQ/bne9H7fNYjqZByJizcovVpvPWC+QZydxhOxzOsMxsZdS80DrW755B3H5VBu4vJ1Tt M+sw== 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=VQOEXukn20hgpPjJ+OLqtGzuCJHE3pnunV9JohjE5Tc=; b=obWatFhZL64CafhvNsYW+KHUzeX5x4Xw48WCwmk4t53I1M9AuBs6EWHaQ6mdPy8tVk RBTVC/DEek9gZ2nU8VSny43wgjnmaTi+mRFNEAZR30VODHkveCNW/D9llHro3Ih0EYkf XJ6bEJmDiAB8/flGPU0IaJdABbeVQF90aNEZfDBWnfuzGnON12fuO0bOk02A+DNFwO7r jkuR9ENeoE5DNyJwOF8e4k66v+ciz5Ju3YuLdve81gEed679HjL5KaG8zKX9h/4zgvoL H0YKvobQJni27w+XuALNhp8p7kwyzsHXX4MCk2OzO08EwIyFEe61wSMscaY9G4bTFioY 07dA== X-Gm-Message-State: AFqh2koe1Zs3c4Mkz8gpZP9yBmc98pGzetM6xbXmN+9E5J65Q5SkrqFk Nbarnn+sA7qQwdmpxdDS0xMIpBJgTo8yJmi6Epzr73MbW0YmNHEExs4= X-Received: by 2002:a5d:6207:0:b0:242:2748:be7a with SMTP id y7-20020a5d6207000000b002422748be7amr4436775wru.116.1673409215323; Tue, 10 Jan 2023 19:53:35 -0800 (PST) MIME-Version: 1.0 References: <20230110091356.1524-1-cuiyunhui@bytedance.com> <20230110104419.67294691@gandalf.local.home> In-Reply-To: <20230110104419.67294691@gandalf.local.home> From: =?UTF-8?B?6L+Q6L6J5bSU?= Date: Wed, 11 Jan 2023 11:53:24 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v5] sock: add tracepoint for send recv length To: Steven Rostedt Cc: Eric Dumazet , 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, dust.li@linux.alibaba.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Tue, Jan 10, 2023 at 11:44 PM Steven Rostedt wrote= : > > > TP_printk("sk address =3D %p, family =3D %s protocol =3D %s, leng= th =3D %d, error =3D %d, flags =3D 0x%x", > __entry->sk, show_family_name(__entry->family), > show_inet_protocol_name(__entry->protocol), > __entry->ret > 0 ? ret : 0, __entry->ret < 0 ? ret : 0, > __entry->flags) > ); > > DEFINE_EVENT(sock_msg_length, sock_send_length, > TP_PROTO(struct sock *sk, int ret, int flags), > > TP_ARGS(sk, ret, flags) > ); > > DEFINE_EVENT_PRINT(sock_msg_length, sock_recv_length, > TP_PROTO(struct sock *sk, int ret, int flags), > > TP_ARGS(sk, ret, flags) > > TP_printk("sk address =3D %p, family =3D %s protocol =3D %s, leng= th =3D %d, error =3D %d, flags =3D 0x%x", > __entry->sk, show_family_name(__entry->family), > show_inet_protocol_name(__entry->protocol), > !(__entry->flags & MSG_PEEK) ? __entry->ret : __entry->= ret > 0 ? ret : 0, > __entry->ret < 0 ? ret : 0, > __entry->flags) > ); > #endif /* _TRACE_SOCK_H */ > > As DEFINE_EVENT_PRINT() uses the class template, but overrides the > TP_printk() portion (still saving memory). > Hi Steve, Based on your suggestion, can we use the following code instead of using DEFINE_EVENT_PRINT =EF=BC=9F DECLARE_EVENT_CLASS(sock_msg_length, TP_PROTO(struct sock *sk, int ret, int flags), TP_ARGS(sk, ret, flags), TP_STRUCT__entry( __field(void *, sk) __field(__u16, family) __field(__u16, protocol) __field(int, ret) __field(int, flags) ), TP_fast_assign( __entry->sk =3D sk; __entry->family =3D sk->sk_family; __entry->protocol =3D sk->sk_protocol; __entry->ret =3D ret; __entry->flags =3D flags; ), TP_printk("sk address =3D %p, family =3D %s protocol =3D %s, length =3D %d, error =3D %d, flags =3D 0x%x", __entry->sk, show_family_name(__entry->family), show_inet_protocol_name(__entry->protocol), !(__entry->flags & MSG_PEEK) ? (__entry->ret > 0 ? __entry->ret : 0) : 0, __entry->ret < 0 ? __entry->ret : 0, __entry->flags) ); DEFINE_EVENT(sock_msg_length, sock_send_length, TP_PROTO(struct sock *sk, int ret, int flags), TP_ARGS(sk, ret, flags) ); DEFINE_EVENT(sock_msg_length, sock_recv_length, TP_PROTO(struct sock *sk, int ret, int flags), TP_ARGS(sk, ret, flags) ); > And then both calls can just do: > > trace_sock_send_length(sk, ret, 0); > > trace_sock_recv_length(sock->sk, ret, flags); > > And I bet that will also solve all the gcc being smart waste. > > -- Steve > Btw, we still need noinline helpers, right? Otherwise the following code would be inlined into sock_recvmsg: mov 0x18(%r13),%rsi mov %gs:0x7e832d87(%rip),%eax # 0x2e68c mov %eax,%eax bt %rax,0xdca591(%rip) # 0xffffffff825c5ea0 <__cpu_online_mask> Thanks, Yunhui