From: Eric Dumazet <edumazet@kernel.org>
To: nramaswamy@openai.com, netdev@vger.kernel.org
Cc: Neal Cardwell <ncardwell@google.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
Yuchung Cheng <ycheng@google.com>,
Jiayuan Chen <jiayuan.chen@linux.dev>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net v2 1/2] tcp: restore RACK list membership when undoing loss
Date: Tue, 6 Oct 2026 08:42:44 +0200 [thread overview]
Message-ID: <627cd81c-9824-4d1b-ae47-f7f929a96596@kernel.org> (raw)
In-Reply-To: <f366f5325d7eb96f0edd999b4f984213743914b8.1791248202.git.nramaswamy@openai.com>
On 10/6/26 07:15, nramaswamy@openai.com wrote:
> From: Neil Ramaswamy <nramaswamy@openai.com>
>
> Partial undo can clear the TCPCB_LOST flag on segments already removed
> from RACK's list, which prevents subsequent RACK loss detection, leading
> to segments only being retransmitted after the RTO. Restoring them to
> the RACK list as part of partial undo makes sure we can properly
> reconsider them for fast retransmission in the future.
>
> To do this, we first sort (by transmission time) the segments whose
> TCPCB_LOST flag is being cleared and then linearly insert those back
> into the RACK list, which is sorted by transmission time.
>
> My investigation started from seeing repeated TCP stalls in prod and the
> mitigation that seemed to prevent these stalls was limiting SO_SNDBUF to
> 96 KiB. It also seems like others have seen similar symptoms before [1].
>
> [1]
> https://lore.kernel.org/netdev/35A4DDAA-7E8D-43CB-A1F5-D1E46A4ED42E@gmail.com/
>
> Fixes: 043b87d7599e ("tcp: more efficient RACK loss detection")
> Signed-off-by: Neil Ramaswamy <nramaswamy@openai.com>
> Assisted-by: LLM sparse
> ---
> net/ipv4/tcp_input.c | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 92bc60716f33..51f04c7474dc 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -69,6 +69,7 @@
> #include <linux/module.h>
> #include <linux/sysctl.h>
> #include <linux/kernel.h>
> +#include <linux/list_sort.h>
> #include <linux/prefetch.h>
> #include <linux/bitops.h>
> #include <net/dst.h>
> @@ -2840,16 +2841,50 @@ static void DBGUNDO(struct sock *sk, const char *msg)
> #endif
> }
>
> +static int tcp_rack_skb_cmp(void *priv, const struct list_head *a,
> + const struct list_head *b)
> +{
> + const struct sk_buff *skb_a = list_entry(a, struct sk_buff,
> + tcp_tsorted_anchor);
> + const struct sk_buff *skb_b = list_entry(b, struct sk_buff,
> + tcp_tsorted_anchor);
> +
> + return tcp_skb_sent_after(tcp_skb_timestamp_us(skb_a),
> + tcp_skb_timestamp_us(skb_b),
> + TCP_SKB_CB(skb_a)->end_seq,
> + TCP_SKB_CB(skb_b)->end_seq);
Patch LGTM, but perhaps we could avoid the two div_u64() calls here.
return tcp_skb_sent_after(skb_a->skb_mstamp_ns,
skb_b->skb_mstamp_ns,
TCP_SKB_CB(skb_a)->end_seq,
TCP_SKB_CB(skb_b)->end_seq);
> +}
> +
> static void tcp_undo_cwnd_reduction(struct sock *sk, bool unmark_loss)
> {
> struct tcp_sock *tp = tcp_sk(sk);
>
> if (unmark_loss) {
> + LIST_HEAD(restored);
> struct sk_buff *skb;
>
> skb_rbtree_walk(skb, &sk->tcp_rtx_queue) {
> + if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST)
> + list_move_tail(&skb->tcp_tsorted_anchor,
> + &restored);
> TCP_SKB_CB(skb)->sacked &= ~TCPCB_LOST;
> }
> + if (!list_empty(&restored)) {
> + struct list_head *pos = &tp->tsorted_sent_queue;
> +
> + /* Ensure lost skbs are added in transmission order */
> + list_sort(NULL, &restored, tcp_rack_skb_cmp);
> + while (!list_empty(&restored)) {
> + struct list_head *entry = restored.next;
> +
> + while (pos->next != &tp->tsorted_sent_queue &&
> + !tcp_rack_skb_cmp(NULL, pos->next,
> + entry))
> + pos = pos->next;
> + list_move(entry, pos);
> + pos = entry;
> + }
> + }
> tp->lost_out = 0;
> tcp_clear_all_retrans_hints(tp);
> }
next prev parent reply other threads:[~2026-10-06 6:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 5:15 [PATCH net v2 0/2] tcp: preserve RACK tracking across partial undo nramaswamy
2026-10-06 5:15 ` [PATCH net v2 1/2] tcp: restore RACK list membership when undoing loss nramaswamy
2026-10-06 6:42 ` Eric Dumazet [this message]
2026-10-06 5:15 ` [PATCH net v2 2/2] selftests: net: packetdrill: test RACK after partial undo nramaswamy
2026-10-06 7:04 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=627cd81c-9824-4d1b-ae47-f7f929a96596@kernel.org \
--to=edumazet@kernel.org \
--cc=davem@davemloft.net \
--cc=horms@kernel.org \
--cc=jiayuan.chen@linux.dev \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=nramaswamy@openai.com \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=ycheng@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®