diff mbox series

[net-next] tcp: add tracepoint for tcp_write_err()

Message ID 20240425162556.83456-1-lulie@linux.alibaba.com (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series [net-next] tcp: add tracepoint for tcp_write_err() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 950 this patch: 950
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: linux-trace-kernel@vger.kernel.org
netdev/build_clang success Errors and warnings before: 940 this patch: 940
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 961 this patch: 961
netdev/checkpatch warning CHECK: Alignment should match open parenthesis
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 3 this patch: 3
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-29--15-00 (tests: 994)

Commit Message

Philo Lu April 25, 2024, 4:25 p.m. UTC
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().

Signed-off-by: Philo Lu <lulie@linux.alibaba.com>
---
 include/trace/events/tcp.h | 7 +++++++
 net/ipv4/tcp_timer.c       | 3 +++
 2 files changed, 10 insertions(+)

Comments

Paolo Abeni April 30, 2024, 8:27 a.m. UTC | #1
On Fri, 2024-04-26 at 00:25 +0800, Philo Lu wrote:
> 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
Philo Lu April 30, 2024, 9:04 a.m. UTC | #2
On 2024/4/30 16:27, Paolo Abeni wrote:
> On Fri, 2024-04-26 at 00:25 +0800, Philo Lu wrote:
>> 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.

> IMHO this provides little value and is not worthy.
> 
> Cheers,
> 
> Paolo
diff mbox series

Patch

diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 5c04a61a11c2c..0efb51dcb8a3f 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -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),
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 976db57b95d40..ebba7e30d5534 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -19,6 +19,7 @@ 
  *		Jorge Cwik, <jorge@laser.satlink.net>
  */
 
+#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);