Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Zhiqi Zhang
Sat, 14 Nov 2026 14:13
[PATCH net] tcp: roccet: do not restart from idle on RTO retransmission
Author: Zhiqi Zhang
Date: Sat, 14 Nov 2026 14:13
Date: Sat, 14 Nov 2026 14:13
71 lines
13624 bytes
13624 bytes
roccet sets .cong_control, so tcp_slow_start_after_idle_check() returns
early and roccet implements the idle restart in cwnd_event_tx_start().
An RTO retransmission also raises CA_EVENT_TX_START. tcp_enter_loss()
marks the outstanding packets lost, which drains the in-flight count
while packets_out stays non-zero, and the RTO timer expires at least
icsk_rto after the last send. The idle restart then overwrites the
snd_ssthresh that roccet_state(TCP_CA_Loss) just set:
tcp_enter_loss()
roccet_recalc_ssthresh() ssthresh = 0.7 * cwnd
roccet_state(TCP_CA_Loss) cwnd = TCP_INIT_CWND,
ssthresh = max(ssthresh, cwnd)
tcp_retransmit_skb()
tcp_event_data_sent() CA_EVENT_TX_START
roccet_cwnd_event_tx_start() ssthresh = cwnd = TCP_INIT_CWND,
state = LAUNCH
The flow loses the reduced ssthresh and cannot slow start back to the
pre-loss window; CUBIC growth restarts from TCP_INIT_CWND with
last_max_cwnd reset. Skip the idle restart while packets are
outstanding, matching tcp_slow_start_after_idle_check().
Measured with a loopback sender and 100% netem loss after cwnd reached
about 126, reading TCP_INFO on the sender:
before fix: ssthresh during RTO = 10 (TCP_INIT_CWND)
after fix: ssthresh during RTO = 88 (0.7 * cwnd preserved)
The same issue was raised in the Sashiko review of the initial series.
Fixes: 819d59638796 ("tcp: Add TCP ROCCET congestion control module.")
Link: https://lore.kernel.org/all/179179785248.434549.16829837649351382748@kernel.org/
Signed-off-by: Zhiqi Zhang <zhiqizhangg@gmail.com>
---
AI assistance:
- DeepSeek (deepseek-flash) generated the code change.
- I wrote the tests and reviewed the code.
- I wrote the documentation and the changelog, and used DeepSeek to
polish the wording.
net/ipv4/tcp_roccet.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/tcp_roccet.c b/net/ipv4/tcp_roccet.c
index 04b9e5246..4b4621a79 100644
--- a/net/ipv4/tcp_roccet.c
+++ b/net/ipv4/tcp_roccet.c
@@ -1144,8 +1144,15 @@ static void roccet_cwnd_event_tx_start(struct sock *sk)
ca->epoch_start = now;
}
- /* After idle periods, go into LAUNCH with slow start */
- if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_slow_start_after_idle) &&
+ /*
+ * Skip the idle restart when packets are outstanding. An RTO
+ * retransmission also raises CA_EVENT_TX_START: loss marking drains
+ * the in-flight count while packets_out stays non-zero. Restarting
+ * there overwrites the snd_ssthresh preserved by roccet_state().
+ * Cf. tcp_slow_start_after_idle_check().
+ */
+ if (!tp->packets_out &&
+ READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_slow_start_after_idle) &&
delta >= inet_csk(sk)->icsk_rto) {
tp->snd_ssthresh = tcp_snd_cwnd(tp);
tcp_snd_cwnd_set(tp, min(TCP_INIT_CWND, tp->snd_cwnd_clamp));
--
2.54.0 (Apple Git-157)
Re: [PATCH net] tcp: roccet: do not restart from idle on RTO retransmission
Author: Eric Dumazet
Date: Sat, 14 Nov 2026 14:59
Date: Sat, 14 Nov 2026 14:59
211 lines
17033 bytes
17033 bytes
Le sam. 14 nov. 2026 ร 15:13, Zhiqi Zhang <zhiqizhangg@gmail.com> a รฉcrit :
>
> roccet sets .cong_control, so tcp_slow_start_after_idle_check() returns
> early and roccet implements the idle restart in cwnd_event_tx_start().
>
> An RTO retransmission also raises CA_EVENT_TX_START. tcp_enter_loss()
> marks the outstanding packets lost, which drains the in-flight count
> while packets_out stays non-zero, and the RTO timer expires at least
> icsk_rto after the last send.
This is true when a TLP probe was sent: the RTO timer is rearmed for
a full icsk_rto at that point, and the probe is the last transmit.
So the first RTO is affected.
Without TLP, the first RTO can escape: the timer is armed when the
first packet of the flight is sent, and pacing spreads the following
ones, so (now - tp->lsndtime) < icsk_rto. The second RTO is always
affected, since it fires one backed-off icsk_rto after the first
RTO retransmit.
Please make the changelog a bit more precise about this.
> The idle restart then overwrites the
> snd_ssthresh that roccet_state(TCP_CA_Loss) just set:
>
> tcp_enter_loss()
> roccet_recalc_ssthresh() ssthresh = 0.7 * cwnd
> roccet_state(TCP_CA_Loss) cwnd = TCP_INIT_CWND,
> ssthresh = max(ssthresh, cwnd)
> tcp_retransmit_skb()
> tcp_event_data_sent() CA_EVENT_TX_START
> roccet_cwnd_event_tx_start() ssthresh = cwnd = TCP_INIT_CWND,
> state = LAUNCH
>
> The flow loses the reduced ssthresh and cannot slow start back to the
> pre-loss window; CUBIC growth restarts from TCP_INIT_CWND with
> last_max_cwnd reset.
roccet_state(TCP_CA_Loss) calls roccet_reset(), which clears the whole
private state. LAUNCH being 0, ca->state is already LAUNCH and
last_max_cwnd is already 0 before roccet_cwnd_event_tx_start() runs,
with or without your patch.
The only thing the idle restart breaks here is tp->snd_ssthresh.
Please limit the changelog to that.
> Skip the idle restart while packets are
> outstanding, matching tcp_slow_start_after_idle_check().
>
> Measured with a loopback sender and 100% netem loss after cwnd reached
> about 126, reading TCP_INFO on the sender:
>
> before fix: ssthresh during RTO = 10 (TCP_INIT_CWND)
> after fix: ssthresh during RTO = 88 (0.7 * cwnd preserved)
>
A packetdrill test is much better for this kind of issue.
I wrote the following one, it fails at the first RTO without your
patch (ssthresh == 10) and passes with it. Feel free to include it
in V2, as a second patch.
A variant with /proc/sys/net/ipv4/tcp_early_retrans=0 (no TLP, so
one less retransmit, first RTO checked at +.45) fails at the
second RTO only, and also passes with your patch.
CONFIG_TCP_CONG_ROCCET=y needs to be added to
tools/testing/selftests/net/packetdrill/config
// SPDX-License-Identifier: GPL-2.0
// Test that ROCCET does not take its "restart after idle" path on RTO.
//
// An RTO retransmit raises CA_EVENT_TX_START, because all outstanding
// packets were just marked lost (tcp_packets_in_flight() == 0) while
// tp->packets_out is not zero. If (now - tp->lsndtime) >= icsk_rto,
// roccet_cwnd_event_tx_start() used to overwrite the snd_ssthresh
// that tcp_enter_loss() had just set with TCP_INIT_CWND.
//
// TLP is enabled here. The RTO timer is rearmed for a full icsk_rto when
// the loss probe is sent, and the probe is the last transmit, so the
// very first RTO is affected.
`./defaults.sh
./set_sysctls.py /proc/sys/net/ipv4/tcp_slow_start_after_idle=1`
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0 setsockopt(3, SOL_TCP, TCP_CONGESTION, "roccet", 6) = 0
+0 bind(3, ..., ...) = 0
+0 listen(3, 1) = 0
+0 < S 0:0(0) win 65535 <mss 1000,sackOK,nop,nop,nop,wscale 7>
+0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+.1 < . 1:1(0) ack 1 win 511
+0 accept(3, ..., ...) = 4
// ROCCET paces its packets: do not expect precise outgoing packets,
// rely on TCP_INFO instead.
+0 write(4, ..., 10000) = 10000
+.1 < . 1:1(0) ack 10001 win 511
+0 %{ assert tcpi_snd_cwnd == 20, tcpi_snd_cwnd }%
// RTT is 100ms, RTO is ~300ms. Nothing is acked from now on.
+0 write(4, ..., 20000) = 20000
// TLP fires ~250ms after the write.
+.4 %{
assert tcpi_ca_state == TCP_CA_Open, tcpi_ca_state
assert tcpi_total_retrans == 1, tcpi_total_retrans
}%
// First RTO, ~300ms after the TLP probe.
// ROCCET is still in LAUNCH state: ssthresh is set to the prior cwnd.
+.3 %{
assert tcpi_ca_state == TCP_CA_Loss, tcpi_ca_state
assert tcpi_backoff == 1, tcpi_backoff
assert tcpi_total_retrans == 2, tcpi_total_retrans
assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd
assert tcpi_snd_ssthresh == 20, tcpi_snd_ssthresh
}%
// Second RTO, ~600ms after the first one.
+.6 %{
assert tcpi_ca_state == TCP_CA_Loss, tcpi_ca_state
assert tcpi_backoff == 2, tcpi_backoff
assert tcpi_total_retrans == 3, tcpi_total_retrans
assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd
assert tcpi_snd_ssthresh == 20, tcpi_snd_ssthresh
}%
// Reset sysctls
`/tmp/sysctl_restore_${PPID}.sh`
> The same issue was raised in the Sashiko review of the initial series.
>
> Fixes: 819d59638796 ("tcp: Add TCP ROCCET congestion control module.")
> Link: https://lore.kernel.org/all/179179785248.434549.16829837649351382748@kernel.org/
> Signed-off-by: Zhiqi Zhang <zhiqizhangg@gmail.com>
> ---
>
> AI assistance:
>
> - DeepSeek (deepseek-flash) generated the code change.
> - I wrote the tests and reviewed the code.
> - I wrote the documentation and the changelog, and used DeepSeek to
> polish the wording.
>
> net/ipv4/tcp_roccet.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/tcp_roccet.c b/net/ipv4/tcp_roccet.c
> index 04b9e5246..4b4621a79 100644
> --- a/net/ipv4/tcp_roccet.c
> +++ b/net/ipv4/tcp_roccet.c
> @@ -1144,8 +1144,15 @@ static void roccet_cwnd_event_tx_start(struct sock *sk)
> ca->epoch_start = now;
> }
>
> - /* After idle periods, go into LAUNCH with slow start */
> - if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_slow_start_after_idle) &&
> + /*
> + * Skip the idle restart when packets are outstanding. An RTO
> + * retransmission also raises CA_EVENT_TX_START: loss marking drains
> + * the in-flight count while packets_out stays non-zero. Restarting
> + * there overwrites the snd_ssthresh preserved by roccet_state().
> + * Cf. tcp_slow_start_after_idle_check().
> + */
> + if (!tp->packets_out &&
> + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_slow_start_after_idle) &&
> delta >= inet_csk(sk)->icsk_rto) {
The code change looks correct to me: tcp_event_data_sent() is called
before tp->packets_out is updated for new data, so a real restart
after idle is still detected.
Please keep the comment style used in this file, and make it shorter,
the details belong to the changelog. Something like:
/* After idle periods, go into LAUNCH with slow start.
* We are not idle if packets are outstanding (e.g. RTO retransmit),
* see tcp_slow_start_after_idle_check().
*/
Please send a V2 (in at least 24 hours) with [PATCH net] in the subject.
Unrelated to this patch, a question for ROCCET authors:
On a repeated RTO, tcp_enter_loss() sets cwnd to 1, then
roccet_state(TCP_CA_Loss) sets it back to TCP_INIT_CWND.
This means a burst of 10 packets after each timeout, including
the backed-off ones.
This is a more serious issue IMO.
Thanks.
> tp->snd_ssthresh = tcp_snd_cwnd(tp);
> tcp_snd_cwnd_set(tp, min(TCP_INIT_CWND, tp->snd_cwnd_clamp));
> --
> 2.54.0 (Apple Git-157)
>
Re: Re: [PATCH net] tcp: roccet: do not restart from idle on RTO retransmission
Author: Lukas Prause
Date: Mon, 16 Nov 2026 12:42
Date: Mon, 16 Nov 2026 12:42
17 lines
9533 bytes
9533 bytes
> Unrelated to this patch, a question for ROCCET authors: > > On a repeated RTO, tcp_enter_loss() sets cwnd to 1, then > roccet_state(TCP_CA_Loss) sets it back to TCP_INIT_CWND. > This means a burst of 10 packets after each timeout, including > the backed-off ones. > > This is a more serious issue IMO. > > Thanks. > >> tp->snd_ssthresh = tcp_snd_cwnd(tp); >> tcp_snd_cwnd_set(tp, min(TCP_INIT_CWND, tp->snd_cwnd_clamp)); Thanks for pointing this out. We will investigate this issue and provide a patch for ROCCET soon.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads