From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512358; b=WyrIHSvimXZQuuKXdckpJwuVOjeru8stvUrHSsLbo01I3ytow8SopTRcRuHP0uwLUviM TFKPBba31HUiW525Wn0Edjv7Yu9lKya+x8bXENNIKyC3s1LVcToOwGP0ydUrVGd0vVXO6 TMlsn3DeQNt9XBydwL7eEWBmNso2YP90SenNfSSU4dXfwIXLN/9Jg3eTMKSJ/dBdd55pA a+2DdNrgES8qRHes+Yw/D1wPikuK69baIDlF+KazKw3dKy+x5lc40Zy/vAKcB6ERd5GTe 04wiMpXnYsp0/PT5EPv4LBh3+Icyl+9k5RoJtkctkcYB0KPSHDHBBIa/ASCKGgaO3pA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512358; 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=PrvfBNuRnAfMdIuvbH54nXw90gUzIJ/fMe/UMp8IYw4=; b=AmBwDrErmayy/uqBn51+ZvJYpjqgWQ7Dn2nJtUAmB0p54U8q9Tm14mM/hx0wPQZzYDwZ 8edxTw1ocHyMGCHuFgSmb25RcYLxvoJY/qEOg6lkhHZkqM6LS/pbHLrnJpf61cJDY+96Q MX1P6YCl1AKYdcp7hfKcjcPoC0gS+KoHUksMHBu06liW92a46sstxvsrOyADM7X+PkwfB e8oDtqX5CpFftIJSgxVkI2YIPH3Meb2gu9zpPuH4GMdMJA+B/Xs+7j0VmRZME6SJycnCQ BedndiH3NhVNux00eMyUWyeumgpdfEjw8T6EMJC0PexDDi+pvUYSEBXQ4plLEQIgYuw== 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=tZPYkScR; arc=none smtp.remote-ip=209.85.210.42 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (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 E9D23606A338 for ; Sat, 5 Dec 2026 23:12:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E9D23606A338 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=tZPYkScR Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-8629fc8ad64so1176943a34.1 for ; Sat, 05 Dec 2026 15:12:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512357; x=1797117157; 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=PrvfBNuRnAfMdIuvbH54nXw90gUzIJ/fMe/UMp8IYw4=; b=tZPYkScR7VXkpPJtTztQ0zPAL1ClVXldGczsyk2QK56/jrsIvKHAV4Mq6DJEcd2koX x1Q2OYjOJzXIQ+dhm+VVzSmRO7HU7FEzA1wcIaEYMVws0zEHkv6mQxJcMnk7ccrEd+OS sGTfOCyhtdUuXZou7HlKdlQacmq4OFM+hHT6n3armVTfJMXkxN9OwsC/KheI3stW59bg PBGpTLsEdZgp5I8t7a5yvjmO+KNYIonjmrxFyj8meZJgQY86ZyVJmBwdfbgwoJtmGZUs Q7SkLk+rN+bb+BV6dULwygK5yqpW5RuH3RdldmoM3amwD+YcoORTJhHYrXZZx+/6971Q /gqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512357; x=1797117157; 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=PrvfBNuRnAfMdIuvbH54nXw90gUzIJ/fMe/UMp8IYw4=; b=A+bIEDVsAHL6j1orfw1epL7Qh9V9NL4mwYXQb7Qdht8BkHF0XFTBKfJesEA9My8KXL lBcO8r5UGyDCyZdZl4VwpIfqpxyuApCXvZ2V1YGdMK10gN6+WyqeveCcVfuhcoIoOnJp M/YR0owSqMtNLOQgYp08jQP7ZeVTNErvYahe238WWE+1n/wzlCfvO5frxDmUyvtLosyp +vUoRU3kd7SRKsL4SWg1wi0k0Lld9PkI6c9legy5wPyTitPv+KNM9q8HycM+nTlU5Di6 0A0brBnkQluK8ZjXVNMCih7DgID1n2olwKqe18SOiC/n32pVU2V/8ntm/y1v19TijrOW C0vA== X-Gm-Message-State: APuU4Z9KqRppEgPyTZksyIRjfiHUX2+Xf98JML9I1OgHWQuqgs7yHyxx oZHQID9Ru3AJnKVivG11sX8iob4QUvhKS1JlzluZqQB1BHPfGCuGX3qz+JAsiT+25MdGg2PnPxp 83lmmoCM= X-Gm-Gg: AZFdTZdrB1L9gky0k8iCLgqMseAcw8YFLp1Rwbu21GjySp54MQq0tHAdS9DmzxQ6GxK RYVCoQzjpxPN25r9dni5eKYNYBUKraF2SFRuZ04ACUuYRRXrp/c4Sd5jqmmCoKSWi4wwsqbegBs pCUQ853/4qKaZG7bnSeZbygyr6A2xkpNxTRGdWiqqDL1UC6mF+FHmYFlQqdWQ/cK9hroIF1z3Fq uzl4XHEyMsuvnGrsaA3hD2BxUvwyQUSSqGUJpXbpFRx2fiB+YTri/YNh8rIWtz3B8Qnkj4C+TxN 9+6FtMnMXTiJODwcLMLsM8qNq914MTXkj/iDSXnftTrgxOZNXqf2gFPi4nGGHi4S9dbJ/vHi/xG FnzwrjNT197Ovm/+7PnW4UNem2ru3oZE17b5z5KIxCWlUjVsGatzyMWCubRBAm0rCV5IH2zXSdw 4FY67LQhEPH/aDo05X2xiLN3Di3OQ9vxE1bFZHiU2ThNjTcCvi8HTjAlvDw3XW1UviCbrv++YTr GtKKh4gRrFDvTP56hSYRWvmWTFC1Ej8/GLxrBR44BZZ3/PBhp4cVcxNrH2HtRwcfp3QHNm0FFGF DN907vTxbh5HlDTdKKEYw8wDWajRMyJHXyEn36qeQL7lTxva4DdHNrD5eMZAgEYdRpLITcaIjVp lqnHqMOwvxWslKWg/XiVBJEUJtpSf9HGVK+1b X-Received: by 2002:a05:6830:2e10:b0:862:9f06:8655 with SMTP id 46e09a7af769-863f89e1b7fmr6856690a34.8.1796512357056; Sat, 05 Dec 2026 15:12:37 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863f7dd42a8sm6279788a34.0.2026.12.05.15.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:12:36 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 6.6.y 01/13] io_uring/net: don't charge the folio offset to truesize for managed frags Date: Sat, 5 Dec 2026 23:12:21 +0000 Message-ID: <20261205231233.4140988-2-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231233.4140988-1-axboe@kernel.dk> References: <20261205231233.4140988-1-axboe@kernel.dk> X-Mailing-List: stable@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 d944b0466b41..67a9cf004e13 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -1141,7 +1141,12 @@ static int io_sg_from_iter(struct sock *sk, 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