From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796441788; b=kkC70AWLTsyDpFiVQoohamQYybsF8v5e5HsxmIDh/uTZNkjcyHXnenV7LcxlNnsHuIz7 i+NNwFs51/yRZ1UoDxLPj/YsnsfduKUtfs8Gn9kYcH+SyAEzeNFJq5o+mK52fG3h3AtK1 4Ry0jtSt8PxbinFjkoOR0W4sj4VxEewgFo2q25LJ13pzodJh0Fc6e207UlANL3BU192yw SP2adv+/Ghc/Z8fubjx0CdSRx+alsJA6CthaFwpntqUd36RVz8P7aAOMTFyxq9uBiPjWm DveidoJu5ASZu0jZAmg1cD7DHXkiIvdjZLuetep7cuDfBqWald2tsOruza2XsTjSalA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796441788; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=vKaACK0Lsh19UIJyYMOo1FPX3KeA/dbKo0xNFdf632k=; b=yLc3KDaKgWcteBECIpYmKn3Sld4iXddP0RdFwVtbQlfavg6VhbCTi4KKNDGwtLgD5WZO 7WunYiT8ZPVFF2wPa4BQKcAphnBqFmrljta2s8C9qvt0PPMaQbJ4b3eqgMlrwt040BxLq yu0WJWcyc7lrH87cr38ncLmTxbgdq8OTfZeGedZSYATypVQUik/xdCcI3WulOtJU7yasL /r3B9P3YlT0Q/Q53vD1ssmZj6CIpee1jaIZ2rWjRKukmnZ2VeTQHu0Mqhs3sDuIRn1x0e wWrtxofR+qe3hQH9QXPAkHlq2Fc+J3dkAp9Sum2pXJJQcSMpypnnvPT8++8QkE8dosQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iI0yESBM; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01979606A322 for ; Sat, 5 Dec 2026 03:36:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iI0yESBM Received: by smtp.kernel.org (Postfix) with ESMTPSA id 751761F0092B; Sat, 5 Dec 2026 03:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796441787; bh=vKaACK0Lsh19UIJyYMOo1FPX3KeA/dbKo0xNFdf632k=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=iI0yESBMyaWhQtttMdPkBTtaF7zZit7IBElQEK1aOiQz76zzZJ7NRDrz1t33TZ2tM eL4lblBlMfgAmVZMeJeDZq3GLb+lng6BIUD5rbCTmhk5E78FRHiFugpCvog8dA8SJF IwvvLyQ4wlCcA7q8ykdUyk3a3bslH5Yp6862j162p2qk/98SN3a/pj7uIvJ2Z34c+z Y65TgVCaC5n9NkDt4qTd41bNjpDRyKIlzk3kWOe14eYIjed/QuetRgAr5zolT0hWiG 2GoI7Wgkd4FAUKbYhHlwBaTPBWmJkVFXXlfZxdVg1oTLIQjg495u5GO5SiT9Qs9kSb 2TQrQte2S3rUg== Subject: Re: [PATCH mptcp-next v11 1/4] mptcp: track app-limited state in mptcp_sendmsg From: netdev-bot+sashiko@kernel.org To: geliang@kernel.org Cc: mptcp@lists.linux.dev, kuba@kernel.org Date: Sat, 05 Dec 2026 03:36:26 +0000 Message-ID: <179644178695.3143.11606891340428189075@kernel.org> In-Reply-To: <4fc318fc6b3764ff8ff0547f7a9d69ff707fa3b1.1796308130.git.geliang@kernel.org> References: <4fc318fc6b3764ff8ff0547f7a9d69ff707fa3b1.1796308130.git.geliang@kernel.org> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 2 · Low: 4 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] In __subflow_push_pending(), subflows can be marked app- limited again during a single bulk send, even though unsent dfrags are… - [Medium] mptcp: unconditional mptcp_data_lock() in mptcp_rate_check_app_limited() - [Low] In mptcp_sendmsg(), the app-limited result computed at entry can be cleared before any subflow uses it. - [Low] The commit message explains how the code works but not why the change is needed. - [Low] The commit author and the Signed-off-by do not match. - [Low] mptcp: placing app_limited before notsent_lowat grows struct mptcp_sock -- mptcp: track app-limited state in mptcp_sendmsg This commit adds mptcp_rate_check_app_limited(). It is called once at mptcp_sendmsg() entry, checks MPTCP-level conditions and stores the result in msk->app_limited. When that flag is set, __subflow_push_pending() calls tcp_rate_check_app_limited() on the scheduled subflow. The flag is cleared on the wait_for_memory path and on sendmsg exit. > mptcp: track app-limited state in mptcp_sendmsg > > Add mptcp_rate_check_app_limited() that evaluates MPTCP-level conditions > (write_seq == snd_nxt, no pending dfrags, no pending retransmission) > and stores the result in msk->app_limited. Called from mptcp_sendmsg() > before the data copy loop. In __subflow_push_pending(), if > msk->app_limited is set, call tcp_rate_check_app_limited() on the > scheduled subflow. The flag is cleared in the wait_for_memory path and > on sendmsg exit, so it is evaluated once per sendmsg and later pushes > do not re-mark subflows while unsent dfrags are still queued, which > would let BBR treat non-app-limited samples as application-limited. [Severity: Low] This isn't a bug, but the message explains how the code works and not why the change is needed. Could it include a problem statement? Before this patch, nothing in net/mptcp/ called tcp_rate_check_app_limited(). The only callers were tcp_sendmsg_locked() and espintcp. The real premise seems to be that MPTCP subflows never go through tcp_sendmsg_locked(), so tp->app_limited on a subflow is never re-armed after tcp_init_sock(). This commit doesn't say so. Only the follow-up selftest commit hints at it. The new writes to tcp_sk(ssk)->app_limited feed the generic rate sampling code (tcp_rate_skb_sent() and tcp_rate_gen()). That affects every congestion control module that uses rate samples, not only BBR. It also changes the delivery rate fields seen through TCP_INFO and MPTCP_TCPINFO. Would it be possible to add the observed symptom and some before/after results, for example with BBR and the default CUBIC? > > Signed-off-by: Geliang Tang [Severity: Low] This isn't a bug, but the author is Geliang Tang , while the only Signed-off-by uses . checkpatch reports this as FROM_SIGN_OFF_MISMATCH. Could the From: line or the trailer be changed to match? The later commits "selftests: mptcp: sockopt: check app_limited" and "mptcp: add sendmsg_locked to proto_ops" have the same mismatch. > diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c > index b9c6e5a615c8b..4be1990e2a243 100644 > --- a/net/mptcp/protocol.c > +++ b/net/mptcp/protocol.c > @@ -1815,6 +1815,9 @@ static int __subflow_push_pending(struct sock *sk, struct sock *ssk, > struct mptcp_data_frag *dfrag; > int len, copied = 0, err = 0; > > + if (msk->app_limited) > + tcp_rate_check_app_limited(ssk); > + [Severity: Medium] Can this mark a subflow app-limited again in the middle of a bulk send, while unsent dfrags are still queued? msk->app_limited stays set until the out: label in mptcp_sendmsg(). That label runs only after the final __mptcp_push_pending() has returned. Inside that push, the loop keeps going while data is pending, and every round calls __subflow_push_pending() again: net/mptcp/protocol.c:__mptcp_push_pending() { while (mptcp_send_head(sk) && (push_count > 0)) { ... if (mptcp_sched_get_send(msk)) break; ... ret = __subflow_push_pending(sk, ssk, &info); ... } Each __subflow_push_pending() call stops after msk->snd_burst bytes. So a large sendmsg on a connection with several subflows takes several rounds, and the scheduler can switch subflows between rounds. On a switch, mptcp_push_release() calls tcp_push() and release_sock() on the previous ssk. That subflow can then send all its data and process ACKs. sk_wmem_alloc can also drop quickly, for example with skb_orphan on loopback or veth. If the scheduler picks that subflow again in a later round, all the per-subflow checks in tcp_rate_check_app_limited() can pass, and tp->app_limited gets set again. At that point mptcp_send_head(sk) is non-NULL, so the msk-level check in mptcp_rate_check_app_limited() would reject this state. This seems to contradict the commit message: "later pushes do not re-mark subflows while unsent dfrags are still queued" Plain TCP marks only once, at tcp_sendmsg_locked() entry, and never inside its push loop. When this happens, samples from data that was not app-limited get tagged is_app_limited. BBR then ignores them unless bw >= max_bw, skips full-bandwidth detection on them, and resets long-term sampling. tcpi_delivery_rate_app_limited reported to userspace is also wrong. The later commits in this series don't change this logic. They only rename mptcp_sendmsg to mptcp_sendmsg_locked. [ ... ] > @@ -2224,6 +2247,7 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) > wait_for_memory: > sk_set_nospace(sk); > __mptcp_push_pending(sk, msg->msg_flags); > + msk->app_limited = 0; > ret = sk_stream_wait_memory(sk, &timeo); > if (ret) > goto do_error; [Severity: Low] Is the app-limited result from mptcp_sendmsg() entry lost here, if the first loop iteration jumps to wait_for_memory before any dfrag is queued? mptcp_rate_check_app_limited() sets msk->app_limited only when mptcp_send_head(sk) is NULL. The first iteration can then reach wait_for_memory through this check in mptcp_sendmsg(): copy_limit = mptcp_send_limit(sk); if (!copy_limit) goto wait_for_memory; That happens when sk_wmem_queued >= sk_sndbuf because unacked data is still charged to the msk. It also happens when mptcp_page_frag_refill() or sk_wmem_schedule() fails. In that case __mptcp_push_pending() does nothing, because its loop needs a send head. No subflow gets marked, and then the flag is cleared here. Nothing evaluates it again after sk_stream_wait_memory(), so data copied after the wait is pushed with the flag clear. Plain TCP doesn't have this gap, because tcp_rate_check_app_limited() writes tp->app_limited directly at sendmsg entry, before any wait. Later commits in the series don't change this. [ ... ] > diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h > --- a/net/mptcp/protocol.h > +++ b/net/mptcp/protocol.h > @@ -350,6 +350,7 @@ struct mptcp_sock { > free_first:1, > rcvspace_init:1, > fastclosing:1; > + u8 app_limited:1; > u32 notsent_lowat; > int keepalive_cnt; > int keepalive_idle; [Severity: Low] Does this grow struct mptcp_sock by 8 bytes on 64-bit kernels? After unsigned long cb_flags come 9 bools, pending_state, mpc_endpoint_id and the existing u8 bitfield. Together they fill exactly 12 bytes. Today notsent_lowat therefore sits 4-byte aligned with no padding, and the four ints after it end on an 8-byte boundary right before struct work_struct work. That bitfield already uses all 8 bits, so app_limited:1 starts a new byte at offset 12. This adds 3 bytes of padding before notsent_lowat. It then adds 4 more bytes after maxseg, before work. The growth also carries into struct mptcp6_sock, which embeds struct mptcp_sock by value. On 32-bit the struct still grows by 4 bytes. The rest of the series doesn't touch net/mptcp/protocol.h, so this stays. There is already a 2-byte hole after scaling_ratio and allow_subflows, right before subflow_id. Could app_limited go there instead? Running pahole on struct mptcp_sock before and after should confirm that the size doesn't change. [ ... ] > @@ -2112,6 +2115,23 @@ static void mptcp_rps_record_subflows(const struct mptcp_sock *msk) > } > } > > +static void mptcp_rate_check_app_limited(struct sock *sk) > +{ > + struct mptcp_sock *msk = mptcp_sk(sk); > + unsigned long flags; > + bool retransmit; > + > + flags = READ_ONCE(msk->flags); > + mptcp_data_lock(sk); > + retransmit = test_bit(MPTCP_RETRANSMIT, &msk->cb_flags); > + mptcp_data_unlock(sk); > + > + msk->app_limited = msk->write_seq == msk->snd_nxt && > + !mptcp_send_head(sk) && > + !test_bit(MPTCP_WORK_RTX, &flags) && > + !retransmit; > +} > + > static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) > { > struct mptcp_sock *msk = mptcp_sk(sk); [Severity: Medium] Does every mptcp_sendmsg() call now need to take the msk data lock? mptcp_data_lock() is spin_lock_bh() on sk->sk_lock.slock. Before this patch, the sendmsg path only touched that spinlock inside lock_sock() and release_sock(). Now every call adds a third acquisition, only to read MPTCP_RETRANSMIT from msk->cb_flags. The subflow RX and ACK softirq paths take the same spinlock, for example mptcp_update_data_ack(), mptcp_data_ready() and mptcp_retransmit_timer(). A busy sender now contends more often with incoming ACK processing. The local_bh_enable() in the unlock can also run pending softirqs before any data has been copied. The lock is taken even when the cheaper checks already decide the result. On a bulk sender, msk->write_seq != msk->snd_nxt or a non-NULL mptcp_send_head(sk) is the common case. Both are protected by the msk socket lock that sendmsg already holds. The lock also doesn't give a stable answer. mptcp_retransmit_timer() can set MPTCP_RETRANSMIT right after mptcp_data_unlock(), and the bit is only acted on in mptcp_release_cb() at release_sock() time anyway. Could the write_seq, send head and MPTCP_WORK_RTX checks run first, so the cb_flags test is reached only when all of them pass? And given the race above, is the data lock needed for that read at all, or would an annotated lockless read be enough? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796308130.git.geliang%40kernel.org