Skip to content

Commit fb8b819

Browse files
leitaoNipaLocal
authored and
NipaLocal
committed
trace: tcp: Add tracepoint for tcp_cwnd_reduction()
Add a lightweight tracepoint to monitor TCP congestion window adjustments via tcp_cwnd_reduction(). This tracepoint enables tracking of: - TCP window size fluctuations - Active socket behavior - Congestion window reduction events Meta has been using BPF programs to monitor this function for years. Adding a proper tracepoint provides a stable API for all users who need to monitor TCP congestion window behavior. Use DECLARE_TRACE instead of TRACE_EVENT to avoid creating trace event infrastructure and exporting to tracefs, keeping the implementation minimal. (Thanks Steven Rostedt) Given that this patch creates a rawtracepoint, you could hook into it using regular tooling, like bpftrace, using regular rawtracepoint infrastructure, such as: rawtracepoint:tcp_cwnd_reduction_tp { .... } Signed-off-by: Breno Leitao <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 81a2bc4 commit fb8b819

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

include/trace/events/tcp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ TRACE_EVENT(tcp_retransmit_synack,
259259
__entry->saddr_v6, __entry->daddr_v6)
260260
);
261261

262+
DECLARE_TRACE(tcp_cwnd_reduction_tp,
263+
TP_PROTO(const struct sock *sk, int newly_acked_sacked,
264+
int newly_lost, int flag),
265+
TP_ARGS(sk, newly_acked_sacked, newly_lost, flag)
266+
);
267+
262268
#include <trace/events/net_probe_common.h>
263269

264270
TRACE_EVENT(tcp_probe,

net/ipv4/tcp_input.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,6 +2709,8 @@ void tcp_cwnd_reduction(struct sock *sk, int newly_acked_sacked, int newly_lost,
27092709
if (newly_acked_sacked <= 0 || WARN_ON_ONCE(!tp->prior_cwnd))
27102710
return;
27112711

2712+
trace_tcp_cwnd_reduction_tp(sk, newly_acked_sacked, newly_lost, flag);
2713+
27122714
tp->prr_delivered += newly_acked_sacked;
27132715
if (delta < 0) {
27142716
u64 dividend = (u64)tp->snd_ssthresh * tp->prr_delivered +

0 commit comments

Comments
 (0)