Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8066423rwl; Tue, 10 Jan 2023 08:39:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXt9Aesgl4ObSKhO3K/ZOeC5K47n7CyLwzf/PWXF3b9aRu3E6gaRpHKbnuCMlIf6nQ3FUTZ7 X-Received: by 2002:a17:90a:af91:b0:219:de9b:f397 with SMTP id w17-20020a17090aaf9100b00219de9bf397mr72905743pjq.3.1673368778531; Tue, 10 Jan 2023 08:39:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673368778; cv=none; d=google.com; s=arc-20160816; b=IoIoSd6PtE9biN43T6Wmm669StOCst1D0PXQrRzu9nh7H8vPfADeReuH4c7yNKGZE0 mU867syW7StNUdQxw+k1gVRTbF55KV6SKbzieGc7tGF1wxfEHvEXEucLgWpsEZZgKlgU 0QBd5fkUJ7IoyPRBhf7uVYydwD/OvTXhg5/dSpCZjDBdDR9GcM8ctJHeef85dSILj6Rc +dno+Ab81QwvNP17tHkAzHOt4hxJrZCKsH21yrnEP7bFAmUDBqWoel9vTijqBpl0bT9a jP36sRtWjxMqbNdvV501NC/y3UG+oJ+IyNP70ycwil+xiSxJLvXyMAo7McbpbctyplOI r0Ng== 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:subject:cc:to:from:date; bh=aJn0LTGiX/JqbyF7T4bVI0uzKCG5sLsXJxPxpelhWlM=; b=Fl+d9R+5G58vc4jIeJgdqPHmjJE3pnKMR7K7vmUtazd/RtLSmSxbyF2XgP+9CFrIy2 9vlGuo0yTq87BgbMPGA+3oIGuEB1TmWnzng0NITbJ0P9zkKJu4/OBEzWV5yYsrMhsrF1 wSdyG4gMhsS7Cf7R6WLLpVlnf/Pun+z62JCofY+44YqTPbOv0E2gxQAPfQWf5kG03xwM giVpxU6xQeoWt2pHo8Dp0hNZV689SE/N8QRhFqdSYlabpADMPD64HwULCtxDoAdzYI4S 312dOetzgxz37bOgEhgmo6R4OTxXXv+xSbFZHpZhu6w4UaMUbMrrBpbsAH9NZIXXP729 f77Q== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lr2-20020a17090b4b8200b0021409b2423esi17185713pjb.86.2023.01.10.08.39.31; Tue, 10 Jan 2023 08:39:38 -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; 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 S238659AbjAJPoj (ORCPT + 53 others); Tue, 10 Jan 2023 10:44:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238799AbjAJPo0 (ORCPT ); Tue, 10 Jan 2023 10:44:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1274448CE6; Tue, 10 Jan 2023 07:44:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8D10461796; Tue, 10 Jan 2023 15:44:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFAEBC433D2; Tue, 10 Jan 2023 15:44:20 +0000 (UTC) Date: Tue, 10 Jan 2023 10:44:19 -0500 From: Steven Rostedt To: Eric Dumazet Cc: Yunhui Cui , 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 Subject: Re: [PATCH v5] sock: add tracepoint for send recv length Message-ID: <20230110104419.67294691@gandalf.local.home> In-Reply-To: References: <20230110091356.1524-1-cuiyunhui@bytedance.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS 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 Tue, 10 Jan 2023 12:49:30 +0100 Eric Dumazet wrote: > > +static noinline void call_trace_sock_recv_length(struct sock *sk, int ret, int flags) > > +{ > > + trace_sock_recv_length(sk, !(flags & MSG_PEEK) ? ret : > > + (ret < 0 ? ret : 0), flags); > > Maybe we should only 'fast assign' the two fields (ret and flags), > and let this logic happen later at 'print' time ? > > This would reduce storage by one integer, and make fast path really fast. > > This also could potentially remove the need for the peculiar construct with > these noinline helpers. I noticed that the trace_sock_send_length() doesn't have this logic, and they are both DEFINE_EVENT() of the same DECLARE_EVENT_CLASS(). But we could change this too, by the following: /* * sock send/recv msg length */ 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 = sk; __entry->family = sk->sk_family; __entry->protocol = sk->sk_protocol; __entry->length = ret > 0 ? ret : 0; __entry->error = ret < 0 ? ret : 0; __entry->flags = flags; ), TP_printk("sk address = %p, family = %s protocol = %s, length = %d, error = %d, flags = 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 = %p, family = %s protocol = %s, length = %d, error = %d, flags = 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). 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