Drop redundant tcp_rate_check_app_limited calls
Subsystems (7)
Geliang Tang
reviewercover Drop redundant tcp_rate_check_app_limited calls
From: Geliang Tang <[email protected]>
These two patches drop the redundant tcp_rate_check_app_limited() calls before tcp_sendmsg_locked() in tcp_bpf_push() and tls_push_sg(), since tcp_rate_check_app_limited() is already called inside tcp_sendmsg_locked().
Note:
The first patch was originally part of my ongoing "MPTCP sockmap support" series [1] (patch 5). Matthieu suggested converting it to a fix and sending it directly to netdev. Removing the redundant tcp_rate_check_app_limited() call benefits my subsequent MPTCP work: in patch 3 of that series, I implement an MPTCP-specific mptcp_rate_check_app_limited() function and call it in mptcp_sendmsg_locked(). This allows me to reuse tcp_bpf_push() by simply replacing tcp_sendmsg_locked() with
sk->sk_socket->ops->sendmsg_locked(),
without carrying protocol-specific assumptions.
The second patch similarly benefits my ongoing "MPTCP KTLS support" work [2]. In patch 9 of that series, I had defined a check_app_limited() interface in struct tls_prot_ops, but this interface is unnecessary if we can reuse the existing TLS infrastructure more cleanly.
[1]
MPTCP sockmap support
https://lore.kernel.org/mptcp/[email protected]/T/#t
[2]
MPTCP KTLS support
https://lore.kernel.org/netdev/[email protected]/
Geliang Tang (2):
bpf: drop duplicate check_app_limited in tcp_bpf_push
tls: drop duplicate check_app_limited in tls_push_sg
net/ipv4/tcp_bpf.c | 1 - net/tls/tls_main.c | 2 -- 2 files changed, 3 deletions(-)
Signature · 1 line
2.53.0
Geliang Tang
reviewerPATCH 1/2 bpf: drop duplicate check_app_limited in tcp_bpf_push
From: Geliang Tang <[email protected]>
When the sendpage->MSG_SPLICE_PAGES migration series replaced do_tcp_sendpages() with direct tcp_sendmsg_locked() calls, callers that had used do_tcp_sendpages() kept an explicit tcp_rate_check_app_limited(sk) that was originally needed to cover do_tcp_sendpages() (which did not call tcp_rate_check_app_limited()). After the inlining, tcp_sendmsg_locked() always provides the check, and the outer call became redundant.
The site changed here, tcp_bpf_push(), is a MSG_SPLICE_PAGES loop that holds the socket lock and only iterates when size > 0; tcp_sendmsg_locked() is invoked on every iteration with state identical to what the outer call sees, so dropping the outer call is safe and behavior-preserving.
A potential benefit of this change is that it facilitates future reuse of tcp_bpf_push() for sockmap support in protocols beyond TCP, such as MPTCP. Since tcp_rate_check_app_limited() is TCP-specific while sendmsg_locked() is a generic interface in struct proto_ops, this change allows us to switch to different protocols via sk->sk_socket->ops->sendmsg_locked() without carrying protocol-specific assumptions.
--- net/ipv4/tcp_bpf.c | 1 - 1 file changed, 1 deletion(-)
net/ipv4/tcp_bpf.c +0 -1
@@ -108,7 +108,6 @@ static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes, off = sge->offset; page =sg_page (sge); -tcp_rate_check_app_limited (sk); retry: msghdr.msg_flags = flags |MSG_SPLICE_PAGES ; has_tx_ulp =tls_sw_has_ctx_tx (sk);
Signature · 1 line
2.53.0
Geliang Tang
reviewerPATCH 2/2 tls: drop duplicate check_app_limited in tls_push_sg
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
When the sendpage->MSG_SPLICE_PAGES migration series replaced do_tcp_sendpages() with direct tcp_sendmsg_locked() calls, callers that had used do_tcp_sendpages() kept an explicit tcp_rate_check_app_limited(sk) that was originally needed to cover do_tcp_sendpages() (which did not call tcp_rate_check_app_limited()). After the inlining, tcp_sendmsg_locked() always provides the check, and the outer call became redundant.
The site changed here, tls_push_sg(), is a MSG_SPLICE_PAGES loop that holds the socket lock and only iterates when size > 0; tcp_sendmsg_locked() is invoked on every iteration with state identical to what the outer call sees, so dropping the outer call is safe and behavior-preserving.
A potential benefit of this change is that it facilitates future reuse of tls_push_sg() for KTLS support in protocols beyond TCP, such as MPTCP. Since tcp_rate_check_app_limited() is TCP-specific while sendmsg_locked() is a generic interface in struct proto_ops, this change allows us to switch to different protocols via sk->sk_socket->ops->sendmsg_locked() without carrying protocol-specific assumptions.
--- net/tls/tls_main.c | 2 -- 1 file changed, 2 deletions(-)
net/tls/tls_main.c +0 -2
@@ -185,8 +185,6 @@ int tls_push_sg(struct sock *sk, ctx->splicing_pages = true;while (1 ) { -/* is sending application-limited? */ -tcp_rate_check_app_limited (sk); p =sg_page (sg); retry:bvec_set_page (&bvec, p, size, offset);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net 2/2] tls: drop duplicate check_app_limited in tls_push_sg
Does the Fixes: tag identify the correct commit? The changelog states the outer call "was originally needed to cover do_tcp_sendpages() (which did not call tcp_rate_check_app_limited())" and that it…
Quoted 8 lines
When the
sendpage->MSG_SPLICE_PAGESmigration series replaceddo_tcp_sendpages()with directtcp_sendmsg_locked()calls, callers that had useddo_tcp_sendpages()kept an explicittcp_rate_check_app_limited(sk)that was originally needed to coverdo_tcp_sendpages()(which did not calltcp_rate_check_app_limited()). After the inlining,tcp_sendmsg_locked()always provides the check, and the outer call became redundant.Fixes e117dcfd646e ("tls: Inline do_tcp_sendpages()")
Does the Fixes: tag identify the correct commit? The changelog states the outer call "was originally needed to cover do_tcp_sendpages() (which did not call tcp_rate_check_app_limited())" and that it "became redundant" only "after the inlining". But e117dcfd646e did not introduce the redundancy.
At e117dcfd646e's parent, do_tcp_sendpages() was already a thin wrapper that funnels into tcp_sendmsg_locked():
ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset,
size_t size, int flags)
{
struct bio_vec bvec;
struct msghdr msg = { .msg_flags = flags | MSG_SPLICE_PAGES, };
bvec_set_page(&bvec, page, size, offset);
iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size);
if (flags & MSG_SENDPAGE_NOTLAST)
msg.msg_flags |= MSG_MORE;
return tcp_sendmsg_locked(sk, &msg, size);
}The conversion that made this true - and therefore the commit that made the tls_push_sg() call redundant - is c5c37af6ecad9 ("tcp: Convert do_tcp_sendpages() to use MSG_SPLICE_PAGES"), three commits earlier in the same series. Before c5c37af6ecad9, do_tcp_sendpages() open-coded the send loop and indeed had no rate check, and tcp_sendmsg_locked() already carried tcp_rate_check_app_limited() at that point. e117dcfd646e only replaced the wrapper call with its body; it left the tcp_rate_check_app_limited(sk) line untouched as diff context.
If a Fixes: tag is kept, should it be:
Both commits landed in the same merge window, so the practical backport range is unchanged.
Quoted 6 lines
so dropping the outer call is safe and behavior-preserving.
A potential benefit of this change is that it facilitates future reuse of
tls_push_sg()for KTLS support in protocols beyond TCP, such as MPTCP.Fixes e117dcfd646e ("tls: Inline do_tcp_sendpages()")
Should this patch carry a Fixes: tag? The changelog describes the change as "safe and behavior-preserving" and motivates it as cleanup plus preparation for future MPTCP reuse. No user-visible bug, regression, crash or misbehaviour is described or fixed: the removed tcp_rate_check_app_limited(sk) is duplicated by the identical call inside tcp_sendmsg_locked(), so tp->app_limited ends up with the same value either way.
A Fixes: tag on a no-op cleanup mainly serves to draw the patch into automated stable selection (AUTOSEL) for no benefit. Either drop the tag, or state concretely what observable behaviour was wrong before so the tag is justified.
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/34817950722
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Perf: Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/34818072039
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/0add685232c4
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1164231
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Jiayuan Chen
maintainerRe: [PATCH bpf 1/2] bpf: drop duplicate check_app_limited in tcp_bpf_push
In reply to Geliang TangQuoted 14 lines · Geliang Tang
From: Geliang Tang <[email protected]>
When the
sendpage->MSG_SPLICE_PAGESmigration series replaceddo_tcp_sendpages()with directtcp_sendmsg_locked()calls, callers that had useddo_tcp_sendpages()kept an explicittcp_rate_check_app_limited(sk)that was originally needed to coverdo_tcp_sendpages()(which did not calltcp_rate_check_app_limited()). After the inlining,tcp_sendmsg_locked()always provides the check, and the outer call became redundant.The site changed here,
tcp_bpf_push(), is aMSG_SPLICE_PAGESloop that holds the socket lock and only iterates when size > 0;tcp_sendmsg_locked()is invoked on every iteration with state identical to what the outer call sees, so dropping the outer call is safe and behavior-preserving.
Quoted 8 lines
A potential benefit of this change is that it facilitates future reuse of
tcp_bpf_push()for sockmap support in protocols beyond TCP, such as MPTCP. Sincetcp_rate_check_app_limited()is TCP-specific whilesendmsg_locked()is a generic interface in structproto_ops, this change allows us to switch to different protocols viask->sk_socket->ops->sendmsg_locked()without carrying protocol-specific assumptions.Fixes ebf2e8860eea ("tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg")
Same as the tls one: this looks like a cleanup to me. Is there a real regression that affects kernel or user behavior?
Do we really need a Fixes tag?
Quoted 17 lines
Signed-off-by Geliang Tang <[email protected]>--- net/ipv4/tcp_bpf.c | 1 - 1 file changed, 1 deletion(-)net/ipv4/tcp_bpf.c +0
-1@@ -108,7 +108,6 @@ static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes, off = sge->offset; page =sg_page (sge); -tcp_rate_check_app_limited (sk); retry: msghdr.msg_flags = flags |MSG_SPLICE_PAGES ; has_tx_ulp =tls_sw_has_ctx_tx (sk);
Re: [PATCH bpf 1/2] bpf: drop duplicate check_app_limited in tcp_bpf_push
Quoted 4 lines · Jiayuan Chen
Same as the tls one: this looks like a cleanup to me. Is there a real regression that affects kernel or user behavior?
Do we really need a Fixes tag?
Hi Jiayuan,
It's a part of the thread in [1], just kindly remind that there had some comments from Matt:
'''
Also, should this be seen as a fix? From what I understand, some behaviours have changed, and it is only recently that this call is no longer needed.
'''
From my view, it seems like that there have some misses in the 'fixed' commit, so the fix tag should be kept, right?
[1] https://lore.kernel.org/mptcp/[email protected]/T/#m1fbcb32408236e2c68554fd26353c98bb59633f9
Thanks
Gang
Quoted 19 lines
Quoted 18 lines
Signed-off-by Geliang Tang <[email protected]>---
net/ipv4/tcp_bpf.c | 1 - 1 file changed, 1 deletion(-)diff --git
a/net/ipv4/tcp_bpf.cb/net/ipv4/tcp_bpf.c
index2e234d155b5e..d5fcf3ce4861100644
---a/net/ipv4/tcp_bpf.c
+++b/net/ipv4/tcp_bpf.c
@@ -108,7 +108,6 @@ static int tcp_bpf_push(struct sock *sk, structsk_msg*msg, u32apply_bytes, off =sge->offset;
page =sg_page(sge);Quoted 1 line
-
tcp_rate_check_app_limited(sk);retry:
msghdr.msg_flags = flags |MSG_SPLICE_PAGES;
has_tx_ulp=tls_sw_has_ctx_tx(sk);
Re: [PATCH bpf 1/2] bpf: drop duplicate check_app_limited in tcp_bpf_push
In reply to Jiayuan ChenQuoted 4 lines · Jiayuan Chen
Same as the tls one: this looks like a cleanup to me. Is there a real regression that affects kernel or user behavior?
Do we really need a Fixes tag?
Hi Jiayuan,
It's a part of the thread in [1], just kindly remind that there had some comments from Matt:
'''
Also, should this be seen as a fix? From what I understand, some behaviours have changed, and it is only recently that this call is no longer needed.
'''
From my view, it seems like that there have some misses in the 'fixed' commit, so the fix tag should be kept, right?
[1] https://lore.kernel.org/mptcp/[email protected]/T/#m1fbcb32408236e2c68554fd26353c98bb59633f9
Thanks
Gang
Quoted 19 lines
Quoted 18 lines
Signed-off-by Geliang Tang <[email protected]>---
net/ipv4/tcp_bpf.c | 1 - 1 file changed, 1 deletion(-)diff --git
a/net/ipv4/tcp_bpf.cb/net/ipv4/tcp_bpf.c
index2e234d155b5e..d5fcf3ce4861100644
---a/net/ipv4/tcp_bpf.c
+++b/net/ipv4/tcp_bpf.c
@@ -108,7 +108,6 @@ static int tcp_bpf_push(struct sock *sk, structsk_msg*msg, u32apply_bytes, off =sge->offset;
page =sg_page(sge);Quoted 1 line
-
tcp_rate_check_app_limited(sk);retry:
msghdr.msg_flags = flags |MSG_SPLICE_PAGES;
has_tx_ulp=tls_sw_has_ctx_tx(sk);
Matthieu Baerts
maintainerRe: [PATCH bpf 1/2] bpf: drop duplicate check_app_limited in tcp_bpf_push
In reply to [email protected]Hi Gang, Jiayuan, Geliang,
Quoted 10 lines · On 14/09/2026 10:45, [email protected] wrote:
Quoted 4 lines · Jiayuan Chen
Same as the tls one: this looks like a cleanup to me. Is there a real regression that affects kernel or user behavior?
Do we really need a Fixes tag?
Hi Jiayuan,
It's a part of the thread in [1], just kindly remind that there had some comments from Matt:
Quoted 8 lines
'''
Also, should this be seen as a fix? From what I understand, some behaviours have changed, and it is only recently that this call is no longer needed.
'''From my view, it seems like that there have some misses in the 'fixed' commit, so the fix tag should be kept, right?
When I first saw the modification, it fell like Geliang was fixing something, hence my question. It is indeed fixing something, but if it "just" avoids extra checks that are now useless, I agree that it doesn't need to carry the fixes tag. (Except if it creates a noticeable perf regression, but I don't think so here.)
If the Fixes tag is removed, it is always good to mention this commit to help with the context (and just in case if this patch can help with the backports). And also good to mention c5c37af6ecad9 ("tcp: Convert do_tcp_sendpages() to use MSG_SPLICE_PAGES") in the commit message as well.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerRe: [PATCH bpf 1/2] bpf: drop duplicate check_app_limited in tcp_bpf_push
In reply to Jiayuan ChenHi Jiayuan,
Quoted 35 lines · Jiayuan Chen
Quoted 33 lines · Geliang Tang
From: Geliang Tang <[email protected]>
When the
sendpage->MSG_SPLICE_PAGESmigration series replaceddo_tcp_sendpages()with directtcp_sendmsg_locked()calls, callers that
had useddo_tcp_sendpages()kept an explicittcp_rate_check_app_limited(sk)
that was originally needed to coverdo_tcp_sendpages()(which did not calltcp_rate_check_app_limited()). After the inlining,tcp_sendmsg_locked()
always provides the check, and the outer call became redundant.The site changed here,
tcp_bpf_push(), is aMSG_SPLICE_PAGESloop that
holds the socket lock and only iterates when size > 0;tcp_sendmsg_locked()
is invoked on every iteration with state identical to what the outer call
sees, so dropping the outer call is safe and behavior-preserving.A potential benefit of this change is that it facilitates future reuse of
tcp_bpf_push()for sockmap support in protocols beyond TCP, such as MPTCP.
Sincetcp_rate_check_app_limited()is TCP-specific whilesendmsg_locked()
is a generic interface in structproto_ops, this change allows us to switch
to different protocols viask->sk_socket->ops->sendmsg_locked()without
carrying protocol-specific assumptions.
Quoted 8 lines
Quoted 2 lines
Fixes ebf2e8860eea ("tcp_bpf: Inline do_tcp_sendpages as it's nowa wrapper around
tcp_sendmsg")Same as the tls one: this looks like a cleanup to me. Is there a real regression that affects kernel or user behavior?
Do we really need a Fixes tag?
Thanks for the review. I fully agree - I'll drop the "Fixes" tags and update the commit logs in v2.
Thanks,
-Geliang
Quoted 20 lines
Quoted 20 lines
Signed-off-by Geliang Tang <[email protected]>---
net/ipv4/tcp_bpf.c| 1 -1 file changed, 1 deletion(-)net/ipv4/tcp_bpf.c +0
-0@@ -108,7 +108,6 @@ static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes, off = sge->offset; page = sg_page(sge);net/ipv4/tcp_bpf.c +0
-1-tcp_rate_check_app_limited (sk);retry:
msghdr.msg_flags = flags |MSG_SPLICE_PAGES;has_tx_ulp=tls_sw_has_ctx_tx(sk);
Jakub Kicinski
maintainerQuoted 2 lines · On Mon, 14 Sep 2026 15:14:21 +0800 Geliang Tang wrote:
bpf: drop duplicate
check_app_limitedintcp_bpf_push
tls: drop duplicatecheck_app_limitedintls_push_sg
you can't have 2 patches in one series targeting different trees
Geliang Tang
reviewerHi Jakub,
Quoted 5 lines · Jakub Kicinski
Quoted 2 lines · On Mon, 14 Sep 2026 15:14:21 +0800 Geliang Tang wrote:
bpf: drop duplicate
check_app_limitedintcp_bpf_push
tls: drop duplicatecheck_app_limitedintls_push_sgyou can't have 2 patches in one series targeting different trees
Right, my bad. I'll send them as two separate patches in v3, each to its own tree.
Thanks,
-Geliang