netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tcp: Add tracepoint for tcp_set_ca_state
@ 2022-03-30 13:01 jackygam2001
  2022-03-30 13:33 ` Denis Kirjanov
  0 siblings, 1 reply; 4+ messages in thread
From: jackygam2001 @ 2022-03-30 13:01 UTC (permalink / raw)
  To: edumazet, davem, kuba, pabeni, rostedt, mingo, yoshfuji, dsahern
  Cc: netdev, linux-kernel, ping.gan, jackygam2001

The congestion status of a tcp flow may be updated since there
is congestion between tcp sender and receiver. It makes sense for
adding tracepoint for congestion status update function to evaluate
the performance of network and congestion algorithm.

Link: https://github.com/iovisor/bcc/pull/3899

Signed-off-by: jackygam2001 <jacky_gam_2001@163.com>
---
 include/net/tcp.h          | 12 +++---------
 include/trace/events/tcp.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
 net/ipv4/tcp_cong.c        | 12 ++++++++++++
 3 files changed, 60 insertions(+), 9 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 70ca4a5e330a..9a3786f33798 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1139,15 +1139,6 @@ 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_set_ca_state(struct sock *sk, const u8 ca_state)
-{
-	struct inet_connection_sock *icsk = inet_csk(sk);
-
-	if (icsk->icsk_ca_ops->set_state)
-		icsk->icsk_ca_ops->set_state(sk, ca_state);
-	icsk->icsk_ca_state = ca_state;
-}
-
 static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event)
 {
 	const struct inet_connection_sock *icsk = inet_csk(sk);
@@ -1156,6 +1147,9 @@ static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event)
 		icsk->icsk_ca_ops->cwnd_event(sk, event);
 }
 
+/* From tcp_cong.c */
+void tcp_set_ca_state(struct sock *sk, const u8 ca_state);
+
 /* From tcp_rate.c */
 void tcp_rate_skb_sent(struct sock *sk, struct sk_buff *skb);
 void tcp_rate_skb_delivered(struct sock *sk, struct sk_buff *skb,
diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 521059d8dc0a..69a68b01c1de 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -371,6 +371,51 @@ DEFINE_EVENT(tcp_event_skb, tcp_bad_csum,
 	TP_ARGS(skb)
 );
 
+TRACE_EVENT(tcp_cong_state_set,
+
+	TP_PROTO(struct sock *sk, const u8 ca_state),
+
+	TP_ARGS(sk, ca_state),
+
+	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, cong_state)
+	),
+
+	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;
+
+		TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr,
+			   sk->sk_v6_rcv_saddr, sk->sk_v6_daddr);
+
+		__entry->cong_state = ca_state;
+	),
+
+	TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c cong_state=%u",
+		  __entry->sport, __entry->dport,
+		  __entry->saddr, __entry->daddr,
+		  __entry->saddr_v6, __entry->daddr_v6,
+		  __entry->cong_state)
+);
+
 #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 dc95572163df..98b48bdb8be7 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -16,6 +16,7 @@
 #include <linux/gfp.h>
 #include <linux/jhash.h>
 #include <net/tcp.h>
+#include <trace/events/tcp.h>
 
 static DEFINE_SPINLOCK(tcp_cong_list_lock);
 static LIST_HEAD(tcp_cong_list);
@@ -33,6 +34,17 @@ struct tcp_congestion_ops *tcp_ca_find(const char *name)
 	return NULL;
 }
 
+void tcp_set_ca_state(struct sock *sk, const u8 ca_state)
+{
+	struct inet_connection_sock *icsk = inet_csk(sk);
+
+	trace_tcp_cong_state_set(sk, ca_state);
+
+	if (icsk->icsk_ca_ops->set_state)
+		icsk->icsk_ca_ops->set_state(sk, ca_state);
+	icsk->icsk_ca_state = ca_state;
+}
+
 /* Must be called with rcu lock held */
 static struct tcp_congestion_ops *tcp_ca_find_autoload(struct net *net,
 						       const char *name)
-- 
2.15.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tcp: Add tracepoint for tcp_set_ca_state
  2022-03-30 13:01 [PATCH] tcp: Add tracepoint for tcp_set_ca_state jackygam2001
@ 2022-03-30 13:33 ` Denis Kirjanov
  2022-03-31  8:21   ` [PATCH v2 net-next] " jackygam2001
  0 siblings, 1 reply; 4+ messages in thread
From: Denis Kirjanov @ 2022-03-30 13:33 UTC (permalink / raw)
  To: jackygam2001, edumazet, davem, kuba, pabeni, rostedt, mingo,
	yoshfuji, dsahern
  Cc: netdev, linux-kernel, ping.gan



3/30/22 16:01, jackygam2001 пишет:
> The congestion status of a tcp flow may be updated since there
> is congestion between tcp sender and receiver. It makes sense for
> adding tracepoint for congestion status update function to evaluate
> the performance of network and congestion algorithm.
> 
> Link: https://github.com/iovisor/bcc/pull/3899
> 
> Signed-off-by: jackygam2001 <jacky_gam_2001@163.com>
Please use net-next prefix and use your real name in SOB

> ---
>   include/net/tcp.h          | 12 +++---------
>   include/trace/events/tcp.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
>   net/ipv4/tcp_cong.c        | 12 ++++++++++++
>   3 files changed, 60 insertions(+), 9 deletions(-)
> 
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index 70ca4a5e330a..9a3786f33798 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -1139,15 +1139,6 @@ 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_set_ca_state(struct sock *sk, const u8 ca_state)
> -{
> -	struct inet_connection_sock *icsk = inet_csk(sk);
> -
> -	if (icsk->icsk_ca_ops->set_state)
> -		icsk->icsk_ca_ops->set_state(sk, ca_state);
> -	icsk->icsk_ca_state = ca_state;
> -}
> -
>   static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event)
>   {
>   	const struct inet_connection_sock *icsk = inet_csk(sk);
> @@ -1156,6 +1147,9 @@ static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event)
>   		icsk->icsk_ca_ops->cwnd_event(sk, event);
>   }
>   
> +/* From tcp_cong.c */
> +void tcp_set_ca_state(struct sock *sk, const u8 ca_state);
> +
>   /* From tcp_rate.c */
>   void tcp_rate_skb_sent(struct sock *sk, struct sk_buff *skb);
>   void tcp_rate_skb_delivered(struct sock *sk, struct sk_buff *skb,
> diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
> index 521059d8dc0a..69a68b01c1de 100644
> --- a/include/trace/events/tcp.h
> +++ b/include/trace/events/tcp.h
> @@ -371,6 +371,51 @@ DEFINE_EVENT(tcp_event_skb, tcp_bad_csum,
>   	TP_ARGS(skb)
>   );
>   
> +TRACE_EVENT(tcp_cong_state_set,
> +
> +	TP_PROTO(struct sock *sk, const u8 ca_state),
> +
> +	TP_ARGS(sk, ca_state),
> +
> +	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, cong_state)
> +	),
> +
> +	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;
> +
> +		TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr,
> +			   sk->sk_v6_rcv_saddr, sk->sk_v6_daddr);
> +
> +		__entry->cong_state = ca_state;
> +	),
> +
> +	TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c cong_state=%u",
> +		  __entry->sport, __entry->dport,
> +		  __entry->saddr, __entry->daddr,
> +		  __entry->saddr_v6, __entry->daddr_v6,
> +		  __entry->cong_state)
> +);
> +
>   #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 dc95572163df..98b48bdb8be7 100644
> --- a/net/ipv4/tcp_cong.c
> +++ b/net/ipv4/tcp_cong.c
> @@ -16,6 +16,7 @@
>   #include <linux/gfp.h>
>   #include <linux/jhash.h>
>   #include <net/tcp.h>
> +#include <trace/events/tcp.h>
>   
>   static DEFINE_SPINLOCK(tcp_cong_list_lock);
>   static LIST_HEAD(tcp_cong_list);
> @@ -33,6 +34,17 @@ struct tcp_congestion_ops *tcp_ca_find(const char *name)
>   	return NULL;
>   }
>   
> +void tcp_set_ca_state(struct sock *sk, const u8 ca_state)
> +{
> +	struct inet_connection_sock *icsk = inet_csk(sk);
> +
> +	trace_tcp_cong_state_set(sk, ca_state);
> +
> +	if (icsk->icsk_ca_ops->set_state)
> +		icsk->icsk_ca_ops->set_state(sk, ca_state);
> +	icsk->icsk_ca_state = ca_state;
> +}
> +
>   /* Must be called with rcu lock held */
>   static struct tcp_congestion_ops *tcp_ca_find_autoload(struct net *net,
>   						       const char *name)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 net-next] tcp: Add tracepoint for tcp_set_ca_state
  2022-03-30 13:33 ` Denis Kirjanov
@ 2022-03-31  8:21   ` jackygam2001
  2022-04-01  3:12     ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: jackygam2001 @ 2022-03-31  8:21 UTC (permalink / raw)
  To: dkirjanov
  Cc: edumazet, davem, kuba, pabeni, rostedt, mingo, yoshfuji, dsahern,
	netdev, linux-kernel, yhs, ping.gan, Ping Gan

From: Ping Gan <jacky_gam_2001@163.com>

The congestion status of a tcp flow may be updated since there
is congestion between tcp sender and receiver. It makes sense to
add tracepoint for congestion status set function to summate cc
status duration and evaluate the performance of network
and congestion algorithm. The backgound of this patch is below.

Link: https://github.com/iovisor/bcc/pull/3899

Signed-off-by: Ping Gan <jacky_gam_2001@163.com>
---
 include/net/tcp.h          | 12 +++---------
 include/trace/events/tcp.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
 net/ipv4/tcp_cong.c        | 12 ++++++++++++
 3 files changed, 60 insertions(+), 9 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 70ca4a5e330a..9a3786f33798 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1139,15 +1139,6 @@ 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_set_ca_state(struct sock *sk, const u8 ca_state)
-{
-	struct inet_connection_sock *icsk = inet_csk(sk);
-
-	if (icsk->icsk_ca_ops->set_state)
-		icsk->icsk_ca_ops->set_state(sk, ca_state);
-	icsk->icsk_ca_state = ca_state;
-}
-
 static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event)
 {
 	const struct inet_connection_sock *icsk = inet_csk(sk);
@@ -1156,6 +1147,9 @@ static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event)
 		icsk->icsk_ca_ops->cwnd_event(sk, event);
 }
 
+/* From tcp_cong.c */
+void tcp_set_ca_state(struct sock *sk, const u8 ca_state);
+
 /* From tcp_rate.c */
 void tcp_rate_skb_sent(struct sock *sk, struct sk_buff *skb);
 void tcp_rate_skb_delivered(struct sock *sk, struct sk_buff *skb,
diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 521059d8dc0a..69a68b01c1de 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -371,6 +371,51 @@ DEFINE_EVENT(tcp_event_skb, tcp_bad_csum,
 	TP_ARGS(skb)
 );
 
+TRACE_EVENT(tcp_cong_state_set,
+
+	TP_PROTO(struct sock *sk, const u8 ca_state),
+
+	TP_ARGS(sk, ca_state),
+
+	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, cong_state)
+	),
+
+	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;
+
+		TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr,
+			   sk->sk_v6_rcv_saddr, sk->sk_v6_daddr);
+
+		__entry->cong_state = ca_state;
+	),
+
+	TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c cong_state=%u",
+		  __entry->sport, __entry->dport,
+		  __entry->saddr, __entry->daddr,
+		  __entry->saddr_v6, __entry->daddr_v6,
+		  __entry->cong_state)
+);
+
 #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 dc95572163df..98b48bdb8be7 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -16,6 +16,7 @@
 #include <linux/gfp.h>
 #include <linux/jhash.h>
 #include <net/tcp.h>
+#include <trace/events/tcp.h>
 
 static DEFINE_SPINLOCK(tcp_cong_list_lock);
 static LIST_HEAD(tcp_cong_list);
@@ -33,6 +34,17 @@ struct tcp_congestion_ops *tcp_ca_find(const char *name)
 	return NULL;
 }
 
+void tcp_set_ca_state(struct sock *sk, const u8 ca_state)
+{
+	struct inet_connection_sock *icsk = inet_csk(sk);
+
+	trace_tcp_cong_state_set(sk, ca_state);
+
+	if (icsk->icsk_ca_ops->set_state)
+		icsk->icsk_ca_ops->set_state(sk, ca_state);
+	icsk->icsk_ca_state = ca_state;
+}
+
 /* Must be called with rcu lock held */
 static struct tcp_congestion_ops *tcp_ca_find_autoload(struct net *net,
 						       const char *name)
-- 
2.15.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 net-next] tcp: Add tracepoint for tcp_set_ca_state
  2022-03-31  8:21   ` [PATCH v2 net-next] " jackygam2001
@ 2022-04-01  3:12     ` Jakub Kicinski
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2022-04-01  3:12 UTC (permalink / raw)
  To: jackygam2001
  Cc: dkirjanov, edumazet, davem, pabeni, rostedt, mingo, yoshfuji,
	dsahern, netdev, linux-kernel, yhs, ping.gan

On Thu, 31 Mar 2022 16:21:49 +0800 jackygam2001 wrote:
> From: Ping Gan <jacky_gam_2001@163.com>
> 
> The congestion status of a tcp flow may be updated since there
> is congestion between tcp sender and receiver. It makes sense to
> add tracepoint for congestion status set function to summate cc
> status duration and evaluate the performance of network
> and congestion algorithm. The backgound of this patch is below.
> 
> Link: https://github.com/iovisor/bcc/pull/3899
> 
> Signed-off-by: Ping Gan <jacky_gam_2001@163.com>

# Form letter - net-next is closed

We have already sent the networking pull request for 5.18
and therefore net-next is closed for new drivers, features,
code refactoring and optimizations. We are currently accepting
bug fixes only.

Please repost when net-next reopens after 5.18-rc1 is cut.

RFC patches sent for review only are obviously welcome at any time.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-01  3:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-30 13:01 [PATCH] tcp: Add tracepoint for tcp_set_ca_state jackygam2001
2022-03-30 13:33 ` Denis Kirjanov
2022-03-31  8:21   ` [PATCH v2 net-next] " jackygam2001
2022-04-01  3:12     ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).