From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512358; b=NSfTygelxqiMKN9EB+DeLeASgTmSK+3AY9+Xx/Mk6HWFganXHO3GrzUIlwjGbJAL6B+E ca0KYaO4yW7bO5mLpmV+H+82BDRaS3P8jS8w9fi2l59JR2ReKuTOMyCEO8wj/3+OFewTw +KGayUmbqWkL+IwiGE8oZa7cnRdNErbmWkUd1cqXAyGZlobkgn6ebKeIq4CvXYkW7V8ui w2AEicQNtxs5CKY+CGUYL0WF0aeqVPQT63ihSNhdcWk5suwwlnbGs3zEwHEj8HOgscD6d 8ZytuoC9Wxa6TgrJlFIP80M0PKDgzwoF31xwKHgfRx2yatHPVS2NYv6Ibj1EeNfJpYw== 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=S2XkPpJvswMEBZteoFFOdmU1QKIt4B9OI4Rwk/0VhTXoXNbFZ73kurtTePxWdhkCzE+m oMELGuCsLK47ryGfolQ4C91lJglorDMKczHJkeXIjMVH5cfuub2x0Nc59t8LtFLf12f1T y3g+j5hn+qWwXhRpA//Mzb2Qn4wufy2RcDTw6yx1cH4cyG1BsH7FJauEnQq6LC9nyRJo/ akAIYh4N1CrvA7tTEJbr0UqUfEaPN2n3uBSbFpb2R6wj2K6J6KwumCcgIalCDa1Up/rGN MphO8mz22DtRUuNb5YgnfB7ywGHQLsNF/AxIpJ46FaaLvZUygZp4j82VoC3+KY5Cudg== 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.46 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (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 152B3606A33E for ; Sat, 5 Dec 2026 23:12:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 152B3606A33E 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-f46.google.com with SMTP id 46e09a7af769-862d919fb1cso1243344a34.0 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=fibd4sHcDD+hROtXgoFQTQxxpw8tOvImQfT/wqT5U8EG9L6XDEOrxZR/w7AZ551d2f zRcgF9B6F/9Ihe7ZupCAMC3TwANh3Y5uY8kjgRuj12Nf99MjzYlr4uXOKIjNd3LWKafe +9+PJPBAH3fI6s8h01SKp57vf/U38o9PBHY4iRvltP1fPFOI+Xw8sW0tXJ4ez1AGaYaW ulkLNdPHWPHa9fSSemYzO4xrWZE+bIgrAH34ChhwibkwIUtJyVnDcdf4pPWR0glIw+sM YkMqEgXdHnrTFbbMhBCx8bPna8CEM4lmAfCMkzyrT0+nBZwBsppCalwjF+w0JeqaiVxc Bj9Q== X-Gm-Message-State: APuU4Z/V1hV45HEKhvLgLWCIaC1qQUJzSzfgW/idYAPr5rIEiSFOInbJ k3S0VYje539PI48xuKsmfvv3mpYt98NuDl2e2hhjV7dQwsswBluKO+GaZcp+euWlC+6b9/3B0Sg 8gv3HVf8= X-Gm-Gg: AZFdTZckEGf/Gu/hHnH+lpDdRaoGFRQ9ea1ZLT9uIdIGHLwq/oxr/lwAdy9qlEj1Z46 11ajvK/j5D9JuRPiYtg9jJGboaae6v423Hh71/EdXuYYyaj/5OdxOX95kl9lqtGONAl4TmaGII6 5NI+CU1S1CzAhSIyY3Uyie6ZWyeiRNMKoRlEdx/ar+eIMARL0a9RWP9S66KTgIX0WeiyyJSO3FN knJUlY07J52gzzWNDYNN+GeR2MJ7D/s/tOwCQcwGmp5CGi9duOlrUyopSiybJugaePrq6L3ES1v rpeg8JagyRAWWlpDCh7xIs7gYMfHa4cSccxTDZbDKd3czhQj91ujVUm+9SedF0Hr7HsW3ZsMmcT kh2itNpj07zLlBcRuHffS1xwkIYWv3/LKHoU/iVPyXnlugK/oBz2ovGf999Ea7v8ulm1/gCt+JZ L/2W+7Br5Rovm93Yq4z/WDD5NwTX+wcg3obhUo28QvX7nWZPbr4RYrOBoGULk0Qt4FWs9xvwn1b eDBLq0Bl+XdsvHNOVDVN19/74nvvtJEikQFL2zzlCSb+q1DJxmWqXuGVB63c8F4nK93s5AokTdo zB4YBfD3DbidKpRg7lDhKhIaUJmezN/xX4r2hDKsD9VtdKQ32xoZhWNZSFnqRhzzlepOds2/d+/ 4CVzT9neK855KB/kFMGo1200XVcozagA68661 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: 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 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