Re: [PATCH net-next v4 2/2] net: prevent mixing frags from different memory providers or bindings

From
Mina Almasry <hidden>
Date
2026-11-11 13:50:12
Also in
lkml
Reply to
Mina Almasry, 2026-11-11
On Tue, Nov 10, 2026 at 7:54 PM Mina Almasry [off-list ref] wrote:
On Mon, Nov 9, 2026 at 10:33 AM Stanislav Fomichev [off-list ref] wrote:
quoted
quoted
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2692,8 +2692,9 @@ static int tcp_clone_payload(struct sock *sk, struct sk_buff *to,
                                   probe_size - len);
                      len += todo;
                      skb_shinfo(to)->flags |= skb_shinfo(skb)->flags & SKBFL_SHARED_FRAG;
+                     to->unreadable |= skb->unreadable;
                      if (lastfrag &&
-                         skb_frag_page(fragfrom) == skb_frag_page(lastfrag) &&
+                         skb_frag_netmem(fragfrom) == skb_frag_netmem(lastfrag) &&
                          skb_frag_off(fragfrom) == skb_frag_off(lastfrag) +
                                                    skb_frag_size(lastfrag)) {
                              skb_frag_size_add(lastfrag, todo);
From [0]:

Maybe easier to not merge niovs here? Add '&& !skb_frag_is_net_iov' to
that 'if (lastfrag' check? (or your new skb_has_net_iovs)

Looks like it is tcp_mtu_probe path, not sure we care about merging there?
I'm guessing this is not an issue with pages because they're
PAGE_SIZE? But, seems maybe a bit lazy to just hammer all possible
net-iov coalescing? Is there a slightly cleaner and more generic check
( && skb_frag_size < PAGE_SIZE or something) so that we don't add
net-iov tech debt? Technically this will be an issue for hugepages in
the tx path or large folios or something.

Also I think it belongs in your patch series maybe. That's the one
adding the large niovs :P
Actually, this comment made me realize: is the optimization that you
did with net-iovs here (that's showing so much better cpu) also
already implemented for pages? If not, is it possible? I don't see in
theory why the userpsace can't pass in a contingious 2MB page to
sendmsg() and the stack could keep it intact in 1 frag up to what the
driver tx supports, no? Is it worth it making your feature generic and
apply to pages too?


-- 
Thanks,
Mina
Thread (9 messages) 9 messages, 3 authors, last reply 10d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help