Netdev List
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@google.com>
To: jiayuan.chen@linux.dev
Cc: edumazet@google.com, netdev@vger.kernel.org,
	nramaswamy@openai.com,  edumazet@kernel.org,
	ncardwell@google.com, ycheng@google.com
Subject: Re: [PATCH net 1/2] tcp: restore RACK list membership when undoing loss
Date: Thu,  1 Oct 2026 00:30:13 +0000	[thread overview]
Message-ID: <20261001003103.987619-1-kuniyu@google.com> (raw)
In-Reply-To: <43ad79b6-40e9-4704-bcd5-b67255105fae@linux.dev>

From: Jiayuan Chen <jiayuan.chen@linux.dev>
Date: Wed, 30 Sep 2026 10:13:42 +0800
> On 9/26/26 8:25 AM, 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 and can lead to
> > long retransmission delays. Restoring them to the RACK list allows them to
> > be reconsidered for fast retransmission in the future. To do this, we first
> > sort the segments whose lost flag is being cleared, and reinsert them into
> > the RACK list (which is sorted by transmission time).
> >
> > 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 | 33 +++++++++++++++++++++++++++++++++
> >   1 file changed, 33 insertions(+)
> >
> > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> > index 92bc60716f33..38ac07c8b38f 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,48 @@ 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);
> > +}
> > +
> >   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) == TCPCB_LOST)

nit: "== TCPCB_LOST" is redundant


> > +				list_move_tail(&skb->tcp_tsorted_anchor, &restored);
> 
> 
> I think the simplest way to solve the problems is just drop 
> 'list_del_init(&skb->tcp_tsorted_anchor);' in tcp_rack_detect_loss(),
> although it will reduce the efficiency of RACK loss detection ?

It will almost revert the optimisation done by 043b87d7599e.

One sort + merging sorted lists during undo seems better
than reintroducing costs in the fast(er) path.


> 
> Leave it to maintainers.
> 
> 
> >   			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);
> >   	}

  reply	other threads:[~2026-10-01  0:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-26  0:25 [PATCH net 0/2] tcp: preserve RACK tracking across partial undo nramaswamy
2026-09-26  0:25 ` [PATCH net 1/2] tcp: restore RACK list membership when undoing loss nramaswamy
2026-09-30  2:13   ` Jiayuan Chen
2026-10-01  0:30     ` Kuniyuki Iwashima [this message]
2026-10-01 23:07   ` Jakub Kicinski
2026-10-01 23:33     ` nramaswamy
2026-09-26  0:25 ` [PATCH net 2/2] selftests: net: packetdrill: test RACK after partial undo nramaswamy
2026-09-28 21:53 ` [PATCH net 0/2] tcp: preserve RACK tracking across " nramaswamy

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=20261001003103.987619-1-kuniyu@google.com \
    --to=kuniyu@google.com \
    --cc=edumazet@google.com \
    --cc=edumazet@kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=nramaswamy@openai.com \
    --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