From: Kuniyuki Iwashima <kuniyu@google.com>
To: Eric Dumazet <edumazet@kernel.org>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Neal Cardwell <ncardwell@google.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next] tcp: use order-0 page frags in tcp_collapse()
Date: Sun, 29 Nov 2026 22:47:28 +0000 [thread overview]
Message-ID: <awyq143K7DJ0yvXr@google.com> (raw)
In-Reply-To: <20261123154708.360226-1-edumazet@kernel.org>
On Mon, 23 Nov 2026 16:47:08 +0100, Eric Dumazet wrote:
> tcp_collapse() copies payload into linear skbs of SKB_MAX_ORDER(0, 0)
> bytes (3776 bytes on x86_64), each of them with its own sk_buff and
> its own skb_shared_info.
>
> The truesize of such an skb is 4352 bytes: 13% of the memory is
> overhead, and a collapsed range can not be denser than that.
>
> Store the payload in order-0 page frags instead. One sk_buff can
> hold up to MAX_SKB_FRAGS pages, and the overhead of a collapsed
> range is now about one sk_buff and its small head.
>
> What does not fill a page is stored in the linear part of the first
> new skb, if this is not bigger than SKB_MAX_ORDER(0, 0) bytes: this
> is never more expensive than a partially used page. Otherwise, the
> last page frag is partially used.
>
> A range of up to SKB_MAX_ORDER(0, 0) bytes is still collapsed into
> a linear skb.
>
> All the pages are allocated before the copy, like skbs were, so
> that tcp_collapse() can still give up without side effect if an
> allocation fails. The truesize of the new skbs is still known
> before they are allocated, to skip the ranges that would not
> shrink.
>
> In tcp_rcv_collapse_bloated.pkt, the 30 skbs of 1000 bytes
> (truesize 69120) were collapsed into 8 skbs (truesize 34816).
> They are now collapsed into a single skb with 7 pages
> (truesize 30976).
>
> Other benefits:
>
> - Fewer skbs in the receive queue and in the out-of-order rbtree.
>
> - Collapsed data is stored in page frags which are full pages,
> except possibly the last one: they can be used by
> TCP_ZEROCOPY_RECEIVE.
>
> TCP_COLLAPSE_SCALING_RATIO is not changed: skbs with a density
> above 86% are still not collapsed.
>
> Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
I guess we could set recv_skip_hint = skb_headlen(skb) - offset
if offset < skb_headlen(skb) to enable zcopy for collapsed skb
with linear data.
Thanks !
prev parent reply other threads:[~2026-11-29 22:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 15:47 [PATCH net-next] tcp: use order-0 page frags in tcp_collapse() Eric Dumazet
2026-11-24 16:27 ` netdev-bot+sashiko
2026-11-29 22:47 ` Kuniyuki Iwashima [this message]
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=awyq143K7DJ0yvXr@google.com \
--to=kuniyu@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox