Netdev List
 help / color / mirror / Atom feed
From: Lin Lei <llleigoing@gmail.com>
To: Matthieu Baerts <matttbe@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@kernel.org>
Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev,
	netdev-bot+sashiko@kernel.org, ncardwell@google.com,
	kuniyu@google.com, davem@davemloft.net, kuba@kernel.org,
	horms@kernel.org, martineau@kernel.org, geliang@kernel.org,
	llleigoing@outlook.com
Subject: Re: [PATCH net 2/3] net: bound receive window predictions before narrowing
Date: Sun, 29 Nov 2026 06:37:54 +0000	[thread overview]
Message-ID: <20261129063755.1972521-1-llleigoing@gmail.com> (raw)
In-Reply-To: <179516297347.3136.13553293180683672285@kernel.org>

Hi Matthieu, Paolo, Eric,

Following up on the MPTCP subflow issue Sashiko flagged on patch 2/3:

On Fri, 20 Nov 2026 08:22:53 +0000, netdev-bot+sashiko@kernel.org wrote:
> Can this clamp turn an underflowed prediction into a fully saturated
> subflow receive buffer?
[...]
> Before this patch, the u32 truncation gave an arbitrary result. With
> newval == oldval / 2 the sum was exactly 2^33, so nothing changed.
[...]
> The subtraction was already there before this patch. Would it make sense
> to skip the slow-start growth when newval <= oldval?

Yes, this heterogeneous-subflow case (e.g. an MTU 1500 initial subflow
and an MTU 9000 MP_JOIN subflow, with @copied landing between their
rcvq_space.space values) can indeed happen: (newval - oldval)
underflows and produces a bogus slow-start prediction.

Cases like newval == oldval / 2 leaving sk_rcvbuf unchanged before v1
only happened by coincidence because 2^33 wrapped to 0 in u32 (in a
local test of this MTU 1500 + 9000 setup on unpatched 7.4.0-rc2, a
30 KB read already sends the join subflow's sk_rcvbuf straight to
tcp_rmem[2] and moves its rcvq_space.space backwards). Relying on
32-bit wraparound is not valid behavior; avoiding bogus growth here
should be handled explicitly by the algorithm.

If this seems worth addressing, I see two main options:

1) Option 1: Skip slow-start growth when newval <= oldval in
   tcp_rcvbuf_grow(), as Sashiko suggested.

   This avoids the underflow without affecting tcp_data_queue_ofo()
   (which passes newval == oldval), but pure TCP callers already
   guarantee newval >= oldval, and tp->rcvq_space.space = newval at the
   top of tcp_rcvbuf_grow() would still move the larger-MTU subflow's
   space estimate backwards.

2) Option 2: Keep tcp_rcvbuf_grow() unchanged and clamp the sample to
   at least the subflow's existing rcvq_space.space in MPTCP:

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2321,12 +2321,14 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied)
 		mptcp_for_each_subflow(msk, subflow) {
 			struct sock *ssk;
 			bool slow;
+			int space;
 
 			ssk = mptcp_subflow_tcp_sock(subflow);
 			slow = lock_sock_fast(ssk);
+			space = tcp_sk(ssk)->rcvq_space.space;
 			/* subflows can be added before tcp_init_transfer() */
-			if (tcp_sk(ssk)->rcvq_space.space)
-				tcp_rcvbuf_grow(ssk, copied);
+			if (space)
+				tcp_rcvbuf_grow(ssk, max(copied, space));
 			unlock_sock_fast(ssk, slow);
 		}
 	}

   Personally, Option 2 seems cleaner to me: it fixes the issue at the
   only caller that can pass a smaller sample, preserves the subflow's
   existing space estimate, zeros the slow-start delta when
   copied < space, and still lets TCP account for its own OOO queue
   (per commit 6b329393502e) and low_rtt policy.

What do you think? If this looks reasonable to you, I plan to submit a
standalone patch.

Thanks,
Lin

  reply	other threads:[~2026-11-29  6:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  5:22 [PATCH net 0/3] tcp, mptcp: fix receive buffer sizing and peek accounting lei lei
2026-11-17  5:22 ` [PATCH net 1/3] tcp: saturate window-to-memory conversions at INT_MAX lei lei
2026-11-19  7:54   ` Eric Dumazet
2026-11-20  8:22   ` netdev-bot+sashiko
2026-11-17  5:22 ` [PATCH net 2/3] net: bound receive window predictions before narrowing lei lei
2026-11-19  7:56   ` Eric Dumazet
2026-11-27 15:04     ` Lin Lei
2026-11-20  8:22   ` netdev-bot+sashiko
2026-11-29  6:37     ` Lin Lei [this message]
2026-11-29  7:50       ` Matthieu Baerts
2026-11-17  5:22 ` [PATCH net 3/3] mptcp: exclude MSG_PEEK from receive buffer autotuning lei lei
2026-11-19  7:59   ` Eric Dumazet
2026-11-19 18:33     ` Matthieu Baerts
2026-11-20  8:05       ` Lin Lei
2026-11-20  8:22   ` netdev-bot+sashiko

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=20261129063755.1972521-1-llleigoing@gmail.com \
    --to=llleigoing@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=geliang@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=llleigoing@outlook.com \
    --cc=martineau@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=ncardwell@google.com \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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