Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4679780rwb; Tue, 8 Aug 2023 12:01:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEygTSf4OGABr8vrGh3Mlgg6XVBX4d1foNMuCMLOIFHwVwlF/BAp3qE+HLhRwblHRCdrPCh X-Received: by 2002:a19:6903:0:b0:4f6:29cf:c0dd with SMTP id e3-20020a196903000000b004f629cfc0ddmr275509lfc.8.1691521295005; Tue, 08 Aug 2023 12:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691521294; cv=none; d=google.com; s=arc-20160816; b=REvVkuSrpuHNamRTjStw7Q6BrG7XiMFwhwVmwn5oqzQBmduV7XBk/+2OA5VaDxem/Z KkJrngWBaGHIi3BnnmFvuHzjVyLjP3y3wy/xtQhufJIdmWC6UIHpeMIJm9w91xC0Sgee ut/PP5JJmudRvtLW5CDxdc9oykGzSqKKVcZ/bkWIUyo1ub0DxPKSwhILduxq+3GEDcRv W6YZ58d4ubSwHUBINOcafED69H7vK9WWnuIShysw5pGjCus+aX7ocyyGX+0iWSURJLsh 7Q5yuVHFbwpLp0QWkFWE4RxrmNhl2zpwoEEuJ1E2q0ZbnGWLumO6UW6yu6Bv5mE/DUW8 lEUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:feedback-id:dkim-signature:dkim-signature; bh=BcvV+WKIQPajFkywU4vq7mmCKoFIGw6OUURHQx3H/pQ=; fh=VtDK9iO6sR6TR5zOh3h8eyiaFGnfglNk3AxiKkUbyHI=; b=qf1gZhfOa8J5x7NCiaTweUacGpSAn4MK7X98AsHeFv1jkfCEhShB3LB/TY2eBfPmGP 65KpYwKekUkJYb/2Lbz8/GbcDhpKAi4Q++EZTYnwmq5po+IDl0v2Odp+NAuiveGZXSaV rG3jmiJbiaP1YAqduvbDJVEV+9syzEmOZUs3phT9AbX9HuLA/9EXRh/ViqEIZ21lPjsy qPP6UGsqaE4NcRA1DBbb7Aiq3DVttjRwvRA0bVLQqkUo/Yk2xU2cYCqQVuUSglCdK7Ap EXiopvCHN3r59ep2E3wlMFEmmvd1b3CHkQOxfzLx7qJPHjAZRV0DYF5cuEulRGxSWDr5 IXKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@manjusaka.me header.s=fm3 header.b=JPGP48TZ; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=Va+Qo9Kq; 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 t17-20020aa7d711000000b00523339f71b0si4406167edq.69.2023.08.08.12.01.08; Tue, 08 Aug 2023 12:01:34 -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=@manjusaka.me header.s=fm3 header.b=JPGP48TZ; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=Va+Qo9Kq; 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 S233841AbjHHQ6x (ORCPT + 99 others); Tue, 8 Aug 2023 12:58:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233765AbjHHQ55 (ORCPT ); Tue, 8 Aug 2023 12:57:57 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90CEE4C33; Tue, 8 Aug 2023 08:42:30 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 5A96D5C0067; Tue, 8 Aug 2023 04:46:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 08 Aug 2023 04:46:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjusaka.me; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1691484411; x=1691570811; bh=BcvV+WKIQPajFkywU4vq7mmCKoFIGw6OUUR HQx3H/pQ=; b=JPGP48TZDMQQ0+1F+s66iC9WJgcLfb/8JA7fH4SgnXnlD8IjRjN 8wmXE7JWzsZCtgZ9li4TIoFxP+vVaTpltbgl10Gnyc8mszhhgjygBuyBf8Tv2Fyt x0WYh6GJKRagucgw2DX4Aqb9kuaWyx8UqPDQ7bMqpaNn/6Pb92cD7qUN6II3wg0k QeMKjIKYi60p2ZjpoLjXAzUp0evwOS1aZOitR/eKBl2LpcYgf+snnErwlkTJ/o+m X5ZS8V89Qbp7KJSKyfUyn1RjH3/cYdV3iy3dlPoQhd3TZCkcMhG7cr1Jc1JOlN3H Fk4VAzpFo6Imt16OE3A5kvyUuD6FwhxfISQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1691484411; x=1691570811; bh=BcvV+WKIQPajFkywU4vq7mmCKoFIGw6OUUR HQx3H/pQ=; b=Va+Qo9KqKivkkA4vaEp6cRXcNZcJaB9iP6mrTlAEEgyAbkbmPcu x9ipOaaqG95BtETWpGbAMoqd0nmO6dzg+o4vc/xFZM6+OpGElvb/YGMwKsOLBDcV 8j3q+/5FrQTpbEXZ0LUBaLcM3Zgz4nuulbv0CbFui4bhXgKPNFYyvA9r8xwtxBLX RQbhqB5ZCDOSiDAPSrf4qXvpWfcH35SEv7boGWWft9xDr5DJn/JYXUtrfNkffmUg z7QOjKiZuN+ar5DVo0drb7TyLMvPkpi86QMP/7Ezh+2vEl/Tl9JgQ2oP1paR45sA Ql0dE3W86YEAYBZOPzr4q56AIZMQCY5w09w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrledvgddtkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeenucfhrhhomhepofgrnhhj uhhsrghkrgcuoehmvgesmhgrnhhjuhhsrghkrgdrmhgvqeenucggtffrrghtthgvrhhnpe duveevjefhjedvgeevvdeutdeukeeljeelhfeftdehkefhfeeivdfgudekueeileenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmvgesmhgrnh hjuhhsrghkrgdrmhgv X-ME-Proxy: Feedback-ID: i3ea9498d:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 8 Aug 2023 04:46:45 -0400 (EDT) Message-ID: Date: Tue, 8 Aug 2023 16:46:41 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] tracepoint: add new `tcp:tcp_ca_event` trace event Content-Language: en-US To: Eric Dumazet Cc: ncardwell@google.com, bpf@vger.kernel.org, davem@davemloft.net, dsahern@kernel.org, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mhiramat@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, rostedt@goodmis.org References: <20230808055817.3979-1-me@manjusaka.me> From: Manjusaka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED 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 2023/8/8 16:26, Eric Dumazet wrote: > On Tue, Aug 8, 2023 at 7:59 AM Manjusaka wrote: >> >> In normal use case, the tcp_ca_event would be changed in high frequency. >> >> It's a good indicator to represent the network quanlity. > > quality ? > > Honestly, it is more about TCP stack tracing than 'network quality' > >> >> So I propose to add a `tcp:tcp_ca_event` trace event >> like `tcp:tcp_cong_state_set` to help the people to >> trace the TCP connection status >> >> Signed-off-by: Manjusaka >> --- >> include/net/tcp.h | 9 ++------ >> include/trace/events/tcp.h | 45 ++++++++++++++++++++++++++++++++++++++ >> net/ipv4/tcp_cong.c | 10 +++++++++ >> 3 files changed, 57 insertions(+), 7 deletions(-) >> >> diff --git a/include/net/tcp.h b/include/net/tcp.h >> index 0ca972ebd3dd..a68c5b61889c 100644 >> --- a/include/net/tcp.h >> +++ b/include/net/tcp.h >> @@ -1154,13 +1154,8 @@ static inline bool tcp_ca_needs_ecn(const struct sock *sk) >> return icsk->icsk_ca_ops->flags & TCP_CONG_NEEDS_ECN; >> } >> >> -static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event) >> -{ >> - const struct inet_connection_sock *icsk = inet_csk(sk); >> - >> - if (icsk->icsk_ca_ops->cwnd_event) >> - icsk->icsk_ca_ops->cwnd_event(sk, event); >> -} >> +/* from tcp_cong.c */ >> +void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event); >> >> /* From tcp_cong.c */ >> void tcp_set_ca_state(struct sock *sk, const u8 ca_state); >> diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h >> index bf06db8d2046..b374eb636af9 100644 >> --- a/include/trace/events/tcp.h >> +++ b/include/trace/events/tcp.h >> @@ -416,6 +416,51 @@ TRACE_EVENT(tcp_cong_state_set, >> __entry->cong_state) >> ); >> >> +TRACE_EVENT(tcp_ca_event, >> + >> + TP_PROTO(struct sock *sk, const u8 ca_event), >> + >> + TP_ARGS(sk, ca_event), >> + >> + TP_STRUCT__entry( >> + __field(const void *, skaddr) >> + __field(__u16, sport) >> + __field(__u16, dport) >> + __array(__u8, saddr, 4) >> + __array(__u8, daddr, 4) >> + __array(__u8, saddr_v6, 16) >> + __array(__u8, daddr_v6, 16) >> + __field(__u8, ca_event) >> + ), >> + > > Please add the family (look at commit 3dd344ea84e1 ("net: tracepoint: > exposing sk_family in all tcp:tracepoints")) > > > >> + TP_fast_assign( >> + struct inet_sock *inet = inet_sk(sk); >> + __be32 *p32; >> + >> + __entry->skaddr = sk; >> + >> + __entry->sport = ntohs(inet->inet_sport); >> + __entry->dport = ntohs(inet->inet_dport); >> + >> + p32 = (__be32 *) __entry->saddr; >> + *p32 = inet->inet_saddr; >> + >> + p32 = (__be32 *) __entry->daddr; >> + *p32 = inet->inet_daddr; > > We keep copying IPv4 addresses that might contain garbage for IPv6 sockets :/ > >> + >> + TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr, >> + sk->sk_v6_rcv_saddr, sk->sk_v6_daddr); > > I will send a cleanup, because IP_STORE_ADDRS() should really take > care of all details. > > >> + >> + __entry->ca_event = ca_event; >> + ), >> + >> + TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c ca_event=%u", >> + __entry->sport, __entry->dport, >> + __entry->saddr, __entry->daddr, >> + __entry->saddr_v6, __entry->daddr_v6, >> + __entry->ca_event) > > Please print the symbol instead of numeric ca_event. > > Look at show_tcp_state_name() for instance. Thanks for the kindness code review, I still get some issue here(Sorry for the first time to contribute): 1. > We keep copying IPv4 addresses that might contain garbage for IPv6 sockets :/ I'm not getting your means, would you mean that we should only save the IPv4 Address here? 2. > I will send a cleanup, because IP_STORE_ADDRS() should really take care of all details. I think you will make the address assignment code in TP_fast_assign as a new function. Should I submit the new change until you send the cleanup patch or I can make this in my patch(cleanup the address assignment)