From: netdev-bot+sashiko@kernel.org
To: zibuyu423@gmail.com
Cc: mptcp@lists.linux.dev, kuba@kernel.org
Subject: Re: [PATCH mptcp-next 1/2] mptcp: support a connection-wide SO_MAX_PACING_RATE
Date: Sat, 05 Dec 2026 05:06:42 +0000 [thread overview]
Message-ID: <179644720207.3143.14344487727599069528@kernel.org> (raw)
In-Reply-To: <179630953225.20.6842896706912408920.mptcp-578-0001@gmail.com>
Thank you for your contribution! Sashiko AI review found 7 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 3 · 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] The connection-wide cap only gates when the next skb may start
(tcp_pacing_check()).
- [Medium] Some subflows keep using the shared msk clock after the
patch's synchronization stops covering them.
- [Medium] mptcp: tcp_pacing_delay() ignores mptcp_pacing_deadline()
causing early probe0
- [Low] The patch handles SO_MAX_PACING_RATE == 0 differently depending
on whether the connection stays MPTCP or falls back to plain TCP.
- [Low] The patch adds `bool mptcp_pacing` to struct tcp_sock
(include/linux/tcp.h, next to is_mptcp) but does not update…
- [Low] The comment on msk->pacing_lock (net/mptcp/protocol.h:314),
'serializes charging and rate changes', does not match how the lock is…
- [Low] The shared departure clock msk->pacing_next_ns has no upper
bound.
--
mptcp: support a connection-wide SO_MAX_PACING_RATE
This patch lets an application cap the aggregate transmit rate of an MPTCP
connection. It charges every subflow transmission to a departure clock
stored in the msk, and tcp_pacing_check() waits on that shared deadline.
A passive child that falls back to plain TCP gets the listener's limit as
a native TCP limit.
Link: https://github.com/multipath-tcp/mptcp_net-next/issues/578
> diff --git a/include/linux/tcp.h b/include/linux/tcp.h
> index 3d6eb6c8681dc..296cca1313c91 100644
> --- a/include/linux/tcp.h
> +++ b/include/linux/tcp.h
> @@ -516,6 +516,7 @@ struct tcp_sock {
> u32 plb_rehash; /* PLB-triggered rehash attempts */
> #if IS_ENABLED(CONFIG_MPTCP)
> bool is_mptcp;
> + bool mptcp_pacing;
> #endif
[Severity: Low]
The comment at the top of struct tcp_sock asks for
Documentation/networking/net_cachelines/tcp_sock.rst to be updated when
fields are added. That document lists is_mptcp but has no entry for
mptcp_pacing.
Should an entry be added? The field is now read on the TX path of every
TCP socket, in tcp_update_skb_after_send() and in tcp_pacing_check().
[ ... ]
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index e9313f39c7b81..57c7aeaec3af5 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -1520,6 +1520,8 @@ static void tcp_update_skb_after_send(struct sock *sk, struct sk_buff *skb,
> tp->tcp_wstamp_ns += len_ns;
> }
> }
> + if (mptcp_needs_pacing(sk))
> + mptcp_pacing_account(sk, skb->len);
> list_move_tail(&skb->tcp_tsorted_anchor, &tp->tsorted_sent_queue);
> }
[Severity: Medium]
tcp_pacing_check() now holds back the write queue until the shared
MPTCP deadline. The timers armed with pace_delay = true still only
add tcp_pacing_delay(), which looks at the subflow's own clock
(tcp_wstamp_ns - tcp_clock_cache) and never at pacing_next_ns. The
subflows keep sk_max_pacing_rate at ~0UL, so tcp_wstamp_ns does not
reflect the MPTCP cap, and tcp_pacing_delay() returns 0 even when the
shared deadline is far in the future.
Consider a subflow whose in-flight data is all ACKed before the shared
deadline. The next tcp_write_xmit() call, for instance from
tcp_data_snd_check() -> __tcp_push_pending_frames(), stops in
tcp_pacing_check(). It returns true with packets_out == 0 and a
non-empty write queue. tcp_check_probe_timer() then arms
ICSK_TIME_PROBE0 for tcp_probe0_base(), about 200ms, with no pacing
delay added.
If the MPTCP gap is longer than that, the probe fires first.
tcp_send_probe0() -> tcp_write_wakeup() sends up to one MSS straight
through tcp_transmit_skb() without consulting tcp_pacing_check().
That segment is still charged by tcp_update_skb_after_send() ->
mptcp_pacing_account(), which pushes pacing_next_ns further out. Once
it is ACKed, packets_out drops back to 0 and the probe timer is
re-armed, so the cycle repeats.
Take a cap below roughly one MSS per 200ms per subflow, or a burst
that leaves pacing_next_ns more than 200ms ahead. Doesn't each subflow
then send an unpaced MSS every probe interval? With several subflows
the aggregate can exceed SO_MAX_PACING_RATE, while the shared clock
drifts ever further into the future.
The other tcp_reset_xmit_timer(..., true) callers, such as
tcp_schedule_loss_probe(), tcp_rearm_rto() and tcp_ack_probe(), have
the same underestimate. TLP and RTO timers on a paced subflow can
therefore also fire before the shared deadline.
Should tcp_pacing_delay() also consider mptcp_pacing_deadline() when
mptcp_needs_pacing() is set? Or is there a better way to keep these
timers behind the shared clock?
[Severity: Medium]
The shared clock is charged only after the whole skb has gone out.
tcp_pacing_check() only decides when the next skb may start.
The subflows keep sk_max_pacing_rate at ~0UL.
mptcp_setsockopt_pacing_rate() only writes the msk value, and
sync_socket_options() does not copy it. So the subflow sk_pacing_rate is
never capped, and tcp_tso_autosize() still sizes skbs from it:
net/ipv4/tcp_output.c:tcp_tso_autosize() {
...
bytes = READ_ONCE(sk->sk_pacing_rate) >> READ_ONCE(sk->sk_pacing_shift);
...
}
On paths with min_rtt above about 512us, plain TCP with the same cap
would build skbs of roughly cap >> sk_pacing_shift bytes. Can an MPTCP
subflow instead build skbs up to sk_gso_max_size and send each one at
line rate before the shared clock makes it wait?
For example, a 100 KB/s cap on a fast WAN path would give 64KB line-rate
bursts followed by about 0.6s of silence. Plain TCP would send ~3KB skbs
at an even pace. fq does not smooth this out, because the skb EDT comes
from the subflow's own tcp_wstamp_ns.
The long-run average stays capped, but the bursts differ from
SO_MAX_PACING_RATE on plain TCP. Should the commit message mention this,
or should the cap also apply to the subflow sk_pacing_rate?
[ ... ]
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index b9c6e5a615c8b..1ffab3ece0002 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -1684,6 +1684,42 @@ bool mptcp_subflow_active(struct mptcp_subflow_context *subflow)
[ ... ]
> +void mptcp_pacing_account(const struct sock *ssk, unsigned int len)
> +{
> + struct sock *sk = mptcp_subflow_ctx(ssk)->conn;
> + s64 now, next, interval, credit;
> + struct mptcp_sock *msk;
> + unsigned long rate;
> +
> + if (!sk || !len)
> + return;
> +
> + msk = mptcp_sk(sk);
> + spin_lock_bh(&msk->pacing_lock);
> + rate = READ_ONCE(sk->sk_max_pacing_rate);
> + if (rate && rate != ~0UL) {
> + /* Keep enough credit for one timer tick. Without GSO a tick can
> + * cover several packets, all of which should be sent on wakeup.
> + * Limit idle credit to one MPTCP burst on fast connections.
> + */
> + now = tcp_sk(ssk)->tcp_clock_cache;
> + interval = div64_ul((u64)len * NSEC_PER_SEC, rate);
> + credit = min_t(s64, hrtimer_resolution,
> + div64_ul((u64)MPTCP_SEND_BURST_SIZE * NSEC_PER_SEC, rate));
> + credit = max(credit, interval / 2);
> + next = max_t(s64, atomic64_read(&msk->pacing_next_ns), now - credit);
> + atomic64_set(&msk->pacing_next_ns, next + interval);
[Severity: Low]
pacing_next_ns has no upper bound. interval is
len * NSEC_PER_SEC / rate, where the rate only has to be non-zero and not
~0UL. next + interval is stored without any clamp.
Some transmissions charge this clock without going through
tcp_pacing_check():
- RTO retransmits from tcp_retransmit_timer() via
__tcp_retransmit_skb()
- TLP retransmits
- MTU probes, because tcp_mtu_probe() runs in tcp_write_xmit() before
the pacing check
At a rate of 1 B/s, a single 64KB charge adds about 6.5e13 ns. If the
debt ever passes 2^63 ns, can next + interval wrap negative?
If it does, mptcp_pacing_deadline() returns a huge u64. tcp_pacing_check()
then arms the pacing hrtimer with an absolute time that has already
expired. The path tcp_pace_kick() -> tcp_tsq_handler() ->
tcp_write_xmit() -> tcp_pacing_check() can re-arm that timer from its own
callback. Could the soft hrtimer loop spin?
Getting there takes a very large number of unchecked charges at a
degenerate rate, and plain TCP's tcp_wstamp_ns grows in a similar
unbounded way, so this is mostly a hardening question. sch_fq clamps
the per-packet delay to NSEC_PER_SEC. Would a similar bound on interval
or on the total debt make sense here?
> + }
> + spin_unlock_bh(&msk->pacing_lock);
> +}
[ ... ]
> @@ -3920,6 +3958,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)
> WRITE_ONCE(msk->csum_enabled, mptcp_is_checksum_enabled(sock_net(sk)));
> mptcp_pm_data_reset(msk);
> mptcp_ca_reset(sk);
> + atomic64_set(&msk->pacing_next_ns, 0);
[Severity: Medium]
What happens to subflows that have left conn_list but are still sending?
__mptcp_close_ssk() unlinks a disposable subflow and closes it while
icsk_ulp_ops is still set:
net/mptcp/protocol.c:__mptcp_close_ssk() {
...
if (dispose_it)
list_del(&subflow->node);
...
__tcp_close(ssk, 0);
...
}
Nothing clears tcp_sk(ssk)->mptcp_pacing, and ctx->conn points at the msk
until subflow_ulp_release(). An orphaned subflow in FIN_WAIT1 with
unacked data keeps retransmitting from softirq timers. Each retransmission
goes through tcp_update_skb_after_send() -> mptcp_pacing_account() and
charges msk->pacing_next_ns.
This reset is a plain atomic64_set() without pacing_lock. By contrast,
mptcp_pacing_account() does a read-modify-write under that lock:
next = max_t(s64, atomic64_read(&msk->pacing_next_ns), now - credit);
atomic64_set(&msk->pacing_next_ns, next + interval);
Can a concurrent charge from a lingering subflow read the old value and
overwrite this reset?
Even without that race, would charges from the old connection's subflows
keep throttling the new connection after connect(AF_UNSPEC) and a
reconnect?
There is a related gap in mptcp_setsockopt_pacing_rate(). It walks only
conn_list through mptcp_for_each_subflow(), so detached subflows never
get mptcp_pacing updated or their queued pacing timer re-armed when the
limit changes.
> msk->bytes_consumed = 0;
> msk->bytes_acked = 0;
> msk->bytes_received = 0;
[ ... ]
> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index 7cdd0a7e8296b..1a98e5bd47bcb 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -310,6 +310,8 @@ struct mptcp_sock {
> u64 bytes_received;
> u64 ack_seq;
> atomic64_t rcv_wnd_sent;
> + atomic64_t pacing_next_ns;
> + spinlock_t pacing_lock; /* serializes charging and rate changes */
[Severity: Low]
Is this comment accurate? It does not seem to match how the lock is used:
- In mptcp_setsockopt_pacing_rate(), sk_setsockopt() writes
sk->sk_max_pacing_rate under lock_sock(msk) only, before pacing_lock
is taken.
- pacing_lock is taken only in the relaxed branch, around the debt
reset. Tightening the rate never takes it.
- mptcp_disconnect() resets pacing_next_ns without it.
For the same reason, the comment "Account sends using the previous rate
before clearing its debt" in mptcp_setsockopt_pacing_rate() is not
guaranteed. mptcp_pacing_account() can take pacing_lock between the
WRITE_ONCE() in sk_setsockopt() and the spin_lock_bh() in the relaxed
branch, and charge at the new rate.
In practice the lock only serializes charging against the setsockopt
debt reset. Could the comment say that?
[ ... ]
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 85695fe00cc38..5ae6be0cdb459 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
[ ... ]
> @@ -1056,6 +1057,14 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
> fallback:
> if (fallback)
> SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK);
> + /* This child is handed to plain TCP and will have no parent clock. */
> + if (listener->conn) {
> + unsigned long rate = READ_ONCE(listener->conn->sk_max_pacing_rate);
> +
> + if (rate != ~0UL)
> + sk_setsockopt(child, SOL_SOCKET, SO_MAX_PACING_RATE,
> + KERNEL_SOCKPTR(&rate), sizeof(rate));
[Severity: Low]
Should a rate of 0 be skipped here as well?
On the MPTCP side, 0 means no limit:
- mptcp_pacing_enabled() and mptcp_pacing_account() both check
rate && rate != ~0UL.
- mptcp_setsockopt_pacing_rate() treats a change to 0 as relaxing the
limit.
This check filters only ~0UL. If the listener has SO_MAX_PACING_RATE set
to 0, the fallback child ends up with sk_pacing_status set to
SK_PACING_NEEDED, and with sk_max_pacing_rate and sk_pacing_rate both 0.
tcp_small_queue_check() then limits the child to 2 * skb->truesize, and
tcp_tso_autosize() loses its pacing-rate term.
MPTCP children from the same listener get mptcp_pacing = false in
mptcp_sk_clone_init() and keep the normal TSQ/TSO sizing. So one listener
setting gives different transmit behaviour depending on whether the
connection fell back.
Would checking mptcp_pacing_enabled(listener->conn) here keep the two
cases consistent?
> + }
> mptcp_subflow_drop_ctx(child);
> return child;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179630953225.20.4977913523988952504.mptcp-578-0000%40gmail.com
next prev parent reply other threads:[~2026-12-05 5:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 14:53 [PATCH mptcp-next 0/2] mptcp: pace subflows against a connection-wide rate limit Ruilin Mao
2026-12-03 14:53 ` [PATCH mptcp-next 1/2] mptcp: support a connection-wide SO_MAX_PACING_RATE Ruilin Mao
2026-12-03 15:29 ` sashiko-bot
2026-12-05 5:06 ` netdev-bot+sashiko [this message]
2026-12-03 14:53 ` [PATCH mptcp-next 2/2] selftests: mptcp: check the aggregate pacing rate across two paths Ruilin Mao
2026-12-03 15:09 ` sashiko-bot
2026-12-05 5:06 ` 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=179644720207.3143.14344487727599069528@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=kuba@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=zibuyu423@gmail.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 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.