All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: stable@vger.kernel.org
Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org
Subject: [PATCH 6.12.y 01/15] io_uring/net: don't charge the folio offset to truesize for managed frags
Date: Sat,  5 Dec 2026 23:10:53 +0000	[thread overview]
Message-ID: <20261205231107.4023506-2-axboe@kernel.dk> (raw)
In-Reply-To: <20261205231107.4023506-1-axboe@kernel.dk>

From: Louis Thiery <thiery.louis@gmail.com>

Commit aaa55c8ff9147b1ce1ba50267aa9f080d469a963 upstream.

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.

Fixes: 57bebf807e2a ("io_uring/rsrc: optimise registered huge pages")
Cc: stable@vger.kernel.org
Signed-off-by: Louis Thiery <thiery.louis@gmail.com>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Reported-by: Brian Martin <brayniac@gmail.com>
Closes: https://lore.kernel.org/io-uring/CAC+fX10wVVSqGnfCg+aazorsCxB34sUDV-XJiBPd6R3Kuqc-7Q@mail.gmail.com/
Tested-by: Brian Martin <brayniac@gmail.com>
Link: https://patch.msgid.link/20261119232935.1708458-1-thiery.louis@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 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 c6512064bdda..53773b0d5276 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -1414,7 +1414,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);
-- 
2.55.0


  reply	other threads:[~2026-12-05 23:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 23:10 [PATCH 6.12.y 00/15] io_uring fixes for 6.12-stable Jens Axboe
2026-12-05 23:10 ` Jens Axboe [this message]
2026-12-05 23:10 ` [PATCH 6.12.y 02/15] io_uring/net: don't copy msg_name on a recvmsg retry Jens Axboe
2026-12-05 23:10 ` [PATCH 6.12.y 03/15] io_uring/kbuf: clear REQ_F_BL_NO_RECYCLE on buffer put Jens Axboe
2026-12-05 23:10 ` [PATCH 6.12.y 04/15] io_uring/tctx: add separate lock for list of tctx's in ctx Jens Axboe
2026-12-05 23:10 ` [PATCH 6.12.y 05/15] io_uring: free the task context after a grace period Jens Axboe
2026-12-05 23:10 ` [PATCH 6.12.y 06/15] io_uring: free the ring " Jens Axboe
2026-12-05 23:10 ` [PATCH 6.12.y 07/15] io_uring/filetable: don't install O_PATH files Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 08/15] io_uring: make ctx->timeout_lock a raw spinlock Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 09/15] io_uring/timeout: flush timeouts outside of the timeout lock Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 10/15] io_uring/cancel: always walk links under timeout_lock Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 11/15] io_uring/net: don't count the buffers of a send bundle Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 12/15] io_uring/net: restore the cmsg buffer on recvmsg retry Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 13/15] io_uring_poll: kill the no longer necessary barrier after poll_wait() Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 14/15] io_uring: close poll activation race when enabling rings Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 15/15] io_uring/cancel: arm local work wakeups only for submitter Jens Axboe

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=20261205231107.4023506-2-axboe@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=gregkh@linuxfoundation.org \
    --cc=io-uring@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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.