* [PATCH net-next v2] trace: tcp: Add tracepoint for tcp_cwnd_reduction()
@ 2025-02-14 17:07 Breno Leitao
2025-02-18 12:53 ` Paolo Abeni
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Breno Leitao @ 2025-02-14 17:07 UTC (permalink / raw)
To: Eric Dumazet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, David S. Miller, David Ahern, Jakub Kicinski,
Paolo Abeni, Simon Horman, Neal Cardwell
Cc: netdev, linux-kernel, linux-trace-kernel, kernel-team, Breno Leitao
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 <leitao@debian.org>
---
---
Changes in v2:
- Close the parenthesis in a new line to honor the tcp.h format (Jakub).
- Add the bpftrace example in the commit message (Jakub)
- Link to v1: https://lore.kernel.org/r/20250207-cwnd_tracepoint-v1-1-13650f3ca96d@debian.org
Changes since RFC:
- Change from a full tracepoint to DECLARE_TRACE() as suggested by
Steven
- Link to RFC: https://lore.kernel.org/r/20250120-cwnd_tracepoint-v1-1-36b0e0d643fa@debian.org
---
include/trace/events/tcp.h | 6 ++++++
net/ipv4/tcp_input.c | 2 ++
2 files changed, 8 insertions(+)
diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index a27c4b619dffd7dcc72fffa71bf0fd5e34fe6681..1a40c41ff8c30a31b5c7002a4109de1cd8ef389e 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -259,6 +259,12 @@ TRACE_EVENT(tcp_retransmit_synack,
__entry->saddr_v6, __entry->daddr_v6)
);
+DECLARE_TRACE(tcp_cwnd_reduction_tp,
+ TP_PROTO(const struct sock *sk, int newly_acked_sacked,
+ int newly_lost, int flag),
+ TP_ARGS(sk, newly_acked_sacked, newly_lost, flag)
+);
+
#include <trace/events/net_probe_common.h>
TRACE_EVENT(tcp_probe,
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 4686783b70defe0457571efd72d41ac88c528f7b..3f79718fdb1ec7a4352dc691147da527448c1f46 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -2709,6 +2709,8 @@ void tcp_cwnd_reduction(struct sock *sk, int newly_acked_sacked, int newly_lost,
if (newly_acked_sacked <= 0 || WARN_ON_ONCE(!tp->prior_cwnd))
return;
+ trace_tcp_cwnd_reduction_tp(sk, newly_acked_sacked, newly_lost, flag);
+
tp->prr_delivered += newly_acked_sacked;
if (delta < 0) {
u64 dividend = (u64)tp->snd_ssthresh * tp->prr_delivered +
---
base-commit: 7a7e0197133d18cfd9931e7d3a842d0f5730223f
change-id: 20250120-cwnd_tracepoint-2e11c996a9cb
Best regards,
--
Breno Leitao <leitao@debian.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] trace: tcp: Add tracepoint for tcp_cwnd_reduction()
2025-02-14 17:07 [PATCH net-next v2] trace: tcp: Add tracepoint for tcp_cwnd_reduction() Breno Leitao
@ 2025-02-18 12:53 ` Paolo Abeni
2025-02-18 13:33 ` Breno Leitao
2025-02-18 13:21 ` Eric Dumazet
2025-02-18 14:40 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2025-02-18 12:53 UTC (permalink / raw)
To: Breno Leitao
Cc: netdev, linux-kernel, Mathieu Desnoyers, linux-trace-kernel,
kernel-team, Jakub Kicinski, Eric Dumazet, David Ahern,
Steven Rostedt, Masami Hiramatsu, David S. Miller, Simon Horman,
Neal Cardwell
Hi,
On 2/14/25 6:07 PM, Breno Leitao wrote:
> 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 <leitao@debian.org>
> ---
> ---
> Changes in v2:
> - Close the parenthesis in a new line to honor the tcp.h format (Jakub).
> - Add the bpftrace example in the commit message (Jakub)
> - Link to v1: https://lore.kernel.org/r/20250207-cwnd_tracepoint-v1-1-13650f3ca96d@debian.org
For future similar situations, note that it's expected to carry-on the
tag already collected in the previous versions, since the delta is only
cosmetic.
No further actions required on your side.
Cheers,
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] trace: tcp: Add tracepoint for tcp_cwnd_reduction()
2025-02-14 17:07 [PATCH net-next v2] trace: tcp: Add tracepoint for tcp_cwnd_reduction() Breno Leitao
2025-02-18 12:53 ` Paolo Abeni
@ 2025-02-18 13:21 ` Eric Dumazet
2025-02-18 14:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2025-02-18 13:21 UTC (permalink / raw)
To: Breno Leitao
Cc: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
David S. Miller, David Ahern, Jakub Kicinski, Paolo Abeni,
Simon Horman, Neal Cardwell, netdev, linux-kernel,
linux-trace-kernel, kernel-team
On Fri, Feb 14, 2025 at 6:07 PM Breno Leitao <leitao@debian.org> wrote:
>
> 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 <leitao@debian.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] trace: tcp: Add tracepoint for tcp_cwnd_reduction()
2025-02-18 12:53 ` Paolo Abeni
@ 2025-02-18 13:33 ` Breno Leitao
0 siblings, 0 replies; 5+ messages in thread
From: Breno Leitao @ 2025-02-18 13:33 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, linux-kernel, Mathieu Desnoyers, linux-trace-kernel,
kernel-team, Jakub Kicinski, Eric Dumazet, David Ahern,
Steven Rostedt, Masami Hiramatsu, David S. Miller, Simon Horman,
Neal Cardwell
Hello Paolo,
On Tue, Feb 18, 2025 at 01:53:15PM +0100, Paolo Abeni wrote:
> On 2/14/25 6:07 PM, Breno Leitao wrote:
> > 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 <leitao@debian.org>
> > ---
> > ---
> > Changes in v2:
> > - Close the parenthesis in a new line to honor the tcp.h format (Jakub).
> > - Add the bpftrace example in the commit message (Jakub)
> > - Link to v1: https://lore.kernel.org/r/20250207-cwnd_tracepoint-v1-1-13650f3ca96d@debian.org
>
> For future similar situations, note that it's expected to carry-on the
> tag already collected in the previous versions, since the delta is only
> cosmetic.
That is fair. I simply forgot about it. Sorry about it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] trace: tcp: Add tracepoint for tcp_cwnd_reduction()
2025-02-14 17:07 [PATCH net-next v2] trace: tcp: Add tracepoint for tcp_cwnd_reduction() Breno Leitao
2025-02-18 12:53 ` Paolo Abeni
2025-02-18 13:21 ` Eric Dumazet
@ 2025-02-18 14:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-18 14:40 UTC (permalink / raw)
To: Breno Leitao
Cc: edumazet, rostedt, mhiramat, mathieu.desnoyers, davem, dsahern,
kuba, pabeni, horms, ncardwell, netdev, linux-kernel,
linux-trace-kernel, kernel-team
Hello:
This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Fri, 14 Feb 2025 09:07:11 -0800 you wrote:
> 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
>
> [...]
Here is the summary with links:
- [net-next,v2] trace: tcp: Add tracepoint for tcp_cwnd_reduction()
https://git.kernel.org/netdev/net-next/c/8e677a466145
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-18 14:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-14 17:07 [PATCH net-next v2] trace: tcp: Add tracepoint for tcp_cwnd_reduction() Breno Leitao
2025-02-18 12:53 ` Paolo Abeni
2025-02-18 13:33 ` Breno Leitao
2025-02-18 13:21 ` Eric Dumazet
2025-02-18 14:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®