All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Fomichev <sdf.kernel@gmail.com>
To: Mina Almasry <almasrymina@google.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	 Willem de Bruijn <willemb@google.com>,
	Kaiyuan Zhang <kaiyuanz@google.com>,
	 linux-kernel@vger.kernel.org,
	Neal Cardwell <ncardwell@google.com>,
	 Kuniyuki Iwashima <kuniyu@google.com>,
	Bobby Eshleman <bobbyeshleman@meta.com>,
	 Pavel Begunkov <asml.silence@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	 Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH net-next v4 2/2] net: prevent mixing frags from different memory providers or bindings
Date: Wed, 11 Nov 2026 14:01:01 -0800	[thread overview]
Message-ID: <avTkuRVZcOuYlu9T@devvm16445.scu0.facebook.com> (raw)
In-Reply-To: <CAHS8izNodRM1Bx+FT7okpdeDfCeyJVP5QoyxhSMJWXpGuwyL4A@mail.gmail.com>

On 11/11, Mina Almasry wrote:
> On Tue, Nov 10, 2026 at 7:54 PM Mina Almasry <almasrymina@google.com> wrote:
> >
> > On Mon, Nov 9, 2026 at 10:33 AM Stanislav Fomichev <sdf.kernel@gmail.com> wrote:
> > > > --- 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?

Based on [0] I'm thinking that I'll drop all per-frag enforcement
and will not add any special handing to tcp_mtu_probes. Looks like
the drivers are expected to handle large frags (if they advertise
large tso) or have a [1]-like segmentation fallback signal to the stack..

And yes, regular msg_zerocopy path already merges pages so this is
not niov specific.

0: https://lore.kernel.org/netdev/20261105222058.944293-1-sdf@fomichev.me/T/#m169832053b43604b0c5df7f7b1d04e9d4f390cbc
1: https://lore.kernel.org/netdev/20261105222058.944293-1-sdf@fomichev.me/T/#mb6e882ab1aecd6c15552773653301cc235b987d8

  reply	other threads:[~2026-11-11 22:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-08  1:38 [PATCH net-next v4 0/2] net: prevent mixing incompatible memory providers in skbs Mina Almasry
2026-11-08  1:38 ` [PATCH net-next v4 1/2] net: fix skb->unreadable propagation in skb_split() and skb_shift() Mina Almasry
2026-11-08  1:38 ` [PATCH net-next v4 2/2] net: prevent mixing frags from different memory providers or bindings Mina Almasry
2026-11-09  1:38   ` netdev-bot+sashiko
2026-11-09 18:32   ` Stanislav Fomichev
2026-11-11  3:54     ` Mina Almasry
2026-11-11 13:49       ` Mina Almasry
2026-11-11 22:01         ` Stanislav Fomichev [this message]
2026-11-11 22:03           ` Mina Almasry

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=avTkuRVZcOuYlu9T@devvm16445.scu0.facebook.com \
    --to=sdf.kernel@gmail.com \
    --cc=almasrymina@google.com \
    --cc=asml.silence@gmail.com \
    --cc=bobbyeshleman@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kaiyuanz@google.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=willemb@google.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.