From: sashiko-bot@kernel.org
To: "Geliang Tang" <geliang@kernel.org>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v12 1/4] mptcp: track app-limited state in mptcp_sendmsg
Date: Sat, 05 Dec 2026 07:47:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-251245@kernel.org> (raw)
In-Reply-To: <605d991d94090eda7a72b085b85cacfd76ec7c26.1796455402.git.tanggeliang@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] mptcp: wait_for_memory in mptcp_sendmsg() drops app_limited
before copy
- [Medium] mptcp: unnecessary mptcp_data_lock() in
mptcp_rate_check_app_limited()
--
commit 36682c147f4e37f3adc6c7a4255afd1bde0e45ce
Author: Geliang Tang <geliang@kernel.org>
mptcp: track app-limited state in mptcp_sendmsg
This commit tracks application-limited state in mptcp_sendmsg() by
checking MPTCP-level send conditions at entry and calling
tcp_rate_check_app_limited() on drained subflows in mptcp_sendmsg_frag().
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index b9c6e5a615c8b..1c6dc621191f3 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
[ ... ]
> @@ -2112,9 +2121,39 @@ static void mptcp_rps_record_subflows(const struct mptcp_sock *msk)
> }
> }
>
> +static bool mptcp_rate_check_app_limited(struct sock *sk)
> +{
> + struct mptcp_sock *msk = mptcp_sk(sk);
> + struct mptcp_subflow_context *subflow;
> + bool app_limited;
> +
> + if (msk->write_seq != msk->snd_nxt || mptcp_send_head(sk) ||
> + test_bit(MPTCP_WORK_RTX, &msk->flags))
> + return false;
> +
> + mptcp_data_lock(sk);
> + app_limited = !test_bit(MPTCP_RETRANSMIT, &msk->cb_flags) &&
> + !(msk->recovery &&
> + before64(msk->snd_una, msk->recovery_snd_nxt)) &&
> + (__mptcp_check_fallback(msk) ||
> + after64(mptcp_wnd_end(msk), msk->snd_nxt));
> + mptcp_data_unlock(sk);
> + if (!app_limited)
> + return false;
[Severity: Medium]
Is mptcp_data_lock(sk) needed here on the mptcp_sendmsg() hot path?
Acquiring sk->sk_lock.slock on every drained-queue sendmsg() doubles
spinlock acquisitions per syscall on 64-bit, adds a BH disable/enable
pair, and contends with softirq processing in ack_update_msk() and
mptcp_data_ready().
Under lock_sock(sk), __mptcp_check_fallback(msk), mptcp_wnd_end(msk),
msk->snd_nxt, msk->recovery, and msk->recovery_snd_nxt are already
lockless or stable, and msk->snd_una is only checked when msk->recovery
is set.
Since mptcp_retransmit_timer() can set MPTCP_RETRANSMIT in msk->cb_flags
right after unlock anyway, reading these fields locklessly would avoid
the spinlock.
[ ... ]
> @@ -2223,7 +2266,8 @@ 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);
> + __mptcp_push_pending(sk, msg->msg_flags, app_limited);
> + app_limited = false;
> ret = sk_stream_wait_memory(sk, &timeo);
> if (ret)
> goto do_error;
[Severity: Medium]
Can clearing app_limited here drop the app-limited marking when
wait_for_memory is reached before any data is copied?
When unacked in-flight dfrags fill sk->sk_sndbuf while msk->write_seq ==
msk->snd_nxt and mptcp_send_head(sk) == NULL,
mptcp_rate_check_app_limited() returns true, but mptcp_send_limit()
returns 0 on the first iteration and jumps straight to wait_for_memory.
__mptcp_push_pending() then returns without calling
tcp_rate_check_app_limited(ssk), and app_limited = false discards the
decision before sk_stream_wait_memory(). After wakeup, tp->app_limited
stays unset, so BBR treats send-buffer-limited flights as network-limited.
Clearing app_limited only when data was actually queued to push (or
marking drained subflows before sleeping, as tcp_sendmsg_locked() does)
would preserve the app-limited state across the wait.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796455402.git.tanggeliang@kylinos.cn?part=1
next prev parent reply other threads:[~2026-12-05 7:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 7:25 [PATCH mptcp-next v12 0/4] prepare interfaces for kTLS and sockmap support Geliang Tang
2026-12-05 7:25 ` [PATCH mptcp-next v12 1/4] mptcp: track app-limited state in mptcp_sendmsg Geliang Tang
2026-12-05 7:47 ` sashiko-bot [this message]
2026-12-05 14:16 ` Matthieu Baerts
2026-12-05 7:25 ` [PATCH mptcp-next v12 2/4] selftests: mptcp: sockopt: check app_limited Geliang Tang
2026-12-05 7:42 ` sashiko-bot
2026-12-05 7:25 ` [PATCH mptcp-next v12 3/4] mptcp: add sendmsg_locked to proto_ops Geliang Tang
2026-12-05 7:25 ` [PATCH mptcp-next v12 4/4] mptcp: update mptcp_check_readable Geliang Tang
2026-12-05 8:49 ` [PATCH mptcp-next v12 0/4] prepare interfaces for kTLS and sockmap support MPTCP CI
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=sashiko-outbox-251245@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=geliang@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.