* [PATCH net-next] net/tcp: Add explicit tracepoint for tcp_syn_ack_timeout()
@ 2026-07-07 1:01 Emil Tsalapatis
2026-07-07 7:52 ` Eric Dumazet
0 siblings, 1 reply; 2+ messages in thread
From: Emil Tsalapatis @ 2026-07-07 1:01 UTC (permalink / raw)
To: netdev, linux-trace-kernel
Cc: edumazet, ncardwell, kuniyu, rostedt, mhiramat, davem, kuba,
pabeni, Emil Tsalapatis
Clang can inline the tcp_syn_ack_timeout() function during compilation,
making it impossible to use kprobes for tracing without preventing
inlining. Add an explicit tracepoint to it instead.
Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
---
include/trace/events/tcp.h | 72 ++++++++++++++++++++++++++++++++++++++
net/ipv4/tcp_timer.c | 3 ++
2 files changed, 75 insertions(+)
diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index f155f95cdb6e..37ffaa50faad 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -332,6 +332,78 @@ TRACE_EVENT(tcp_retransmit_synack,
__entry->saddr_v6, __entry->daddr_v6)
);
+TRACE_EVENT(tcp_syn_ack_timeout,
+
+ TP_PROTO(const struct request_sock *req),
+
+ TP_ARGS(req),
+
+ TP_STRUCT__entry(
+ __field(const void *, req)
+ __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, state)
+ __field(u8, num_timeout)
+ __field(bool, acked)
+ ),
+
+
+ TP_fast_assign(
+ const struct inet_request_sock *ireq = inet_rsk(req);
+ __be32 *p32;
+
+ __entry->req = req;
+
+ __entry->sport = ireq->ir_num;
+ __entry->dport = ntohs(ireq->ir_rmt_port);
+ __entry->family = req->__req_common.skc_family;
+
+ p32 = (__be32 *) __entry->saddr;
+ *p32 = ireq->ir_loc_addr;
+
+ p32 = (__be32 *) __entry->daddr;
+ *p32 = ireq->ir_rmt_addr;
+
+#if IS_ENABLED(CONFIG_IPV6)
+ /*
+ * Cannot use TP_STORE_ADDRS directly because it assumes
+ * there is an sk available.
+ */
+ if (__entry->family == AF_INET6) {
+ struct in6_addr *pin6;
+
+ pin6 = (struct in6_addr *)__entry->saddr_v6;
+ *pin6 = ireq->ir_v6_loc_addr;
+ pin6 = (struct in6_addr *)__entry->daddr_v6;
+ *pin6 = ireq->ir_v6_rmt_addr;
+ } else {
+ TP_STORE_V4MAPPED(__entry, ireq->ir_loc_addr, ireq->ir_rmt_addr);
+ }
+#else
+ TP_STORE_V4MAPPED(__entry, ireq->ir_loc_addr, ireq->ir_rmt_addr);
+#endif
+
+ __entry->state = ireq->ireq_state;
+ __entry->num_timeout = req->num_timeout;
+ __entry->acked = ireq->acked;
+ ),
+
+ TP_printk("family=%s sport=%hu dport=%hu saddr=%pI4 "
+ "daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c "
+ "ireq_state=%s num_timeout=%u acked=%d",
+ show_family_name(__entry->family),
+ __entry->sport, __entry->dport,
+ __entry->saddr, __entry->daddr,
+ __entry->saddr_v6, __entry->daddr_v6,
+ show_tcp_state_name(__entry->state),
+ __entry->num_timeout, __entry->acked)
+);
+
TRACE_EVENT(tcp_sendmsg_locked,
TP_PROTO(const struct sock *sk, const struct msghdr *msg,
const struct sk_buff *skb, int size_goal),
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index bf171b5e1eb3..8f482a6b43e3 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -24,6 +24,7 @@
#include <net/tcp.h>
#include <net/tcp_ecn.h>
#include <net/rstreason.h>
+#include <trace/events/tcp.h>
static u32 tcp_clamp_rto_to_user_timeout(const struct sock *sk)
{
@@ -753,6 +754,8 @@ void tcp_syn_ack_timeout(const struct request_sock *req)
struct net *net = read_pnet(&inet_rsk(req)->ireq_net);
__NET_INC_STATS(net, LINUX_MIB_TCPTIMEOUTS);
+
+ trace_tcp_syn_ack_timeout(req);
}
void tcp_reset_keepalive_timer(struct sock *sk, unsigned long len)
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next] net/tcp: Add explicit tracepoint for tcp_syn_ack_timeout()
2026-07-07 1:01 [PATCH net-next] net/tcp: Add explicit tracepoint for tcp_syn_ack_timeout() Emil Tsalapatis
@ 2026-07-07 7:52 ` Eric Dumazet
0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2026-07-07 7:52 UTC (permalink / raw)
To: Emil Tsalapatis
Cc: netdev, linux-trace-kernel, ncardwell, kuniyu, rostedt, mhiramat,
davem, kuba, pabeni
On Mon, Jul 6, 2026 at 6:01 PM Emil Tsalapatis <emil@etsalapatis.com> wrote:
>
> Clang can inline the tcp_syn_ack_timeout() function during compilation,
> making it impossible to use kprobes for tracing without preventing
> inlining. Add an explicit tracepoint to it instead.
So much copy/pasting for a very small issue :/
>
> Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
> ---
> include/trace/events/tcp.h | 72 ++++++++++++++++++++++++++++++++++++++
> net/ipv4/tcp_timer.c | 3 ++
> 2 files changed, 75 insertions(+)
>
tcp_syn_ack_timeout() is hardly a fast path, so you can instead:
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 322db13333c7..ab2c3de19e46 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -748,7 +748,7 @@ static void tcp_write_timer(struct timer_list *t)
sock_put(sk);
}
-void tcp_syn_ack_timeout(const struct request_sock *req)
+noinline_for_tracing void tcp_syn_ack_timeout(const struct request_sock *req)
{
struct net *net = read_pnet(&inet_rsk(req)->ireq_net);
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-07 7:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 1:01 [PATCH net-next] net/tcp: Add explicit tracepoint for tcp_syn_ack_timeout() Emil Tsalapatis
2026-07-07 7:52 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox