From: Pavel Begunkov <asml.silence@gmail.com>
To: Louis Thiery <thiery.louis@gmail.com>, Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] io_uring/net: don't charge the folio offset to truesize for managed frags
Date: Mon, 23 Nov 2026 13:20:25 +0000 [thread overview]
Message-ID: <2784354f-34f1-412b-aa95-70603f2f8cf8@gmail.com> (raw)
In-Reply-To: <20261119232935.1708458-1-thiery.louis@gmail.com>
On 11/19/26 23:29, Louis Thiery wrote:
> Registered buffers backed by huge pages are coalesced into one bvec per
> folio, so bv_offset is relative to the folio, not to a 4K page.
> io_sg_from_iter() adds PAGE_ALIGN(bv_len + bv_offset) to the skb
> truesize, which charges the socket for the whole run-up inside the
> folio. A 64K send from 1.5MB into a 2MB THP folio adds about 1.6MB of
> truesize, and sk_wmem_queued fills long before any real memory is used.
>
> The visible effect is a socket that looks full: with a 2MB send buffer
> only 4 of 128 queued 64K sends complete before the sender blocks,
> versus 30 of 128 with the same buffer registered as 4K pages, and most
> pipelined send_zc requests come back short.
>
> Only the in-page part of the offset matters for how much memory a
> fragment ties up, so use offset_in_page(). This matches what
> zerocopy_fill_skb_from_iter() charges for the same data.
Looks good, thanks for the patch.
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
>
> Fixes: 57bebf807e2a ("io_uring/rsrc: optimise registered huge pages")
> Cc: stable@vger.kernel.org
> Signed-off-by: Louis Thiery <thiery.louis@gmail.com>
> ---
> io_uring/net.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/io_uring/net.c b/io_uring/net.c
> index 533afd335..8afad1b2d 100644
> --- a/io_uring/net.c
> +++ b/io_uring/net.c
> @@ -1501,7 +1501,12 @@ static int io_sg_from_iter(struct sk_buff *skb,
> struct bio_vec v = mp_bvec_iter_bvec(from->bvec, bi);
>
> copied += v.bv_len;
> - truesize += PAGE_ALIGN(v.bv_len + v.bv_offset);
> + /*
> + * bv_offset is relative to the folio for coalesced huge page
> + * registrations, so only the in-page part of it matters for
> + * how much memory this fragment ties up.
> + */
> + truesize += PAGE_ALIGN(v.bv_len + offset_in_page(v.bv_offset));
> __skb_fill_page_desc_noacc(shinfo, frag++, v.bv_page,
> v.bv_offset, v.bv_len);
> bvec_iter_advance_single(from->bvec, &bi, v.bv_len);
>
> base-commit: 0659e44ce739ecd856164c75a5325b7959a2921d
--
Pavel Begunkov
prev parent reply other threads:[~2026-11-23 13:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 23:29 Louis Thiery
2026-11-20 0:11 ` Brian Martin
2026-11-20 0:26 ` Louis Thiery
2026-11-23 13:20 ` Pavel Begunkov [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=2784354f-34f1-412b-aa95-70603f2f8cf8@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=thiery.louis@gmail.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
all inboxes | Powered by JetHome®