All of lore.kernel.org
 help / color / mirror / Atom feed
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>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	 netdev@vger.kernel.org, Jiayuan Chen <jiayuan.chen@linux.dev>
Subject: Re: [PATCH net-next] net: do not over-estimate truesize in zerocopy_fill_skb_from_iter()
Date: Sat, 21 Nov 2026 19:11:43 +0000	[thread overview]
Message-ID: <awHs5yZyi002msnJ@google.com> (raw)
In-Reply-To: <20261119101538.3229466-1-edumazet@kernel.org>

On Thu, 19 Nov 2026 11:15:38 +0100, Eric Dumazet wrote:
> zerocopy_fill_skb_from_iter() adds PAGE_ALIGN(copied + start) to
> skb->truesize for each iov_iter_get_pages2() call.
> 
> Since commit 394fcd8a8134 ("net: zerocopy: combine pages in
> zerocopy_sg_from_iter()"), a chunk that directly follows the last frag
> in the same page is merged into this frag, and the extra page reference
> is released. The page is still accounted again in skb->truesize.
> 
> With iovecs describing small contiguous chunks of the same page, each
> iovec charges a full page while a single page is pinned. For TCP,
> 1024 one-byte iovecs sent with MSG_ZEROCOPY add 4 MB to sk_wmem_queued
> and charge 4 MB to the socket, for 1024 bytes of payload sitting in
> one page. Appending to the skb at the tail of the write queue does not
> check sk_sndbuf, so a single sendmsg() can get sk_wmem_queued above it.
> 
> Account pages while building the frags instead:
> 
> - A new frag accounts one page, as before.
> - A chunk merged into the last frag only accounts the pages this frag
>   did not already cover.
> 
> The accounting is unchanged when no chunk is merged in the middle
> of a page.
> 
> Fixes: 394fcd8a8134 ("net: zerocopy: combine pages in zerocopy_sg_from_iter()")
> Link: https://lore.kernel.org/netdev/20261119090828.343748-1-jiayuan.chen@linux.dev/
> Cc: Jiayuan Chen <jiayuan.chen@linux.dev>
> Signed-off-by: Eric Dumazet <edumazet@kernel.org>

Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>

  reply	other threads:[~2026-11-21 19:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 10:15 [PATCH net-next] net: do not over-estimate truesize in zerocopy_fill_skb_from_iter() Eric Dumazet
2026-11-21 19:11 ` Kuniyuki Iwashima [this message]
2026-11-21 19:35 ` netdev-bot+sashiko
2026-11-23  9:02   ` Eric Dumazet

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=awHs5yZyi002msnJ@google.com \
    --to=kuniyu@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --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.