Skip to contentSkip to conversation

tcp: add tracepoint for tcp_write_err()

PATCH In review Philo Lu 2 participants 3 messages Apr 25, 2024 – Apr 30, 2024

Subsystems (4)
lore
Share & tools
lore

Philo Lu

author
#0 lore raw

PATCH 1/1 tcp: add tracepoint for tcp_write_err()

This tracepoint can be used to trace tcp write error events, e.g., retransmit timeout. Though there is a tracepoint in sk_error_report(), the value of sk->sk_err depends on sk->sk_err_soft, and we cannot easily recognized errors from tcp_write_err().

---
 include/trace/events/tcp.h | 7 +++++++
 net/ipv4/tcp_timer.c       | 3 +++
 2 files changed, 10 insertions(+)
include/trace/events/tcp.h +7 -0
index 5c04a61a11c2c..0efb51dcb8a3f 100644
@@ -195,6 +195,13 @@ DEFINE_EVENT(tcp_event_sk, tcp_rcv_space_adjust,
 	TP_ARGS(sk)
 );
 
+DEFINE_EVENT(tcp_event_sk, tcp_write_err,
+
+	TP_PROTO(struct sock *sk),
+
+	TP_ARGS(sk)
+);
+
 TRACE_EVENT(tcp_retransmit_synack,
 
 	TP_PROTO(const struct sock *sk, const struct request_sock *req),
net/ipv4/tcp_timer.c +3 -0
index 976db57b95d40..ebba7e30d5534 100644
@@ -19,6 +19,7 @@
  *		Jorge Cwik, <[email protected]>
  */
 
+#include <trace/events/tcp.h>
 #include <linux/module.h>
 #include <linux/gfp.h>
 #include <net/tcp.h>
@@ -73,6 +74,8 @@ u32 tcp_clamp_probe0_to_user_timeout(const struct sock *sk, u32 when)
 
 static void tcp_write_err(struct sock *sk)
 {
+	trace_tcp_write_err(sk);
+
 	WRITE_ONCE(sk->sk_err, READ_ONCE(sk->sk_err_soft) ? : ETIMEDOUT);
 	sk_error_report(sk);
 
Signature · 1 line
2.32.0.3.g01195cf9f
maintainer
#1 lore raw
Quoted 4 lines · Philo Lu

This tracepoint can be used to trace tcp write error events, e.g., retransmit timeout. Though there is a tracepoint in sk_error_report(), the value of sk->sk_err depends on sk->sk_err_soft, and we cannot easily recognized errors from tcp_write_err().

Why not? you can look at the dumped sock protocol and ev. capture the sk_error_report tracepoint call-trace.

IMHO this provides little value and is not worthy.

Cheers,

Paolo

author
#2 lore raw
Quoted 9 lines · Paolo Abeni
Quoted 4 lines · Philo Lu

This tracepoint can be used to trace tcp write error events, e.g., retransmit timeout. Though there is a tracepoint in sk_error_report(), the value of sk->sk_err depends on sk->sk_err_soft, and we cannot easily recognized errors from tcp_write_err().

Why not? you can look at the dumped sock protocol and ev. capture the sk_error_report tracepoint call-trace.

Thanks for your suggestion, Paolo. I'll try to trace sk_error_report with its calling stack and see if this could solve my problem.

Though tcp_write_err() seems to be inlined in my system, upper callers may provides useful infomation. Let me have a try;)

Thanks.

Quoted 5 lines

IMHO this provides little value and is not worthy.

Cheers,

Paolo