From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512273; b=bzn2c4Ea5rr3O6sQbaNSTVjsUAKrjmAuCAPvEstO3fNoCeVjCAdF5tpSye/eJglyrUca SePkSj7lM8Z3SBaMCuTWvZ2f0IWftkeP7kYsfjhNtmYcQcXVirPfy9JrMInZ27fSE05Bv Y/WOhVmp1+mqPTnp8uHSwRtcBXt5lCP9XDxNki3etjntibj3ffJjpuVzyX2+9R3ZDrHVQ 3AiKkk93+uJdOMxKBcWgX2Q3anYF04JHVWGS8b0WUJP2ilAQaXVjYjyJgf0XWhkeZgnV5 h2lCTBjcJzetmOyIiuhlnf+mkIt1OedHG+eu4ymp53prekl6jNeQ0FPYkXH6OclqUvA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512273; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=Cun0glnwzTLETjsWHgmT2AI50sfug4gC4EfxjnxuZ/g=; b=pHMK9kTvDJzq5QP+d14YURIo58UKaAGt6i9gzkFroU8rhTlBYLOEttcSkVwv+rhccP6D Bfm21ayFo+oj+fiyOG7N8DbOMngcStkMk60qEofp+oJQLk96iwd0SSBsTOZhVeODNuWsS qOjUolWLungIgN1FOMFlNBvsllV8zVxQ1K6GsAmQAuspV7RsJ4fC6wVumy0eIO822MBAu +9QpRcWmgxUQy+STe6thwavybpMBwJC2UW1Rl+ritInRNXCHBdyIoxp7WyMRJSFTTmxAA iFmYgYVbnCiiKygPtXqxtG0+nkQqLDJbceiuH33L0Lep7KYZYC4nhRjKS1V/zIRP5ag== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass header.d=kernel.dk header.i=@kernel.dk header.a=rsa-sha256 header.s=google header.b=cV29hRA+; arc=none smtp.remote-ip=209.85.210.45 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24264606A334 for ; Sat, 5 Dec 2026 23:11:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 24264606A334 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.dk header.i=@kernel.dk header.a=rsa-sha256 header.s=google header.b=cV29hRA+ Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-8253bc5a613so1480729a34.0 for ; Sat, 05 Dec 2026 15:11:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512272; x=1797117072; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Cun0glnwzTLETjsWHgmT2AI50sfug4gC4EfxjnxuZ/g=; b=cV29hRA+LyIuJtyw9PTwGeVTeuRP4GVgX+urP8D/R+5ZlNgSBBkuOuoWA1X+Yvbsqo jpPGWZWB6v6f6FUJgU6IC6VEHgE2ML+jSjufer8AYa4S7imVPRE7vcLjqwgVT+lD2/Pg NI2D0O0zTAN2Zd5R+xTmBI/T8XUVp7F2KDGOM/fRvsar8M+PCfNCYnna8jKqDbbVDmml 2GGQyAYz1Nf1qs4+ga28aqvAOpIsHR8EAHmOYGc2DR4plpZBv8X0Jr4d0ZgjdrpC7zhn eVUaUKdUgMlUFfcf+X+a0o5ZzvTQqA3nKMhDcCW5nJhIJzWHpGwzmkP5t87zjZbaosHX QORA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512272; x=1797117072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Cun0glnwzTLETjsWHgmT2AI50sfug4gC4EfxjnxuZ/g=; b=vvd0xrtSdCwKvtgXwrrdSO4QNYx+qk4sePUrIfIIxd44qUdPmBrdxoO54GrK63aC2k eIGVq2iAn27va/sA8RpxZoGpn9wImRmTnFzobdrekP+AnDgU5cgpt+XF+ohq6vlFTXEg myX0yyqaMGkrkjAyuzD06APnLxSNBSuVEGtbA0RHxn4fuuhBTI2G744JUA6BNxFR0cs7 Tk02n9AgDqow+II1aJnTBTbchnL2KNOken+VUIwbYUkb8R6zef+H2iBev4e54h4lbdke 4iD+OVoGniLRz495hiBRDnZnXGmADrkDIwI/eQRP6NRVHKzEhfI2BGGgxOIKELL+VU9K Vvpw== X-Gm-Message-State: APuU4Z86zLqiuu3/ysMnmpZQLS6VPTJWjZ+FzfpY3GocMxjWSWCw5YiC r0175fzSWtWvMjdgW1QDhtQ5DrnCfBCrrSKERhFelxsxIzqZd/ZrJYdLwrtV8GXoMHA= X-Gm-Gg: AZFdTZcwVeEQL6ij/v/vFIXCMhGR5yunD77x8VZW34pAgeqHpGqKn44zVdHexUD+S60 qgravLSriZANIVJL0ak9DBvw/AA53yzLNcooULXTD0GDxTQJ0banFd0X+COl2wWkZb7OJYqefkp gPF0/MhDonL70o+iqfhSOXO8BophMBPpmvlF6i5qPl7fwnNgAk699G/HnPNeCRhdGtfiOlEOVqE 928vxlG6DZeA4viSrL5RtUpYvpiNrOEs3VkR9i6dcBbwv1WsZFl6rUW8vZ6I7rKgdlXm69j+6/0 mAQXszYRRmQ0ilj3R4x7Db/EOuSCJMUC/euFna2ImLn9D8MVS5kUa46+axVjPprLxoEZ/nbgQzQ BKeNxLQj/7llHwI64BkLmlzy7DJ46l5GMbVyC0Cu9mofghdcQ1CNtDwyFuuMxiYAxauA1ygGWvY mQ/SjaS6QBVagMgBjRBqr4kPLRYbhKY28zgOq8aLRNa+n6cij3HUafq81VgMeEWSBjw7t+CsGFt ZP/LMMjd71Dx7L1mRsopDQVnYLkzOvxA2CgXwMrNhJb7H8h+Uu8B2A2p92ZwwijBpTofWyK3rEJ xzf/qrjpzSE9rJHioz/evpQvrbD1XGnXLhdeC0ooryvF7xLBMkZV9mcLirGnKbNPpUWbNxyhyp0 4xmXIBYwNiOwmBWVtHY6TO5AnqNLMlhdO+q64QjZfBAlXO01ZohOaJk0lMg== X-Received: by 2002:a05:6808:50ac:b0:57a:5851:f586 with SMTP id 5614622812f47-57f2087b804mr5483444b6e.49.1796512272065; Sat, 05 Dec 2026 15:11:12 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57f1f65febbsm4163964b6e.6.2026.12.05.15.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:11:11 -0800 (PST) From: Jens Axboe 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 Message-ID: <20261205231107.4023506-2-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231107.4023506-1-axboe@kernel.dk> References: <20261205231107.4023506-1-axboe@kernel.dk> X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Louis Thiery 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 Reviewed-by: Pavel Begunkov Reported-by: Brian Martin Closes: https://lore.kernel.org/io-uring/CAC+fX10wVVSqGnfCg+aazorsCxB34sUDV-XJiBPd6R3Kuqc-7Q@mail.gmail.com/ Tested-by: Brian Martin Link: https://patch.msgid.link/20261119232935.1708458-1-thiery.louis@gmail.com Signed-off-by: Jens Axboe --- 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