Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1788565rdg; Sat, 12 Aug 2023 17:22:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwcfIVKVt7hoX6dUDi8lrHEUUQXjbFZBKrn9ad6qz/oVVyb4BLqqlmfCY1pDwZ9su7aLpN X-Received: by 2002:a17:903:1251:b0:1b5:674d:2aa5 with SMTP id u17-20020a170903125100b001b5674d2aa5mr7068211plh.13.1691886146832; Sat, 12 Aug 2023 17:22:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691886146; cv=none; d=google.com; s=arc-20160816; b=pmtpg0nlc5wwXcZtIkE5NGC4Nlq1e7Md9v+K06QezlYJIxB/K1YGtk54JoU2lAiurN wD+AADj3dJCayOIqqbCUiyxGpzc+04BivW4Ol5KOoflpuluoBDujWWqFxVPxP53CvyWL +geXIZNXwM4gbdw0o8W8WBu4J2BHNCpDtWKf9ZzvjQgv/J9pEswcW0XaH9b9YU0AH+C0 Y+ZrCsq/tX3PRaAMq03uEAGe2+O5YaT2IW5GwzTNnz1C+JwsG0JKNjeuOK9QYuNbz4Y6 qmJYLJSt4xgZTe6uvomY/9dU30XRDsyDbbunUezvXcub7ZdIwNaZrTFbDJ0cX1VW6Rfz 7BkA== 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=Ggu6izMHIfOGDT03aRgCqSflXrhQ70xaKssOhSnccCA=; fh=5eNLAf/Rs6aa48wiiuv2MeoaRD/0h5GbiLmJG1dX4kI=; b=Bzt5/le+vPB3RKHn6hpcOL6IcoGA0VKdMLVacLId8hywqHvE4t0HPoihkwo3VE3B7k 7hEtgIeSl/0zusfo8EMKjx8ev0eWXxz8NeAomZJwSRieICG+D5h1E6jwqQ6dajCIErBb 34K9LPIpX0leuMEMr+pJn5qLgYVDBv9C7mfWvRUSymciAYU4ol55+mi9VJ6EQwg0gjs9 4P/+H4ckwsMOTyOVLrKEAhBzvdrajg+XkdGF2I7S8nJL8/lNL4bZWeWMsn9jRqoNM5x6 sSl9nIDA3b8TryHtGx9E3xVnOH8MV9Me8byxahgKQV+nEX6fO1CzunrJctVlTuRFK4eM YoEA== 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 f7-20020a170902ce8700b001bb9c731a41si5572869plg.623.2023.08.12.17.22.13; Sat, 12 Aug 2023 17:22:26 -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; 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 S229740AbjHLXAU (ORCPT + 99 others); Sat, 12 Aug 2023 19:00:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbjHLXAT (ORCPT ); Sat, 12 Aug 2023 19:00:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60D85198E; Sat, 12 Aug 2023 16:00:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3332261FFF; Sat, 12 Aug 2023 23:00:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FAEAC433C7; Sat, 12 Aug 2023 23:00:19 +0000 (UTC) Date: Sat, 12 Aug 2023 19:00:17 -0400 From: Steven Rostedt To: Manjusaka Cc: edumazet@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, ncardwell@google.com, netdev@vger.kernel.org, pabeni@redhat.com Subject: Re: [PATCH v3] tracepoint: add new `tcp:tcp_ca_event` trace event Message-ID: <20230812190017.3a62396c@rorschach.local.home> In-Reply-To: References: <20230812201249.62237-1-me@manjusaka.me> 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=-1.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 On Sun, 13 Aug 2023 04:17:24 +0800 Manjusaka wrote: > On 2023/8/13 04:12, Zheao Li wrote: > > In normal use case, the tcp_ca_event would be changed in high frequency. > > > > The developer can monitor the network quality more easier by tracing > > TCP stack with this TP event. > > > > 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: Zheao Li > > --- > > include/net/tcp.h | 9 ++---- > > include/trace/events/tcp.h | 60 ++++++++++++++++++++++++++++++++++++++ > > net/ipv4/tcp_cong.c | 10 +++++++ > > 3 files changed, 72 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 7b1ddffa3dfc..993eb00403ea 100644 > > --- a/include/trace/events/tcp.h > > +++ b/include/trace/events/tcp.h > > @@ -41,6 +41,18 @@ > > TP_STORE_V4MAPPED(__entry, saddr, daddr) > > #endif > > > > +/* The TCP CA event traced by tcp_ca_event*/ > > +#define tcp_ca_event_names \ > > + EM(CA_EVENT_TX_START) \ > > + EM(CA_EVENT_CWND_RESTART) \ > > + EM(CA_EVENT_COMPLETE_CWR) \ > > + EM(CA_EVENT_LOSS) \ > > + EM(CA_EVENT_ECN_NO_CE) \ > > + EMe(CA_EVENT_ECN_IS_CE) > > + > > +#define show_tcp_ca_event_names(val) \ > > + __print_symbolic(val, tcp_ca_event_names) > > + > > /* > > * tcp event with arguments sk and skb > > * > > @@ -419,6 +431,54 @@ 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) > > + __field(__u16, family) > > + __array(__u8, saddr, 4) > > + __array(__u8, daddr, 4) > > + __array(__u8, saddr_v6, 16) > > + __array(__u8, daddr_v6, 16) > > + __field(__u8, ca_event) > > + ), > > + > > + 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); > > + __entry->family = sk->sk_family; > > + > > + p32 = (__be32 *) __entry->saddr; > > + *p32 = inet->inet_saddr; > > + > > + p32 = (__be32 *) __entry->daddr; > > + *p32 = inet->inet_daddr; > > + > > + TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr, > > + sk->sk_v6_rcv_saddr, sk->sk_v6_daddr); > > + > > + __entry->ca_event = ca_event; > > + ), > > + > > + TP_printk("family=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c ca_event=%s", > > + show_family_name(__entry->family), > > + __entry->sport, __entry->dport, > > + __entry->saddr, __entry->daddr, > > + __entry->saddr_v6, __entry->daddr_v6, > > + show_tcp_ca_event_names(__entry->ca_event)) > > +); > > + > > #endif /* _TRACE_TCP_H */ > > > > /* This part must be outside protection */ > > diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c > > index 1b34050a7538..fb7ec6ebbbd0 100644 > > --- a/net/ipv4/tcp_cong.c > > +++ b/net/ipv4/tcp_cong.c > > @@ -34,6 +34,16 @@ struct tcp_congestion_ops *tcp_ca_find(const char *name) > > return NULL; > > } > > > > +void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event) > > +{ > > + const struct inet_connection_sock *icsk = inet_csk(sk); > > + > > + trace_tcp_ca_event(sk, (u8)event); > > + > > + if (icsk->icsk_ca_ops->cwnd_event) > > + icsk->icsk_ca_ops->cwnd_event(sk, event); > > +} > > + > > void tcp_set_ca_state(struct sock *sk, const u8 ca_state) > > { > > struct inet_connection_sock *icsk = inet_csk(sk); > > For more information, this patch is not passthrough the `./scripts/checkpatch.pl` check > with the following error message `Macros with complex values should be enclosed in parentheses`. > > I have no idea because there is no complex expression and the `include/trace/events/sock.h` files > also failed in the style check. Please ignore all checkpatch.pl messages when it comes to the TRACE_EVENT() macro and pretty much anything it recommends to do with TRACE_EVENTS() in general. checkpatch.pl's recommendations on the include/trace code is just wrong, and makes it worse. One day I need to add a patch to fix checkpatch. -- Steve